Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
4c5afa2d
提交
4c5afa2d
authored
4月 15, 2015
作者:
--global
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Adapt unit test to test both paths of fix for direct outputs
上级
c4708d8e
隐藏空白字符变更
内嵌
并排
正在显示
1 个修改的文件
包含
20 行增加
和
12 行删除
+20
-12
test_scan.py
theano/scan_module/tests/test_scan.py
+20
-12
没有找到文件。
theano/scan_module/tests/test_scan.py
浏览文件 @
4c5afa2d
...
...
@@ -2526,27 +2526,35 @@ class T_Scan(unittest.TestCase):
x
=
tensor
.
scalar
()
seq
=
tensor
.
vector
()
out
,
updates
=
theano
.
scan
(
lambda
a
,
b
:
a
+
b
,
sequences
=
seq
,
outputs_info
=
x
)
# Obtain a reference to the scan output before the subtensor and
# compile a function with it as output
assert
isinstance
(
out
.
owner
.
op
,
tensor
.
subtensor
.
Subtensor
)
out
=
out
.
owner
.
inputs
[
0
]
fct
=
theano
.
function
([
x
,
seq
],
out
[:
-
1
])
outputs_info
=
[
x
,
tensor
.
zeros_like
(
x
)]
(
out1
,
out2
),
updates
=
theano
.
scan
(
lambda
a
,
b
,
c
:
(
a
+
b
,
b
+
c
),
sequences
=
seq
,
outputs_info
=
outputs_info
)
# Obtain a reference to the scan outputs before the subtensor and
# compile a function with them as outputs
assert
isinstance
(
out1
.
owner
.
op
,
tensor
.
subtensor
.
Subtensor
)
assert
isinstance
(
out2
.
owner
.
op
,
tensor
.
subtensor
.
Subtensor
)
out1_direct
=
out1
.
owner
.
inputs
[
0
]
out2_direct
=
out2
.
owner
.
inputs
[
0
]
fct
=
theano
.
function
([
x
,
seq
],
[
out1_direct
[:
-
1
],
out2_direct
[:
-
1
]])
# Test the function to ensure valid outputs
floatX
=
theano
.
config
.
floatX
init_value
=
5.0
seq_value
=
numpy
.
arange
(
4
,
dtype
=
floatX
)
output
=
fct
(
init_value
,
seq_value
)
output
1
,
output2
=
fct
(
init_value
,
seq_value
)
expected_output
=
[
init_value
]
expected_output1
=
[
init_value
]
expected_output2
=
[
0
]
for
i
in
seq_value
[:
-
1
]:
expected_output
.
append
(
expected_output
[
-
1
]
+
i
)
expected_output2
.
append
(
expected_output1
[
-
1
]
+
expected_output2
[
-
1
])
expected_output1
.
append
(
expected_output1
[
-
1
]
+
i
)
utt
.
assert_allclose
(
output
,
expected_output
)
utt
.
assert_allclose
(
output1
,
expected_output1
)
utt
.
assert_allclose
(
output2
,
expected_output2
)
def
test_infer_shape
(
self
):
# Test for a crash in scan.infer_shape when using both
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论