Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
c398b58d
提交
c398b58d
authored
6月 18, 2015
作者:
Harm de Vries
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
test softmax_op and softmax_ghraph in test_argmax_pushdown
上级
24f6a4e5
隐藏空白字符变更
内嵌
并排
正在显示
1 个修改的文件
包含
40 行增加
和
40 行删除
+40
-40
test_nnet.py
theano/tensor/nnet/tests/test_nnet.py
+40
-40
没有找到文件。
theano/tensor/nnet/tests/test_nnet.py
浏览文件 @
c398b58d
...
@@ -1127,49 +1127,49 @@ class T_CrossentropyCategorical1Hot(utt.InferShapeTester):
...
@@ -1127,49 +1127,49 @@ class T_CrossentropyCategorical1Hot(utt.InferShapeTester):
def
test_argmax_pushdown
():
def
test_argmax_pushdown
():
x
=
tensor
.
matrix
()
x
=
tensor
.
matrix
()
for
softmax
in
[
softmax_graph
,
softmax_op
]:
# test that the max_and_argmax is pushed down if the max is not used
out
=
tensor
.
max_and_argmax
(
softmax
(
tensor
.
exp
(
tensor
.
tanh
(
sigmoid
(
x
)))),
axis
=-
1
)[
1
]
fgraph
=
gof
.
FunctionGraph
(
[
x
],
[
out
])
theano
.
compile
.
mode
.
optdb
.
query
(
theano
.
compile
.
mode
.
OPT_FAST_RUN
)
.
optimize
(
fgraph
)
# test that the max_and_argmax is pushed down if the max is not used
# print 'AFTER'
out
=
tensor
.
max_and_argmax
(
# for node in fgraph.toposort():
softmax_graph
(
tensor
.
exp
(
tensor
.
tanh
(
sigmoid
(
x
)))),
# print node.op
axis
=-
1
)[
1
]
assert
len
(
fgraph
.
toposort
())
==
2
# an output_guard is second
fgraph
=
gof
.
FunctionGraph
(
assert
fgraph
.
toposort
()[
0
]
.
op
==
tensor
.
basic
.
_max_and_argmax
[
x
],
assert
str
(
fgraph
.
toposort
()[
1
]
.
op
)
==
'OutputGuard'
[
out
])
x
=
tensor
.
matrix
()
theano
.
compile
.
mode
.
optdb
.
query
(
# test that the max_and_argmax is not pushed down if the max is used
theano
.
compile
.
mode
.
OPT_FAST_RUN
)
.
optimize
(
fgraph
)
out
=
tensor
.
max_and_argmax
(
softmax
(
tensor
.
exp
(
tensor
.
tanh
(
sigmoid
(
x
)))),
# print 'AFTER'
axis
=-
1
)[
0
]
# for node in fgraph.toposort():
fgraph
=
gof
.
FunctionGraph
(
# print node.op
[
x
],
assert
len
(
fgraph
.
toposort
())
==
2
# an output_guard is second
[
out
])
assert
fgraph
.
toposort
()[
0
]
.
op
==
tensor
.
basic
.
_max_and_argmax
assert
str
(
fgraph
.
toposort
()[
1
]
.
op
)
==
'OutputGuard'
x
=
tensor
.
matrix
()
# test that the max_and_argmax is not pushed down if the max is used
out
=
tensor
.
max_and_argmax
(
softmax_op
(
tensor
.
exp
(
tensor
.
tanh
(
sigmoid
(
x
)))),
axis
=-
1
)[
0
]
fgraph
=
gof
.
FunctionGraph
(
[
x
],
[
out
])
backup
=
config
.
warn
.
argmax_pushdown_bug
backup
=
config
.
warn
.
argmax_pushdown_bug
config
.
warn
.
argmax_pushdown_bug
=
False
config
.
warn
.
argmax_pushdown_bug
=
False
try
:
try
:
theano
.
compile
.
mode
.
optdb
.
query
(
theano
.
compile
.
mode
.
optdb
.
query
(
theano
.
compile
.
mode
.
OPT_FAST_RUN
)
.
optimize
(
fgraph
)
theano
.
compile
.
mode
.
OPT_FAST_RUN
)
.
optimize
(
fgraph
)
finally
:
finally
:
config
.
warn
.
argmax_pushdown_bug
=
backup
config
.
warn
.
argmax_pushdown_bug
=
backup
# print 'AFTER'
# print 'AFTER'
# for node in fgraph.toposort():
# for node in fgraph.toposort():
# print node.op
# print node.op
assert
len
(
fgraph
.
toposort
())
==
4
# an output_guard is second
assert
len
(
fgraph
.
toposort
())
==
4
# an output_guard is second
assert
isinstance
(
fgraph
.
toposort
()[
0
]
.
op
,
tensor
.
Elemwise
)
assert
isinstance
(
fgraph
.
toposort
()[
0
]
.
op
,
tensor
.
Elemwise
)
assert
isinstance
(
fgraph
.
toposort
()[
1
]
.
op
,
Softmax
)
assert
isinstance
(
fgraph
.
toposort
()[
1
]
.
op
,
Softmax
)
assert
isinstance
(
fgraph
.
toposort
()[
2
]
.
op
,
tensor
.
CAReduce
)
assert
isinstance
(
fgraph
.
toposort
()[
2
]
.
op
,
tensor
.
CAReduce
)
assert
isinstance
(
fgraph
.
toposort
()[
2
]
.
op
.
scalar_op
,
theano
.
scalar
.
Maximum
)
assert
isinstance
(
fgraph
.
toposort
()[
2
]
.
op
.
scalar_op
,
theano
.
scalar
.
Maximum
)
assert
str
(
fgraph
.
toposort
()[
3
]
.
op
)
==
'OutputGuard'
assert
str
(
fgraph
.
toposort
()[
3
]
.
op
)
==
'OutputGuard'
def
test_argmax_pushdown_bias
():
def
test_argmax_pushdown_bias
():
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论