Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
77c9fd0b
提交
77c9fd0b
authored
3月 13, 2008
作者:
bergstrj@iro.umontreal.ca
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
removed dead code
上级
4336f227
显示空白字符变更
内嵌
并排
正在显示
1 个修改的文件
包含
2 行增加
和
88 行删除
+2
-88
_test_gradient.py
_test_gradient.py
+2
-88
没有找到文件。
_test_gradient.py
浏览文件 @
77c9fd0b
...
@@ -86,9 +86,6 @@ class _test_grad_sources_inputs(unittest.TestCase):
...
@@ -86,9 +86,6 @@ class _test_grad_sources_inputs(unittest.TestCase):
a1
=
retNone
([
i
],
self
)
a1
=
retNone
([
i
],
self
)
g
=
grad_sources_inputs
([(
a1
.
out
,
None
)],
None
)
g
=
grad_sources_inputs
([(
a1
.
out
,
None
)],
None
)
def
test_no_invalid_graph
(
self
):
"""Test that bprop fails on an invalid graph"""
raise
NotImplementedError
()
def
test_1in_1out
(
self
):
def
test_1in_1out
(
self
):
"""Test grad is called correctly for a 1-to-1 op"""
"""Test grad is called correctly for a 1-to-1 op"""
gval
=
gof
.
result
.
ResultBase
()
gval
=
gof
.
result
.
ResultBase
()
...
@@ -288,6 +285,8 @@ def matrices(n):
...
@@ -288,6 +285,8 @@ def matrices(n):
return
[
matrix
()
for
i
in
xrange
(
n
)]
return
[
matrix
()
for
i
in
xrange
(
n
)]
#TODO: move this to the _test_tensor_ops.py
class
_testCase_matinv
:
# (unittest.TestCase):
class
_testCase_matinv
:
# (unittest.TestCase):
def
setUp
(
self
):
def
setUp
(
self
):
...
@@ -320,90 +319,5 @@ class _testCase_matinv:# (unittest.TestCase):
...
@@ -320,90 +319,5 @@ class _testCase_matinv:# (unittest.TestCase):
"""Matrix inversion by gradient descent (eval mode)"""
"""Matrix inversion by gradient descent (eval mode)"""
self
.
assertEqual
((
'2.67327580893'
,
'0.000438649434819'
),
self
.
matinv
(
3
))
self
.
assertEqual
((
'2.67327580893'
,
'0.000438649434819'
),
self
.
matinv
(
3
))
class
_testCase_old
:
#(unittest.TestCase):
def
setUp
(
self
):
numpy
.
random
.
seed
(
1
)
def
test_grad_wrt_ndarray_pointer
(
self
):
"""Grad indexing by un-wrapped ndarray"""
a
=
numpy
.
ones
((
4
,
4
))
b
=
numpy
.
ones
((
4
,
4
))
c
=
numpy
.
ones
((
4
,
4
))
expr
=
core
.
sum
(
core
.
dot
(
core
.
add
(
a
,
b
),
c
))
g
=
grad
(
expr
)
g
[
a
]
def
test_bprop_call_order
(
self
):
"""Ensure call before bprop is illegal"""
a
=
numpy
.
ones
((
3
,
3
,
3
))
b
=
core
.
exp
(
a
)
gb
=
Grad
({
b
:
wrappers
.
wrap
(
a
)})
try
:
gb
(
a
)
self
.
assertEqual
(
'should have raised'
,
0
)
except
Exception
,
e
:
self
.
assertEqual
(
str
(
e
),
'Grad.__call__ only makes sense after a bprop'
)
return
self
.
assertEqual
(
'should have caught, returned'
,
0
)
def
test_undefined_grad0
(
self
):
"""Make sure posneg works with fully specified gradients"""
a
=
numpy
.
ones
((
3
,
3
,
3
))
b
,
c
=
_testCase
.
posneg
(
a
)
g
=
Grad
({
b
:
wrappers
.
wrap
(
a
),
c
:
wrappers
.
wrap
(
a
)})
g
.
bprop
()
max
=
numpy
.
max
(
g
(
a
))
min
=
numpy
.
min
(
g
(
a
))
self
.
assertEqual
(
max
,
min
)
self
.
assertEqual
(
max
,
0.0
)
def
test_undefined_grad1
(
self
):
"""Propagate undefined values through posneg's first gradient"""
a
=
numpy
.
ones
((
3
,
3
,
3
))
b
,
c
=
_testCase
.
posneg
(
a
)
gb
=
Grad
({
b
:
wrappers
.
wrap
(
a
)})
try
:
gb
.
bprop
()
self
.
assertEqual
(
'should have raised'
,
0
)
except
UndefinedError
:
return
self
.
assertEqual
(
"Should have been error"
,
0
)
def
test_undefined_grad2
(
self
):
"""Propagate undefined values through posneg's second gradient"""
a
=
numpy
.
ones
((
3
,
3
,
3
))
b
,
c
=
_testCase
.
posneg
(
a
)
gc
=
Grad
({
c
:
wrappers
.
wrap
(
a
)})
try
:
gc
.
bprop
()
self
.
assertEqual
(
'should have raised'
,
0
)
except
UndefinedError
:
return
self
.
assertEqual
(
"Should have been error"
,
0
)
def
test_undefined_grad3
(
self
):
"""Ignore undefined values properly"""
a
=
numpy
.
ones
((
3
,
3
,
3
))
b
,
c
,
d
=
_testCase
.
posnegzero
(
a
)
#print b, c, d
g
=
Grad
({
b
:
wrappers
.
wrap
(
a
),
c
:
wrappers
.
wrap
(
a
)})
g
.
bprop
()
max
=
numpy
.
max
(
g
(
a
))
min
=
numpy
.
min
(
g
(
a
))
self
.
assertEqual
(
max
,
min
)
self
.
assertEqual
(
max
,
0.0
)
def
tearDown
(
self
):
core
.
pop_mode
()
if
__name__
==
'__main__'
:
if
__name__
==
'__main__'
:
unittest
.
main
()
unittest
.
main
()
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论