Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
4b0f029a
提交
4b0f029a
authored
3月 18, 2008
作者:
Olivier Breuleux
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
merge
上级
d82e9fd4
显示空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
20 行增加
和
7 行删除
+20
-7
_test_tensor.py
_test_tensor.py
+2
-2
tensor.py
tensor.py
+18
-5
没有找到文件。
_test_tensor.py
浏览文件 @
4b0f029a
...
@@ -188,9 +188,9 @@ class T_pow(unittest.TestCase):
...
@@ -188,9 +188,9 @@ class T_pow(unittest.TestCase):
verify_grad
(
self
,
DivElemwise
,
[
numpy
.
random
.
rand
(
3
,
4
),
numpy
.
random
.
rand
(
3
,
4
)
+
0.1
])
verify_grad
(
self
,
DivElemwise
,
[
numpy
.
random
.
rand
(
3
,
4
),
numpy
.
random
.
rand
(
3
,
4
)
+
0.1
])
verify_grad
(
self
,
PowElemwise
,
[
numpy
.
random
.
rand
(
3
,
4
),
numpy
.
random
.
rand
(
3
,
4
)])
verify_grad
(
self
,
PowElemwise
,
[
numpy
.
random
.
rand
(
3
,
4
),
numpy
.
random
.
rand
(
3
,
4
)])
def
test_scalar_l
(
self
):
def
test_scalar_l
(
self
):
verify_grad
(
self
,
PowScalarL
,
[
numpy
.
random
.
rand
(
3
),
3.0
])
verify_grad
(
self
,
PowScalarL
,
[
numpy
.
random
.
rand
(
3
),
numpy
.
asarray
(
3.0
)
])
def
test_scalar_r
(
self
):
def
test_scalar_r
(
self
):
verify_grad
(
self
,
PowScalarR
,
[
numpy
.
random
.
rand
(
3
),
3.0
])
verify_grad
(
self
,
PowScalarR
,
[
numpy
.
random
.
rand
(
3
),
numpy
.
asarray
(
3.0
)
])
class
_testCase_matinv
:
#(unittest.TestCase):
class
_testCase_matinv
:
#(unittest.TestCase):
...
...
tensor.py
浏览文件 @
4b0f029a
...
@@ -119,6 +119,8 @@ class _Op(Op):
...
@@ -119,6 +119,8 @@ class _Op(Op):
nin
=
-
1
nin
=
-
1
nout
=
1
nout
=
1
_destroy_map
=
{}
def
__init__
(
self
,
*
inputs
):
def
__init__
(
self
,
*
inputs
):
def
as_tensor
(
obj
):
def
as_tensor
(
obj
):
...
@@ -148,17 +150,28 @@ class _Op(Op):
...
@@ -148,17 +150,28 @@ class _Op(Op):
def
propagate_dtype
(
self
,
*
i_dtypes
):
def
propagate_dtype
(
self
,
*
i_dtypes
):
def
upcast
(
dtype
,
*
dtypes
):
def
upcast
(
dtype
,
*
dtypes
):
z
=
numpy
.
zeros
((),
dtype
=
dtype
)
z
=
numpy
.
zeros
((),
dtype
=
dtype
)
#print '----', self.__class__
#print type(z), dtype
for
dtype
in
dtypes
:
for
dtype
in
dtypes
:
z
=
z
+
numpy
.
zeros
((),
dtype
=
dtype
)
z
=
z
+
numpy
.
zeros
((),
dtype
=
dtype
)
#print type(z), type(dtype), dtype
return
str
(
z
.
dtype
)
return
str
(
z
.
dtype
)
for
dtype
in
i_dtypes
:
for
dtype
in
i_dtypes
:
if
dtype
is
None
:
if
dtype
is
None
:
raise
TypeError
(
"Expected a Tensor."
)
raise
TypeError
(
"Expected a Tensor."
)
rval
=
upcast
(
*
i_dtypes
)
upcasted
=
upcast
(
*
i_dtypes
)
return
rval
return
upcasted
# try:
# dmap = self.destroy_map()
# except AttributeError:
# dmap = {}
# rval = []
# for i in xrange(self.nout):
# if i in dmap:
# destroyed = dmap[output]
# if len(destroyed) != 1:
# raise TypeError("Cannot infer dtype of output %s because it destroys more than one input." % output)
# rval.append(destroyed[0])
# else:
# rval.append(upcasted)
# return rval
def
impl
(
self
,
*
inputs
):
def
impl
(
self
,
*
inputs
):
raise
AbstractFunctionError
()
raise
AbstractFunctionError
()
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论