Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
999aeb92
提交
999aeb92
authored
9月 10, 2013
作者:
Frédéric Bastien
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #1506 from lamblin/merge_scan
Fix bug in scan merge optimization reported by Yao Li.
上级
44f9d0f7
d0a9a4cd
显示空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
36 行增加
和
1 行删除
+36
-1
scan_opt.py
theano/scan_module/scan_opt.py
+6
-1
test_scan.py
theano/scan_module/tests/test_scan.py
+30
-0
没有找到文件。
theano/scan_module/scan_opt.py
浏览文件 @
999aeb92
...
@@ -1233,8 +1233,13 @@ class ScanMerge(gof.Optimizer):
...
@@ -1233,8 +1233,13 @@ class ScanMerge(gof.Optimizer):
belongs_to_set_idx
=
-
1
belongs_to_set_idx
=
-
1
for
pos
,
subset
in
enumerate
(
all_sets
):
for
pos
,
subset
in
enumerate
(
all_sets
):
if
self
.
belongs_to_set
(
nd
,
subset
):
if
self
.
belongs_to_set
(
nd
,
subset
):
assert
belongs_to_set_idx
==
-
1
belongs_to_set_idx
=
pos
belongs_to_set_idx
=
pos
# It is possible that nd belongs to more than one subset.
# For instance, if we have 3 Scan nodes X, Y and Z, if Z
# depends on the output of X, then X and Z are incompatible
# and would create different subsets, but Y could be
# compatible with both X and Z. We choose the first one.
break
if
belongs_to_set_idx
==
-
1
:
if
belongs_to_set_idx
==
-
1
:
all_sets
.
append
([
nd
])
all_sets
.
append
([
nd
])
...
...
theano/scan_module/tests/test_scan.py
浏览文件 @
999aeb92
...
@@ -2447,6 +2447,36 @@ class T_Scan(unittest.TestCase):
...
@@ -2447,6 +2447,36 @@ class T_Scan(unittest.TestCase):
n
.
op
,
theano
.
scan_module
.
scan_op
.
Scan
)]
n
.
op
,
theano
.
scan_module
.
scan_op
.
Scan
)]
self
.
assertTrue
(
len
(
scans
)
==
2
)
self
.
assertTrue
(
len
(
scans
)
==
2
)
def
test_merge_3scans
(
self
):
# This test checks a case where we have 3 scans, two of them
# cannot be merged together, but the third one can be merged with
# either.
x
=
theano
.
tensor
.
vector
()
y
=
theano
.
tensor
.
vector
()
def
sum
(
s
):
return
s
+
1
sx
,
upx
=
theano
.
scan
(
sum
,
sequences
=
[
x
],
n_steps
=
4
,
name
=
'X'
)
# We need to use an expression of y rather than y so the toposort
# comes up with the 'Y' scan last.
sy
,
upy
=
theano
.
scan
(
sum
,
sequences
=
[
2
*
y
+
2
],
n_steps
=
4
,
name
=
'Y'
)
sz
,
upz
=
theano
.
scan
(
sum
,
sequences
=
[
sx
],
n_steps
=
4
,
name
=
'Z'
)
f
=
theano
.
function
(
[
x
,
y
],
[
sy
,
sz
],
mode
=
mode_with_opt
.
excluding
(
'scanOp_pushout_seqs_ops'
))
topo
=
f
.
maker
.
fgraph
.
toposort
()
scans
=
[
n
for
n
in
topo
if
isinstance
(
n
.
op
,
theano
.
scan_module
.
scan_op
.
Scan
)]
self
.
assertTrue
(
len
(
scans
)
==
2
)
rng
=
numpy
.
random
.
RandomState
(
utt
.
fetch_seed
())
x_val
=
rng
.
uniform
(
size
=
(
4
,))
.
astype
(
theano
.
config
.
floatX
)
y_val
=
rng
.
uniform
(
size
=
(
4
,))
.
astype
(
theano
.
config
.
floatX
)
# Run it so DebugMode can detect optimization problems.
f
(
x_val
,
y_val
)
def
test_hash
(
self
):
def
test_hash
(
self
):
x
=
theano
.
tensor
.
vector
()
x
=
theano
.
tensor
.
vector
()
y
=
theano
.
tensor
.
vector
()
y
=
theano
.
tensor
.
vector
()
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论