Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
b1425c93
提交
b1425c93
authored
8月 07, 2013
作者:
Frederic
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add one more assert and test the 2 fixes with those assert by modifing
an existing tests.
上级
e645134c
隐藏空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
56 行增加
和
26 行删除
+56
-26
scan_op.py
theano/scan_module/scan_op.py
+13
-2
test_scan.py
theano/scan_module/tests/test_scan.py
+43
-24
没有找到文件。
theano/scan_module/scan_op.py
浏览文件 @
b1425c93
...
@@ -1582,12 +1582,23 @@ class Scan(PureOp):
...
@@ -1582,12 +1582,23 @@ class Scan(PureOp):
outer_inp_seqs
.
append
(
x
[::
-
1
])
outer_inp_seqs
.
append
(
x
[::
-
1
])
if
hasattr
(
inputs
[
0
]
.
tag
,
'test_value'
):
if
hasattr
(
inputs
[
0
]
.
tag
,
'test_value'
):
# Here we tests that the new scan input sequence all have
# the same shape[0]. This is a properties that the scan()
# fct add and we want to keep it for all Scan op. This is
# used in T_Scan.test_grad_multiple_outs_taps to test
# that.
for
x
in
self
.
outer_mitsot_outs
(
outs
):
for
x
in
self
.
outer_mitsot_outs
(
outs
):
if
hasattr
(
x
[::
-
1
][:
inputs
[
0
]]
.
tag
,
'test_value'
):
if
hasattr
(
x
[::
-
1
][:
inputs
[
0
]]
.
tag
,
'test_value'
):
assert
x
[::
-
1
][:
inputs
[
0
]]
.
tag
.
test_value
.
shape
[
0
]
==
inputs
[
0
]
.
tag
.
test_value
assert
(
x
[::
-
1
][:
inputs
[
0
]]
.
tag
.
test_value
.
shape
[
0
]
==
inputs
[
0
]
.
tag
.
test_value
)
for
x
in
self
.
outer_sitsot_outs
(
outs
):
for
x
in
self
.
outer_sitsot_outs
(
outs
):
if
hasattr
(
x
[::
-
1
][:
-
1
]
.
tag
,
'test_value'
):
if
hasattr
(
x
[::
-
1
][:
-
1
]
.
tag
,
'test_value'
):
assert
x
[::
-
1
][:
-
1
]
.
tag
.
test_value
.
shape
[
0
]
==
inputs
[
0
]
.
tag
.
test_value
assert
(
x
[::
-
1
][:
-
1
]
.
tag
.
test_value
.
shape
[
0
]
==
inputs
[
0
]
.
tag
.
test_value
)
for
x
in
self
.
outer_nitsot_outs
(
outs
):
if
hasattr
(
x
[::
-
1
]
.
tag
,
'test_value'
):
assert
(
x
[::
-
1
]
.
tag
.
test_value
.
shape
[
0
]
==
inputs
[
0
]
.
tag
.
test_value
)
outer_inp_seqs
+=
[
x
[::
-
1
][:
inputs
[
0
]]
outer_inp_seqs
+=
[
x
[::
-
1
][:
inputs
[
0
]]
for
x
in
self
.
outer_mitsot_outs
(
outs
)]
for
x
in
self
.
outer_mitsot_outs
(
outs
)]
outer_inp_seqs
+=
[
x
[::
-
1
][:
-
1
]
for
x
in
self
.
outer_sitsot_outs
(
outs
)]
outer_inp_seqs
+=
[
x
[::
-
1
][:
-
1
]
for
x
in
self
.
outer_sitsot_outs
(
outs
)]
...
...
theano/scan_module/tests/test_scan.py
浏览文件 @
b1425c93
...
@@ -1545,6 +1545,12 @@ class T_Scan(unittest.TestCase):
...
@@ -1545,6 +1545,12 @@ class T_Scan(unittest.TestCase):
x0
=
theano
.
tensor
.
vector
(
'x0'
)
x0
=
theano
.
tensor
.
vector
(
'x0'
)
y0
=
theano
.
tensor
.
vector
(
'y0'
)
y0
=
theano
.
tensor
.
vector
(
'y0'
)
W_in1
.
tag
.
test_value
=
vW_in1
u1
.
tag
.
test_value
=
v_u1
u2
.
tag
.
test_value
=
v_u2
x0
.
tag
.
test_value
=
v_x0
y0
.
tag
.
test_value
=
v_y0
def
f_rnn_cmpl
(
u1_t
,
def
f_rnn_cmpl
(
u1_t
,
u2_tm1
,
u2_tm1
,
u2_t
,
u2_t
,
...
@@ -1553,33 +1559,46 @@ class T_Scan(unittest.TestCase):
...
@@ -1553,33 +1559,46 @@ class T_Scan(unittest.TestCase):
y_tm1
,
y_tm1
,
y_tm3
,
y_tm3
,
W_in1
):
W_in1
):
return
[
theano
.
dot
(
u1_t
,
W_in1
)
+
\
return
[
theano
.
dot
(
u1_t
,
W_in1
)
+
(
u2_t
+
u2_tm1
*
u2_tp1
)
*
W_in2
+
\
(
u2_t
+
u2_tm1
*
u2_tp1
)
*
W_in2
+
theano
.
dot
(
x_tm1
,
W
),
theano
.
dot
(
x_tm1
,
W
),
(
y_tm1
+
y_tm3
)
*
theano
.
dot
(
x_tm1
,
W_out
),
(
y_tm1
+
y_tm3
)
*
theano
.
dot
(
x_tm1
,
W_out
),
theano
.
dot
(
u1_t
,
W_in1
)]
theano
.
dot
(
u1_t
,
W_in1
)]
cost
,
updates
=
scan_project_sum
(
f_rnn_cmpl
,
[
u1
,
dict
(
input
=
u2
,
taps
=
[
-
1
,
0
,
1
])],
[
x0
,
dict
(
initial
=
y0
,
taps
=
[
-
1
,
-
3
]),
None
],
W_in1
,
n_steps
=
None
,
truncate_gradient
=-
1
,
go_backwards
=
False
)
vparams
=
[
v_u1
,
v_u2
,
v_x0
,
v_y0
,
vW_in1
]
params
=
[
u1
,
u2
,
x0
,
y0
,
W_in1
]
gparams
=
theano
.
tensor
.
grad
(
cost
,
params
)
grad_fn
=
theano
.
function
([
u1
,
u2
,
x0
,
y0
,
W_in1
],
gparams
,
updates
=
updates
,
no_default_updates
=
True
,
allow_input_downcast
=
True
)
cost_fn
=
theano
.
function
([
u1
,
u2
,
x0
,
y0
,
W_in1
],
# We change the compute_test_value[_opt] flag to run the
cost
,
# assert in Scan.grad() of the new scan input sequence related
updates
=
updates
,
# to outer_mitsot_outs, outer_sitsot_outs and
no_default_updates
=
True
,
# outer_nitsot_outs. This allow to test an old Scan bug.
allow_input_downcast
=
True
)
old1
=
theano
.
config
.
compute_test_value
old2
=
theano
.
config
.
compute_test_value_opt
theano
.
config
.
compute_test_value
=
'raise'
theano
.
config
.
compute_test_value_opt
=
'raise'
try
:
cost
,
updates
=
scan_project_sum
(
f_rnn_cmpl
,
[
u1
,
dict
(
input
=
u2
,
taps
=
[
-
1
,
0
,
1
])],
[
x0
,
dict
(
initial
=
y0
,
taps
=
[
-
1
,
-
3
]),
None
],
W_in1
,
n_steps
=
None
,
truncate_gradient
=-
1
,
go_backwards
=
False
)
vparams
=
[
v_u1
,
v_u2
,
v_x0
,
v_y0
,
vW_in1
]
params
=
[
u1
,
u2
,
x0
,
y0
,
W_in1
]
gparams
=
theano
.
tensor
.
grad
(
cost
,
params
)
grad_fn
=
theano
.
function
([
u1
,
u2
,
x0
,
y0
,
W_in1
],
gparams
,
updates
=
updates
,
no_default_updates
=
True
,
allow_input_downcast
=
True
)
cost_fn
=
theano
.
function
([
u1
,
u2
,
x0
,
y0
,
W_in1
],
cost
,
updates
=
updates
,
no_default_updates
=
True
,
allow_input_downcast
=
True
)
finally
:
theano
.
config
.
compute_test_value
=
old1
theano
.
config
.
compute_test_value_opt
=
old2
num_grad
=
multiple_outputs_numeric_grad
(
cost_fn
,
num_grad
=
multiple_outputs_numeric_grad
(
cost_fn
,
[
v_u1
,
[
v_u1
,
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论