Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
0dfefe84
提交
0dfefe84
authored
7月 20, 2011
作者:
Razvan Pascanu
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
logic to deal with the condition passed to scan
上级
fd88c988
显示空白字符变更
内嵌
并排
正在显示
1 个修改的文件
包含
24 行增加
和
3 行删除
+24
-3
scan.py
theano/scan_module/scan.py
+24
-3
没有找到文件。
theano/scan_module/scan.py
浏览文件 @
0dfefe84
...
@@ -716,7 +716,12 @@ def scan( fn
...
@@ -716,7 +716,12 @@ def scan( fn
# when we apply the lambda expression we get a mixture of update rules
# when we apply the lambda expression we get a mixture of update rules
# and outputs that needs to be separated
# and outputs that needs to be separated
outputs
,
updates
=
scan_utils
.
get_updates_and_outputs
(
fn
(
*
args
))
condition
,
outputs
,
updates
=
scan_utils
.
get_updates_and_outputs
(
fn
(
*
args
))
if
condition
is
not
None
:
as_while
=
True
else
:
as_while
=
False
##
##
### Step 3. Check if we actually need scan and remove it if we don't
### Step 3. Check if we actually need scan and remove it if we don't
##
##
...
@@ -725,6 +730,10 @@ def scan( fn
...
@@ -725,6 +730,10 @@ def scan( fn
if
n_fixed_steps
in
[
1
,
-
1
]:
if
n_fixed_steps
in
[
1
,
-
1
]:
# We do not need to use the scan op anymore, so we can just return
# We do not need to use the scan op anymore, so we can just return
# the outputs and updates we have
# the outputs and updates we have
if
condition
is
not
None
:
warning
(
(
'When the number of steps is fixed and equal to 1,'
' the provided stopping condition, '
,
str
(
condition
),
' is ignored'
))
for
pos
,
inner_out
in
enumerate
(
outputs
):
for
pos
,
inner_out
in
enumerate
(
outputs
):
# we need to see if we need to pad our sequences with an
# we need to see if we need to pad our sequences with an
...
@@ -770,8 +779,11 @@ def scan( fn
...
@@ -770,8 +779,11 @@ def scan( fn
## in args is quite important
## in args is quite important
dummy_args
+=
extra_inputs
dummy_args
+=
extra_inputs
dummy_outs
=
outputs
if
condition
is
not
None
:
dummy_outs
.
append
(
condition
)
dummy_f
=
function
(
dummy_args
dummy_f
=
function
(
dummy_args
,
outp
uts
,
dummy_o
uts
,
updates
=
updates
,
updates
=
updates
,
mode
=
compile
.
mode
.
Mode
(
linker
=
'py'
,
,
mode
=
compile
.
mode
.
Mode
(
linker
=
'py'
,
optimizer
=
None
)
)
optimizer
=
None
)
)
...
@@ -789,13 +801,18 @@ def scan( fn
...
@@ -789,13 +801,18 @@ def scan( fn
# assumed outputs until now (provided by the user) there can be
# assumed outputs until now (provided by the user) there can be
# only one explanation: No information is provided for any of the
# only one explanation: No information is provided for any of the
# outputs (i.e. we are dealing with a map)
# outputs (i.e. we are dealing with a map)
if
not
(
len
(
dummy_f
.
maker
.
outputs
)
==
n_outs
or
outs_info
==
[]):
tmp_dummy_f_outs
=
len
(
dummy_f
.
maker
.
outputs
)
if
as_while
:
tmp_dummy_f_outs
-=
1
if
not
(
tmp_dummy_f_outs
==
n_outs
or
outs_info
==
[]):
raise
ValueError
(
'Please provide None as output_info for '
raise
ValueError
(
'Please provide None as output_info for '
'any output that does not feed back into '
'any output that does not feed back into '
'scan (i.e. it behaves like a map) '
)
'scan (i.e. it behaves like a map) '
)
if
outs_info
==
[]:
if
outs_info
==
[]:
n_outs
=
len
(
dummy_f
.
maker
.
outputs
)
n_outs
=
len
(
dummy_f
.
maker
.
outputs
)
if
as_while
:
n_outs
=
n_outs
-
1
outs_info
=
[
dict
()
for
x
in
xrange
(
n_outs
)
]
outs_info
=
[
dict
()
for
x
in
xrange
(
n_outs
)
]
...
@@ -889,6 +906,8 @@ def scan( fn
...
@@ -889,6 +906,8 @@ def scan( fn
sit_sot_inner_outputs
+
sit_sot_inner_outputs
+
nit_sot_inner_outputs
+
nit_sot_inner_outputs
+
shared_inner_outputs
)
shared_inner_outputs
)
if
condition
is
not
None
:
inner_outs
.
append
(
condition
)
if
cuda
.
cuda_available
:
if
cuda
.
cuda_available
:
# very often we end up in this situation when we want to
# very often we end up in this situation when we want to
# replace w with w_copy, where w is CudaNdarray
# replace w with w_copy, where w is CudaNdarray
...
@@ -930,6 +949,8 @@ def scan( fn
...
@@ -930,6 +949,8 @@ def scan( fn
info
[
'mode'
]
=
mode
info
[
'mode'
]
=
mode
info
[
'inplace'
]
=
False
info
[
'inplace'
]
=
False
info
[
'gpu'
]
=
False
info
[
'gpu'
]
=
False
info
[
'as_while'
]
=
as_while
info
[
'profile'
]
=
profile
local_op
=
scan_op
.
Scan
(
inner_inputs
,
new_outs
,
info
)
local_op
=
scan_op
.
Scan
(
inner_inputs
,
new_outs
,
info
)
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论