Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
ce660543
提交
ce660543
authored
5月 23, 2013
作者:
lamblin
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #1388 from nouiz/fix_crash
Fix-crash in scan grad when compute_test_value=raise
上级
3a9aa1eb
b17c1d2c
隐藏空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
60 行增加
和
4 行删除
+60
-4
scan_op.py
theano/scan_module/scan_op.py
+9
-4
test_scan.py
theano/scan_module/tests/test_scan.py
+51
-0
没有找到文件。
theano/scan_module/scan_op.py
浏览文件 @
ce660543
...
...
@@ -1355,10 +1355,15 @@ class Scan(PureOp):
# Note that we do not care about the output of
# this compute gradient. We just care to see if
# it is None or not. (i.e. disconnected or not)
tmp
=
compute_gradient
(
inner_out
,
safe_new
(
inner_out
,
dtype
=
'float64'
),
ils
)
try
:
old
=
theano
.
config
.
compute_test_value
theano
.
config
.
compute_test_value
=
'off'
tmp
=
compute_gradient
(
inner_out
,
safe_new
(
inner_out
,
dtype
=
'float64'
),
ils
)
finally
:
theano
.
config
.
compute_test_value
=
old
else
:
# It should be undefined not disconnected
tmp
=
ils
...
...
theano/scan_module/tests/test_scan.py
浏览文件 @
ce660543
...
...
@@ -3880,6 +3880,57 @@ def test_compute_test_value_nonseq():
theano
.
config
.
compute_test_value
=
backup
def
test_compute_test_value_grad
():
# Test case originally reported by Bitton Tenessi
# https://groups.google.com/d/msg/theano-users/fAP3i2CbskQ/3OgBf4yjqiQJ
WEIGHT
=
numpy
.
array
([
1
,
2
,
1
,
3
,
4
,
1
,
5
,
6
,
1
,
7
,
8
,
1
],
dtype
=
'float32'
)
old_compute_test_val
=
theano
.
config
.
compute_test_value
old_exception_verbosity
=
theano
.
config
.
exception_verbosity
try
:
theano
.
config
.
compute_test_value
=
'raise'
theano
.
config
.
exception_verbosity
=
'high'
W_flat
=
tensor
.
fvector
(
name
=
'W'
)
W_flat
.
tag
.
test_value
=
WEIGHT
W
=
W_flat
.
reshape
((
2
,
2
,
3
))
outputs_mi
=
tensor
.
as_tensor_variable
(
numpy
.
asarray
(
0
,
dtype
=
'float32'
))
outputs_mi
.
tag
.
test_value
=
numpy
.
asarray
(
0
,
dtype
=
'float32'
)
def
loss_mi
(
mi
,
sum_mi
,
W
):
outputs_ti
=
tensor
.
as_tensor_variable
(
numpy
.
asarray
(
0
,
dtype
=
'float32'
))
outputs_ti
.
tag
.
test_value
=
numpy
.
asarray
(
0
,
dtype
=
'float32'
)
def
loss_ti
(
ti
,
sum_ti
,
mi
,
W
):
return
W
.
sum
()
.
sum
()
.
sum
()
+
sum_ti
result_ti
,
_
=
theano
.
scan
(
fn
=
loss_ti
,
outputs_info
=
outputs_ti
,
sequences
=
tensor
.
arange
(
W
.
shape
[
1
],
dtype
=
'int32'
),
non_sequences
=
[
mi
,
W
],
)
lossmi
=
result_ti
[
-
1
]
return
sum_mi
+
lossmi
result_mi
,
_
=
theano
.
scan
(
fn
=
loss_mi
,
outputs_info
=
outputs_mi
,
sequences
=
tensor
.
arange
(
W
.
shape
[
0
],
dtype
=
'int32'
),
non_sequences
=
[
W
],
)
loss
=
result_mi
[
-
1
]
grad
=
tensor
.
grad
(
loss
,
W_flat
)
finally
:
theano
.
config
.
compute_test_value
=
old_compute_test_val
theano
.
config
.
exception_verbosity
=
old_exception_verbosity
def
test_constant_folding_n_steps
():
# The following code used to crash at revision 2060b8f, in the constant
# folding optimization step.
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论