Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
ce90645e
提交
ce90645e
authored
4月 24, 2018
作者:
Glexin
提交者:
Pascal Lamblin
4月 24, 2018
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Fix MissingInputError when scan use hidden variable to calculate condition (#6597)
Fix scan MissingInputError cause by hidden var used in condition.
上级
f2a2df15
隐藏空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
22 行增加
和
2 行删除
+22
-2
scan.py
theano/scan_module/scan.py
+2
-2
test_scan.py
theano/scan_module/tests/test_scan.py
+20
-0
没有找到文件。
theano/scan_module/scan.py
浏览文件 @
ce90645e
...
@@ -820,6 +820,8 @@ def scan(fn,
...
@@ -820,6 +820,8 @@ def scan(fn,
# extract still missing inputs (there still might be so) and add them
# extract still missing inputs (there still might be so) and add them
# as non sequences at the end of our args
# as non sequences at the end of our args
if
condition
is
not
None
:
outputs
.
append
(
condition
)
fake_nonseqs
=
[
x
.
type
()
for
x
in
non_seqs
]
fake_nonseqs
=
[
x
.
type
()
for
x
in
non_seqs
]
fake_outputs
=
scan_utils
.
clone
(
outputs
,
fake_outputs
=
scan_utils
.
clone
(
outputs
,
replace
=
OrderedDict
(
izip
(
non_seqs
,
replace
=
OrderedDict
(
izip
(
non_seqs
,
...
@@ -836,8 +838,6 @@ def scan(fn,
...
@@ -836,8 +838,6 @@ def scan(fn,
dummy_args
+=
extra_inputs
dummy_args
+=
extra_inputs
dummy_outs
=
outputs
dummy_outs
=
outputs
if
condition
is
not
None
:
dummy_outs
.
append
(
condition
)
# Perform a try-except to provide a meaningful error message to the
# Perform a try-except to provide a meaningful error message to the
# user if inputs of the inner function are missing.
# user if inputs of the inner function are missing.
try
:
try
:
...
...
theano/scan_module/tests/test_scan.py
浏览文件 @
ce90645e
...
@@ -5718,3 +5718,23 @@ class TestGradUntil(unittest.TestCase):
...
@@ -5718,3 +5718,23 @@ class TestGradUntil(unittest.TestCase):
numpy_grad
=
np
.
array
([
0
,
0
,
0
,
5
,
6
,
10
,
4
,
5
,
0
,
0
,
0
,
0
,
0
,
0
,
0
])
numpy_grad
=
np
.
array
([
0
,
0
,
0
,
5
,
6
,
10
,
4
,
5
,
0
,
0
,
0
,
0
,
0
,
0
,
0
])
numpy_grad
=
numpy_grad
.
astype
(
theano
.
config
.
floatX
)
numpy_grad
=
numpy_grad
.
astype
(
theano
.
config
.
floatX
)
utt
.
assert_allclose
(
theano_gradient
,
numpy_grad
)
utt
.
assert_allclose
(
theano_gradient
,
numpy_grad
)
def
test_condition_hidden_inp
():
max_value
=
theano
.
tensor
.
scalar
(
"max_value"
)
n_steps
=
theano
.
tensor
.
iscalar
(
"n_steps"
)
def
accum
(
prev_value
,
step
):
new_value
=
prev_value
+
step
new_step
=
step
+
1
condition
=
theano
.
scan_module
.
until
(
new_value
>
max_value
)
return
[
new_value
,
new_step
],
condition
rs
,
updates
=
theano
.
scan
(
fn
=
accum
,
outputs_info
=
[
0
,
0
],
n_steps
=
n_steps
)
f
=
theano
.
function
(
inputs
=
[
max_value
,
n_steps
],
outputs
=
rs
)
_sum
,
total_steps
=
f
(
100
,
100
)
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论