Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
4ca430a8
提交
4ca430a8
authored
9月 05, 2012
作者:
Ian Goodfellow
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
removed uses of the warn_type flag
上级
378430eb
隐藏空白字符变更
内嵌
并排
正在显示
1 个修改的文件
包含
9 行增加
和
12 行删除
+9
-12
test_gradient.py
theano/tests/test_gradient.py
+9
-12
没有找到文件。
theano/tests/test_gradient.py
浏览文件 @
4ca430a8
...
@@ -16,11 +16,8 @@ from theano.gof.null_type import NullType
...
@@ -16,11 +16,8 @@ from theano.gof.null_type import NullType
one
=
theano
.
tensor
.
as_tensor_variable
(
1.
)
one
=
theano
.
tensor
.
as_tensor_variable
(
1.
)
def
_grad_sources_inputs
(
*
args
):
# warn_type was introduced after this code, it complains throughout for nothing.
return
grad_sources_inputs
(
warn_type
=
False
,
*
args
)
class
test
_
grad_sources_inputs
(
unittest
.
TestCase
):
class
testgrad_sources_inputs
(
unittest
.
TestCase
):
def
test_retNone1
(
self
):
def
test_retNone1
(
self
):
"""Test that it is not ok to return None from op.grad()"""
"""Test that it is not ok to return None from op.grad()"""
...
@@ -35,7 +32,7 @@ class test_grad_sources_inputs(unittest.TestCase):
...
@@ -35,7 +32,7 @@ class test_grad_sources_inputs(unittest.TestCase):
pass
pass
a
=
retNone
()
.
make_node
()
a
=
retNone
()
.
make_node
()
try
:
try
:
_
grad_sources_inputs
([(
a
.
out
,
one
)],
None
)
grad_sources_inputs
([(
a
.
out
,
one
)],
None
)
except
TypeError
,
e
:
except
TypeError
,
e
:
return
return
self
.
fail
()
self
.
fail
()
...
@@ -52,10 +49,10 @@ class test_grad_sources_inputs(unittest.TestCase):
...
@@ -52,10 +49,10 @@ class test_grad_sources_inputs(unittest.TestCase):
i
=
theano
.
tensor
.
vector
()
i
=
theano
.
tensor
.
vector
()
j
=
theano
.
tensor
.
vector
()
j
=
theano
.
tensor
.
vector
()
a1
=
retOne
()
.
make_node
(
i
)
a1
=
retOne
()
.
make_node
(
i
)
g
=
_
grad_sources_inputs
([(
a1
.
out
,
one
)],
None
)
g
=
grad_sources_inputs
([(
a1
.
out
,
one
)],
None
)
a2
=
retOne
()
.
make_node
(
i
,
j
)
a2
=
retOne
()
.
make_node
(
i
,
j
)
try
:
try
:
g
=
_
grad_sources_inputs
([(
a2
.
out
,
one
)],
None
)
g
=
grad_sources_inputs
([(
a2
.
out
,
one
)],
None
)
except
ValueError
,
e
:
except
ValueError
,
e
:
return
return
self
.
fail
()
self
.
fail
()
...
@@ -71,7 +68,7 @@ class test_grad_sources_inputs(unittest.TestCase):
...
@@ -71,7 +68,7 @@ class test_grad_sources_inputs(unittest.TestCase):
def
grad
(
self
,
inp
,
grads
):
def
grad
(
self
,
inp
,
grads
):
return
gval
,
return
gval
,
a1
=
O
()
.
make_node
()
a1
=
O
()
.
make_node
()
g
=
_
grad_sources_inputs
([(
a1
.
outputs
[
0
],
one
)],
None
)
g
=
grad_sources_inputs
([(
a1
.
outputs
[
0
],
one
)],
None
)
self
.
assertTrue
(
g
[
a1
.
inputs
[
0
]]
is
gval
)
self
.
assertTrue
(
g
[
a1
.
inputs
[
0
]]
is
gval
)
def
test_1in_Nout
(
self
):
def
test_1in_Nout
(
self
):
...
@@ -87,7 +84,7 @@ class test_grad_sources_inputs(unittest.TestCase):
...
@@ -87,7 +84,7 @@ class test_grad_sources_inputs(unittest.TestCase):
gz1
,
gz2
=
grads
gz1
,
gz2
=
grads
return
gval
,
return
gval
,
a1
=
O
()
.
make_node
()
a1
=
O
()
.
make_node
()
g
=
_
grad_sources_inputs
([(
a1
.
outputs
[
0
],
one
)],
None
)
g
=
grad_sources_inputs
([(
a1
.
outputs
[
0
],
one
)],
None
)
self
.
assertTrue
(
g
[
a1
.
inputs
[
0
]]
is
gval
)
self
.
assertTrue
(
g
[
a1
.
inputs
[
0
]]
is
gval
)
def
test_Nin_1out
(
self
):
def
test_Nin_1out
(
self
):
...
@@ -104,7 +101,7 @@ class test_grad_sources_inputs(unittest.TestCase):
...
@@ -104,7 +101,7 @@ class test_grad_sources_inputs(unittest.TestCase):
gz
,
=
grads
gz
,
=
grads
return
(
gval0
,
gval1
)
return
(
gval0
,
gval1
)
a1
=
O
()
.
make_node
()
a1
=
O
()
.
make_node
()
g
=
_
grad_sources_inputs
([(
a1
.
outputs
[
0
],
one
)],
None
)
g
=
grad_sources_inputs
([(
a1
.
outputs
[
0
],
one
)],
None
)
self
.
assertTrue
(
g
[
a1
.
inputs
[
0
]]
is
gval0
)
self
.
assertTrue
(
g
[
a1
.
inputs
[
0
]]
is
gval0
)
self
.
assertTrue
(
g
[
a1
.
inputs
[
1
]]
is
gval1
)
self
.
assertTrue
(
g
[
a1
.
inputs
[
1
]]
is
gval1
)
...
@@ -120,7 +117,7 @@ class test_grad_sources_inputs(unittest.TestCase):
...
@@ -120,7 +117,7 @@ class test_grad_sources_inputs(unittest.TestCase):
def
grad
(
self
,
inp
,
grads
):
def
grad
(
self
,
inp
,
grads
):
return
gval0
,
gval1
return
gval0
,
gval1
a1
=
O
()
.
make_node
()
a1
=
O
()
.
make_node
()
g
=
_
grad_sources_inputs
([(
a1
.
outputs
[
0
],
one
)],
None
)
g
=
grad_sources_inputs
([(
a1
.
outputs
[
0
],
one
)],
None
)
self
.
assertTrue
(
g
[
a1
.
inputs
[
0
]]
is
gval0
)
self
.
assertTrue
(
g
[
a1
.
inputs
[
0
]]
is
gval0
)
self
.
assertTrue
(
g
[
a1
.
inputs
[
1
]]
is
gval1
)
self
.
assertTrue
(
g
[
a1
.
inputs
[
1
]]
is
gval1
)
...
@@ -136,7 +133,7 @@ class test_grad_sources_inputs(unittest.TestCase):
...
@@ -136,7 +133,7 @@ class test_grad_sources_inputs(unittest.TestCase):
return
[
one
]
return
[
one
]
i
=
theano
.
tensor
.
matrix
()
i
=
theano
.
tensor
.
matrix
()
a1
=
O
(
self
)
.
make_node
(
i
)
a1
=
O
(
self
)
.
make_node
(
i
)
g
=
grad_sources_inputs
([(
a1
.
outputs
[
0
],
one
)],
None
,
warn_type
=
False
)
g
=
grad_sources_inputs
([(
a1
.
outputs
[
0
],
one
)],
None
)
self
.
assertTrue
(
g
[
i
]
is
one
)
self
.
assertTrue
(
g
[
i
]
is
one
)
def
test_unimplemented_grad_func
():
def
test_unimplemented_grad_func
():
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论