Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
97082358
提交
97082358
authored
6月 12, 2017
作者:
Reyhane Askari
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
added check for cycle_detection flag in test
上级
1cef6dac
隐藏空白字符变更
内嵌
并排
正在显示
1 个修改的文件
包含
53 行增加
和
16 行删除
+53
-16
test_nnet.py
theano/tensor/nnet/tests/test_nnet.py
+53
-16
没有找到文件。
theano/tensor/nnet/tests/test_nnet.py
浏览文件 @
97082358
...
@@ -580,8 +580,13 @@ class T_CrossentropyCategorical1Hot(utt.InferShapeTester):
...
@@ -580,8 +580,13 @@ class T_CrossentropyCategorical1Hot(utt.InferShapeTester):
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
)
assert
(
fgraph
.
outputs
[
0
]
.
owner
.
op
==
if
theano
.
config
.
cycle_detection
==
'fast'
:
crossentropy_softmax_argmax_1hot_with_bias
)
assert
(
fgraph
.
outputs
[
0
]
.
owner
.
op
==
crossentropy_softmax_argmax_1hot_with_bias
)
else
:
assert
str
(
fgraph
.
outputs
[
0
]
.
owner
.
op
)
==
'OutputGuard'
assert
(
fgraph
.
outputs
[
0
]
.
owner
.
inputs
[
0
]
.
owner
.
op
==
crossentropy_softmax_argmax_1hot_with_bias
)
def
test_softmax_optimizations_vector
(
self
):
def
test_softmax_optimizations_vector
(
self
):
x
=
tensor
.
vector
(
'x'
)
x
=
tensor
.
vector
(
'x'
)
...
@@ -594,8 +599,13 @@ class T_CrossentropyCategorical1Hot(utt.InferShapeTester):
...
@@ -594,8 +599,13 @@ class T_CrossentropyCategorical1Hot(utt.InferShapeTester):
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
)
assert
(
fgraph
.
outputs
[
0
]
.
owner
.
op
==
if
theano
.
config
.
cycle_detection
==
'fast'
:
crossentropy_softmax_argmax_1hot_with_bias
)
assert
(
fgraph
.
outputs
[
0
]
.
owner
.
op
==
crossentropy_softmax_argmax_1hot_with_bias
)
else
:
assert
str
(
fgraph
.
outputs
[
0
]
.
owner
.
op
)
==
'OutputGuard'
assert
(
fgraph
.
outputs
[
0
]
.
owner
.
inputs
[
0
]
.
owner
.
op
==
crossentropy_softmax_argmax_1hot_with_bias
)
def
test_softmax_optimizations_w_bias
(
self
):
def
test_softmax_optimizations_w_bias
(
self
):
x
=
tensor
.
matrix
(
'x'
)
x
=
tensor
.
matrix
(
'x'
)
...
@@ -623,9 +633,15 @@ class T_CrossentropyCategorical1Hot(utt.InferShapeTester):
...
@@ -623,9 +633,15 @@ class T_CrossentropyCategorical1Hot(utt.InferShapeTester):
# print node.op
# print node.op
# print printing.pprint(node.outputs[0])
# print printing.pprint(node.outputs[0])
# print '===='
# print '===='
assert
len
(
fgraph
.
toposort
())
==
1
if
theano
.
config
.
cycle_detection
==
'fast'
:
assert
(
fgraph
.
outputs
[
0
]
.
owner
.
op
==
assert
len
(
fgraph
.
toposort
())
==
1
crossentropy_softmax_argmax_1hot_with_bias
)
assert
(
fgraph
.
outputs
[
0
]
.
owner
.
op
==
crossentropy_softmax_argmax_1hot_with_bias
)
else
:
assert
len
(
fgraph
.
toposort
())
==
2
assert
str
(
fgraph
.
outputs
[
0
]
.
owner
.
op
)
==
'OutputGuard'
assert
(
fgraph
.
outputs
[
0
]
.
owner
.
inputs
[
0
]
.
owner
.
op
==
crossentropy_softmax_argmax_1hot_with_bias
)
def
test_softmax_optimizations_w_bias2
(
self
):
def
test_softmax_optimizations_w_bias2
(
self
):
x
=
tensor
.
matrix
(
'x'
)
x
=
tensor
.
matrix
(
'x'
)
...
@@ -651,10 +667,15 @@ class T_CrossentropyCategorical1Hot(utt.InferShapeTester):
...
@@ -651,10 +667,15 @@ class T_CrossentropyCategorical1Hot(utt.InferShapeTester):
# for node in fgraph.toposort():
# for node in fgraph.toposort():
# print node.op
# print node.op
# print '===='
# print '===='
assert
len
(
fgraph
.
toposort
())
==
2
if
theano
.
config
.
cycle_detection
==
'fast'
:
assert
len
(
fgraph
.
toposort
())
==
2
assert
(
fgraph
.
outputs
[
0
]
.
owner
.
op
==
assert
(
fgraph
.
outputs
[
0
]
.
owner
.
op
==
crossentropy_softmax_argmax_1hot_with_bias
)
crossentropy_softmax_argmax_1hot_with_bias
)
else
:
assert
len
(
fgraph
.
toposort
())
==
3
assert
str
(
fgraph
.
outputs
[
0
]
.
owner
.
op
)
==
'OutputGuard'
assert
(
fgraph
.
outputs
[
0
]
.
owner
.
inputs
[
0
]
.
owner
.
op
==
crossentropy_softmax_argmax_1hot_with_bias
)
def
test_softmax_optimizations_w_bias_vector
(
self
):
def
test_softmax_optimizations_w_bias_vector
(
self
):
x
=
tensor
.
vector
(
'x'
)
x
=
tensor
.
vector
(
'x'
)
...
@@ -677,9 +698,15 @@ class T_CrossentropyCategorical1Hot(utt.InferShapeTester):
...
@@ -677,9 +698,15 @@ class T_CrossentropyCategorical1Hot(utt.InferShapeTester):
# for node in fgraph.toposort():
# for node in fgraph.toposort():
# print node.op
# print node.op
# print '===='
# print '===='
assert
len
(
fgraph
.
toposort
())
==
2
if
theano
.
config
.
cycle_detection
==
'fast'
:
assert
(
fgraph
.
outputs
[
0
]
.
owner
.
op
==
assert
len
(
fgraph
.
toposort
())
==
2
crossentropy_softmax_argmax_1hot_with_bias
)
assert
(
fgraph
.
outputs
[
0
]
.
owner
.
op
==
crossentropy_softmax_argmax_1hot_with_bias
)
else
:
assert
len
(
fgraph
.
toposort
())
==
3
assert
str
(
fgraph
.
outputs
[
0
]
.
owner
.
op
)
==
'OutputGuard'
assert
(
fgraph
.
outputs
[
0
]
.
owner
.
inputs
[
0
]
.
owner
.
op
==
crossentropy_softmax_argmax_1hot_with_bias
)
def
test_softmax_grad_optimizations
(
self
):
def
test_softmax_grad_optimizations
(
self
):
x
=
tensor
.
matrix
(
'x'
)
x
=
tensor
.
matrix
(
'x'
)
...
@@ -1381,7 +1408,13 @@ def test_argmax_pushdown_bias():
...
@@ -1381,7 +1408,13 @@ def test_argmax_pushdown_bias():
# for node in fgraph.toposort():
# for node in fgraph.toposort():
# print node.op
# print node.op
types_to_check
=
(
tensor
.
DimShuffle
,
tensor
.
Elemwise
,
tensor
.
Argmax
)
types_to_check
=
(
tensor
.
DimShuffle
,
tensor
.
Elemwise
,
tensor
.
Argmax
)
assert
len
(
fgraph
.
toposort
())
==
3
if
theano
.
config
.
cycle_detection
==
'fast'
:
assert
len
(
fgraph
.
toposort
())
==
3
else
:
assert
len
(
fgraph
.
toposort
())
==
4
assert
str
(
fgraph
.
toposort
()[
3
]
.
op
)
==
'OutputGuard'
for
i
,
type
in
enumerate
(
types_to_check
):
for
i
,
type
in
enumerate
(
types_to_check
):
assert
isinstance
(
fgraph
.
toposort
()[
i
]
.
op
,
type
)
assert
isinstance
(
fgraph
.
toposort
()[
i
]
.
op
,
type
)
assert
check_stack_trace
(
fgraph
,
ops_to_check
=
types_to_check
)
assert
check_stack_trace
(
fgraph
,
ops_to_check
=
types_to_check
)
...
@@ -1404,7 +1437,11 @@ def test_argmax_pushdown_bias():
...
@@ -1404,7 +1437,11 @@ def test_argmax_pushdown_bias():
# print 'AFTER'
# print 'AFTER'
# for node in fgraph.toposort():
# for node in fgraph.toposort():
# print node.op
# print node.op
assert
len
(
fgraph
.
toposort
())
==
2
if
theano
.
config
.
cycle_detection
==
'fast'
:
assert
len
(
fgraph
.
toposort
())
==
2
else
:
assert
len
(
fgraph
.
toposort
())
==
3
assert
str
(
fgraph
.
toposort
()[
2
]
.
op
)
==
'OutputGuard'
assert
isinstance
(
fgraph
.
toposort
()[
0
]
.
op
,
SoftmaxWithBias
)
assert
isinstance
(
fgraph
.
toposort
()[
0
]
.
op
,
SoftmaxWithBias
)
assert
isinstance
(
fgraph
.
toposort
()[
1
]
.
op
,
tensor
.
CAReduce
)
assert
isinstance
(
fgraph
.
toposort
()[
1
]
.
op
,
tensor
.
CAReduce
)
assert
isinstance
(
fgraph
.
toposort
()[
1
]
.
op
.
scalar_op
,
theano
.
scalar
.
Maximum
)
assert
isinstance
(
fgraph
.
toposort
()[
1
]
.
op
.
scalar_op
,
theano
.
scalar
.
Maximum
)
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论