Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
611f4c35
提交
611f4c35
authored
12月 05, 2014
作者:
Pierre Luc Carrier
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Ensure scan optimizations are included in the compile mode when relevant
上级
60001cf2
显示空白字符变更
内嵌
并排
正在显示
1 个修改的文件
包含
24 行增加
和
21 行删除
+24
-21
test_scan_opt.py
theano/scan_module/tests/test_scan_opt.py
+24
-21
没有找到文件。
theano/scan_module/tests/test_scan_opt.py
浏览文件 @
611f4c35
...
@@ -157,12 +157,11 @@ class TestPushOutScanOutputDot(object):
...
@@ -157,12 +157,11 @@ class TestPushOutScanOutputDot(object):
# Compile the function twice, once with the optimization and once
# Compile the function twice, once with the optimization and once
# without
# without
f_opt
=
theano
.
function
([
v
,
m
],
T
.
jacobian
(
output
,
v
))
opt_mode
=
mode
.
including
(
"scan"
)
f_opt
=
theano
.
function
([
v
,
m
],
T
.
jacobian
(
output
,
v
),
mode
=
opt_mode
)
default_mode
=
theano
.
compile
.
get_default_mode
()
no_opt_mode
=
mode
.
excluding
(
"scanOp_pushout_output"
)
new_mode
=
default_mode
.
excluding
(
"scanOp_pushout_output"
)
f_no_opt
=
theano
.
function
([
v
,
m
],
T
.
jacobian
(
output
,
v
),
mode
=
no_opt_mode
)
f_no_opt
=
theano
.
function
([
v
,
m
],
T
.
jacobian
(
output
,
v
),
mode
=
new_mode
)
# Ensure that the optimization was performed correctly in f_opt
# Ensure that the optimization was performed correctly in f_opt
# The inner function of scan should have only one output and it should
# The inner function of scan should have only one output and it should
...
@@ -248,11 +247,11 @@ class TestPushOutScanOutputDot(object):
...
@@ -248,11 +247,11 @@ class TestPushOutScanOutputDot(object):
# Compile the function twice, once with the optimization and once
# Compile the function twice, once with the optimization and once
# without
# without
f_opt
=
theano
.
function
([
a
,
b
],
outputs
)
opt_mode
=
mode
.
including
(
"scan"
)
f_opt
=
theano
.
function
([
a
,
b
],
outputs
,
mode
=
opt_mode
)
default_mode
=
theano
.
compile
.
get_default_mode
()
no_opt_mode
=
mode
.
excluding
(
"scanOp_pushout_output"
)
new_mode
=
default_mode
.
excluding
(
"scanOp_pushout_output"
)
f_no_opt
=
theano
.
function
([
a
,
b
],
outputs
,
mode
=
no_opt_mode
)
f_no_opt
=
theano
.
function
([
a
,
b
],
outputs
,
mode
=
new_mode
)
# Ensure that the optimization was performed correctly in f_opt
# Ensure that the optimization was performed correctly in f_opt
# The inner function of scan should have only one output and it should
# The inner function of scan should have only one output and it should
...
@@ -332,19 +331,21 @@ class TestPushOutSumOfDot():
...
@@ -332,19 +331,21 @@ class TestPushOutSumOfDot():
# Compile the function twice, once with the optimization and once
# Compile the function twice, once with the optimization and once
# without
# without
opt_mode
=
mode
.
including
(
"scan"
)
h
,
_
=
theano
.
scan
(
rnn_step1
,
sequences
=
[
x
,
ri
,
zi
],
n_steps
=
seq_len
,
h
,
_
=
theano
.
scan
(
rnn_step1
,
sequences
=
[
x
,
ri
,
zi
],
n_steps
=
seq_len
,
outputs_info
=
init
,
name
=
'fpass1'
)
outputs_info
=
init
,
name
=
'fpass1'
,
mode
=
opt_mode
)
cost
=
h
[
-
1
]
.
sum
()
cost
=
h
[
-
1
]
.
sum
()
grad1
=
T
.
grad
(
cost
,
[
U
,
V
,
W
])
grad1
=
T
.
grad
(
cost
,
[
U
,
V
,
W
])
f_opt
=
theano
.
function
(
inputs
=
[
x
,
ri
,
zi
],
outputs
=
grad1
)
f_opt
=
theano
.
function
(
inputs
=
[
x
,
ri
,
zi
],
outputs
=
grad1
,
mode
=
opt_mode
)
default_mode
=
theano
.
compile
.
get_default_mode
()
no_opt_mode
=
mode
.
excluding
(
"scanOp_pushout_output"
)
new_mode
=
default_mode
.
excluding
(
"scanOp_pushout_output"
)
h
,
_
=
theano
.
scan
(
rnn_step1
,
sequences
=
[
x
,
ri
,
zi
],
n_steps
=
seq_len
,
h
,
_
=
theano
.
scan
(
rnn_step1
,
sequences
=
[
x
,
ri
,
zi
],
n_steps
=
seq_len
,
outputs_info
=
init
,
name
=
'fpass1'
,
mode
=
n
ew
_mode
)
outputs_info
=
init
,
name
=
'fpass1'
,
mode
=
n
o_opt
_mode
)
cost
=
h
[
-
1
]
.
sum
()
cost
=
h
[
-
1
]
.
sum
()
grad1
=
T
.
grad
(
cost
,
[
U
,
V
,
W
])
grad1
=
T
.
grad
(
cost
,
[
U
,
V
,
W
])
f_no_opt
=
theano
.
function
(
inputs
=
[
x
,
ri
,
zi
],
outputs
=
grad1
,
mode
=
new_mode
)
f_no_opt
=
theano
.
function
(
inputs
=
[
x
,
ri
,
zi
],
outputs
=
grad1
,
mode
=
no_opt_mode
)
# Validate that the optimization has been applied
# Validate that the optimization has been applied
scan_node_grad
=
[
node
for
node
in
f_opt
.
maker
.
fgraph
.
toposort
()
scan_node_grad
=
[
node
for
node
in
f_opt
.
maker
.
fgraph
.
toposort
()
...
@@ -383,21 +384,23 @@ class TestPushOutSumOfDot():
...
@@ -383,21 +384,23 @@ class TestPushOutSumOfDot():
# Compile the function twice, once with the optimization and once
# Compile the function twice, once with the optimization and once
# without
# without
opt_mode
=
mode
.
including
(
"scan"
)
h
,
_
=
theano
.
scan
(
inner_fct
,
h
,
_
=
theano
.
scan
(
inner_fct
,
sequences
=
[
input1
,
input2
,
input3
],
sequences
=
[
input1
,
input2
,
input3
],
outputs_info
=
init
)
outputs_info
=
init
,
mode
=
opt_mode
)
output
=
h
[
-
1
]
output
=
h
[
-
1
]
f_opt
=
theano
.
function
([
input1
,
input2
,
input3
],
output
)
f_opt
=
theano
.
function
([
input1
,
input2
,
input3
],
output
,
mode
=
opt_mode
)
default_mode
=
theano
.
compile
.
get_default_mode
()
no_opt_mode
=
mode
.
excluding
(
"scanOp_pushout_output"
)
new_mode
=
default_mode
.
excluding
(
"scanOp_pushout_output"
)
h
,
_
=
theano
.
scan
(
inner_fct
,
h
,
_
=
theano
.
scan
(
inner_fct
,
sequences
=
[
input1
,
input2
,
input3
],
sequences
=
[
input1
,
input2
,
input3
],
outputs_info
=
init
,
outputs_info
=
init
,
mode
=
n
ew
_mode
)
mode
=
n
o_opt
_mode
)
output
=
h
[
-
1
]
output
=
h
[
-
1
]
f_no_opt
=
theano
.
function
([
input1
,
input2
,
input3
],
output
,
f_no_opt
=
theano
.
function
([
input1
,
input2
,
input3
],
output
,
mode
=
n
ew
_mode
)
mode
=
n
o_opt
_mode
)
# Ensure that the optimization has been applied for f_opt
# Ensure that the optimization has been applied for f_opt
# TODO
# TODO
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论