Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
b4c10047
提交
b4c10047
authored
6月 10, 2011
作者:
Olivier Delalleau
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Safer setting of config warn options to be 100% sure they do not persist outside of tests
上级
df6a535e
隐藏空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
86 行增加
和
41 行删除
+86
-41
test_nnet.py
theano/tensor/nnet/tests/test_nnet.py
+37
-8
test_opt.py
theano/tensor/tests/test_opt.py
+49
-33
没有找到文件。
theano/tensor/nnet/tests/test_nnet.py
浏览文件 @
b4c10047
...
...
@@ -727,7 +727,13 @@ class T_CrossentropyCategorical1Hot(unittest.TestCase):
theano
.
printing
.
debugprint
(
f
)
raise
g
=
theano
.
function
([
x
,
b
,
y
],
T
.
grad
(
expr
,
x
),
mode
=
mode
)
backup
=
config
.
warn
.
sum_div_dimshuffle_bug
config
.
warn
.
sum_div_dimshuffle_bug
=
False
try
:
g
=
theano
.
function
([
x
,
b
,
y
],
T
.
grad
(
expr
,
x
),
mode
=
mode
)
finally
:
config
.
warn
.
sum_div_dimshuffle_bug
=
backup
print_graph
(
g
)
try
:
ops
=
[
node
.
op
for
node
in
g
.
maker
.
env
.
toposort
()]
...
...
@@ -879,9 +885,13 @@ def test_argmax_pushdown():
[
x
],
[
out
])
backup
=
config
.
warn
.
argmax_pushdown_bug
config
.
warn
.
argmax_pushdown_bug
=
False
theano
.
compile
.
mode
.
optdb
.
query
(
theano
.
compile
.
mode
.
OPT_FAST_RUN
)
.
optimize
(
env
)
try
:
theano
.
compile
.
mode
.
optdb
.
query
(
theano
.
compile
.
mode
.
OPT_FAST_RUN
)
.
optimize
(
env
)
finally
:
config
.
warn
.
argmax_pushdown_bug
=
backup
#print 'AFTER'
#for node in env.toposort():
...
...
@@ -923,9 +933,13 @@ def test_argmax_pushdown_bias():
[
x
,
b
],
[
out
])
backup
=
config
.
warn
.
argmax_pushdown_bug
config
.
warn
.
argmax_pushdown_bug
=
False
theano
.
compile
.
mode
.
optdb
.
query
(
theano
.
compile
.
mode
.
OPT_FAST_RUN
)
.
optimize
(
env
)
try
:
theano
.
compile
.
mode
.
optdb
.
query
(
theano
.
compile
.
mode
.
OPT_FAST_RUN
)
.
optimize
(
env
)
finally
:
config
.
warn
.
argmax_pushdown_bug
=
backup
#print 'AFTER'
#for node in env.toposort():
...
...
@@ -1020,7 +1034,12 @@ class Test_softmax_opt:
# test that function contains softmax and softmaxgrad
w
=
T
.
matrix
()
g
=
theano
.
function
([
c
,
w
],
T
.
grad
((
p_y
*
w
)
.
sum
(),
c
))
backup
=
config
.
warn
.
sum_div_dimshuffle_bug
config
.
warn
.
sum_div_dimshuffle_bug
=
False
try
:
g
=
theano
.
function
([
c
,
w
],
T
.
grad
((
p_y
*
w
)
.
sum
(),
c
))
finally
:
config
.
warn
.
sum_div_dimshuffle_bug
=
backup
g_ops
=
[
n
.
op
for
n
in
g
.
maker
.
env
.
toposort
()]
print
'--- g ='
printing
.
debugprint
(
g
)
...
...
@@ -1042,7 +1061,12 @@ class Test_softmax_opt:
printing
.
debugprint
(
f
)
# test that function contains softmax and no div.
g
=
theano
.
function
([
c
],
T
.
grad
(
p_y
.
sum
(),
c
))
backup
=
config
.
warn
.
sum_div_dimshuffle_bug
config
.
warn
.
sum_div_dimshuffle_bug
=
False
try
:
g
=
theano
.
function
([
c
],
T
.
grad
(
p_y
.
sum
(),
c
))
finally
:
config
.
warn
.
sum_div_dimshuffle_bug
=
backup
printing
.
debugprint
(
g
)
raise
SkipTest
(
'Optimization not enabled for the moment'
)
...
...
@@ -1056,7 +1080,12 @@ class Test_softmax_opt:
printing
.
debugprint
(
f
)
# test that function contains softmax and no div.
g
=
theano
.
function
([
c
],
T
.
grad
(
p_y
.
sum
(),
c
))
backup
=
config
.
warn
.
sum_div_dimshuffle_bug
config
.
warn
.
sum_div_dimshuffle_bug
=
False
try
:
g
=
theano
.
function
([
c
],
T
.
grad
(
p_y
.
sum
(),
c
))
finally
:
config
.
warn
.
sum_div_dimshuffle_bug
=
backup
printing
.
debugprint
(
g
)
raise
SkipTest
(
'Optimization not enabled for the moment'
)
...
...
theano/tensor/tests/test_opt.py
浏览文件 @
b4c10047
...
...
@@ -2511,33 +2511,41 @@ class T_local_sum(unittest.TestCase):
assert
numpy
.
allclose
(
f
(
input
),
input
.
sum
())
backup
=
config
.
warn
.
sum_sum_bug
config
.
warn
.
sum_sum_bug
=
False
f
=
theano
.
function
([
a
],
a
.
sum
(
0
)
.
sum
(
0
)
.
sum
(
0
),
mode
=
self
.
mode
)
assert
len
(
f
.
maker
.
env
.
nodes
)
==
1
assert
numpy
.
allclose
(
f
(
input
),
input
.
sum
())
try
:
f
=
theano
.
function
([
a
],
a
.
sum
(
0
)
.
sum
(
0
)
.
sum
(
0
),
mode
=
self
.
mode
)
assert
len
(
f
.
maker
.
env
.
nodes
)
==
1
assert
numpy
.
allclose
(
f
(
input
),
input
.
sum
())
finally
:
config
.
warn
.
sum_sum_bug
=
backup
def
test_local_sum_sum
(
self
):
a
=
T
.
tensor3
()
input
=
numpy
.
arange
(
3
*
3
*
3
,
dtype
=
config
.
floatX
)
.
reshape
(
3
,
3
,
3
)
dims
=
[(
0
,
0
),(
1
,
0
),(
2
,
0
),(
0
,
1
),(
1
,
1
),(
2
,
1
)]
backup
=
config
.
warn
.
sum_sum_bug
config
.
warn
.
sum_sum_bug
=
False
for
d
,
dd
in
dims
:
f
=
theano
.
function
([
a
],
a
.
sum
(
d
)
.
sum
(
dd
),
mode
=
self
.
mode
)
assert
numpy
.
allclose
(
f
(
input
),
input
.
sum
(
d
)
.
sum
(
dd
))
assert
len
(
f
.
maker
.
env
.
nodes
)
==
1
for
d
,
dd
in
dims
:
f
=
theano
.
function
([
a
],
a
.
sum
(
d
)
.
sum
(
dd
)
.
sum
(
0
),
mode
=
self
.
mode
)
assert
numpy
.
allclose
(
f
(
input
),
input
.
sum
(
d
)
.
sum
(
dd
)
.
sum
(
0
))
assert
len
(
f
.
maker
.
env
.
nodes
)
==
1
for
d
in
[
0
,
1
,
2
]:
f
=
theano
.
function
([
a
],
a
.
sum
(
d
)
.
sum
(
None
),
mode
=
self
.
mode
)
assert
numpy
.
allclose
(
f
(
input
),
input
.
sum
(
d
)
.
sum
())
assert
len
(
f
.
maker
.
env
.
nodes
)
==
1
for
d
in
[
0
,
1
,
2
]:
f
=
theano
.
function
([
a
],
a
.
sum
(
None
)
.
sum
(),
mode
=
self
.
mode
)
assert
numpy
.
allclose
(
f
(
input
),
input
.
sum
())
assert
len
(
f
.
maker
.
env
.
nodes
)
==
1
try
:
for
d
,
dd
in
dims
:
f
=
theano
.
function
([
a
],
a
.
sum
(
d
)
.
sum
(
dd
),
mode
=
self
.
mode
)
assert
numpy
.
allclose
(
f
(
input
),
input
.
sum
(
d
)
.
sum
(
dd
))
assert
len
(
f
.
maker
.
env
.
nodes
)
==
1
for
d
,
dd
in
dims
:
f
=
theano
.
function
([
a
],
a
.
sum
(
d
)
.
sum
(
dd
)
.
sum
(
0
),
mode
=
self
.
mode
)
assert
numpy
.
allclose
(
f
(
input
),
input
.
sum
(
d
)
.
sum
(
dd
)
.
sum
(
0
))
assert
len
(
f
.
maker
.
env
.
nodes
)
==
1
for
d
in
[
0
,
1
,
2
]:
f
=
theano
.
function
([
a
],
a
.
sum
(
d
)
.
sum
(
None
),
mode
=
self
.
mode
)
assert
numpy
.
allclose
(
f
(
input
),
input
.
sum
(
d
)
.
sum
())
assert
len
(
f
.
maker
.
env
.
nodes
)
==
1
for
d
in
[
0
,
1
,
2
]:
f
=
theano
.
function
([
a
],
a
.
sum
(
None
)
.
sum
(),
mode
=
self
.
mode
)
assert
numpy
.
allclose
(
f
(
input
),
input
.
sum
())
assert
len
(
f
.
maker
.
env
.
nodes
)
==
1
finally
:
config
.
warn
.
sum_sum_bug
=
backup
def
test_local_sum_alloc
(
self
):
a
=
T
.
dtensor3
()
...
...
@@ -2567,13 +2575,17 @@ class T_local_sum(unittest.TestCase):
assert
len
(
f
.
maker
.
env
.
nodes
)
==
nb_nodes
[
2
]
assert
f
.
maker
.
env
.
toposort
()[
-
1
]
.
op
==
T
.
alloc
backup
=
config
.
warn
.
sum_sum_bug
config
.
warn
.
sum_sum_bug
=
False
for
d
,
dd
in
[(
0
,
0
),(
1
,
0
),(
2
,
0
),(
0
,
1
),(
1
,
1
),(
2
,
1
)]:
f
=
theano
.
function
([
a
],
t_like
(
a
)
.
sum
(
d
)
.
sum
(
dd
),
mode
=
mode
)
print
f
.
maker
.
env
.
toposort
()
assert
numpy
.
allclose
(
f
(
input
),
n_like
(
input
)
.
sum
(
d
)
.
sum
(
dd
))
assert
len
(
f
.
maker
.
env
.
nodes
)
==
nb_nodes
[
3
]
assert
f
.
maker
.
env
.
toposort
()[
-
1
]
.
op
==
T
.
alloc
try
:
for
d
,
dd
in
[(
0
,
0
),(
1
,
0
),(
2
,
0
),(
0
,
1
),(
1
,
1
),(
2
,
1
)]:
f
=
theano
.
function
([
a
],
t_like
(
a
)
.
sum
(
d
)
.
sum
(
dd
),
mode
=
mode
)
print
f
.
maker
.
env
.
toposort
()
assert
numpy
.
allclose
(
f
(
input
),
n_like
(
input
)
.
sum
(
d
)
.
sum
(
dd
))
assert
len
(
f
.
maker
.
env
.
nodes
)
==
nb_nodes
[
3
]
assert
f
.
maker
.
env
.
toposort
()[
-
1
]
.
op
==
T
.
alloc
finally
:
config
.
warn
.
sum_sum_bug
=
backup
class
T_local_sum_dimshuffle
(
unittest
.
TestCase
):
def
setUp
(
self
):
...
...
@@ -2627,16 +2639,20 @@ class T_local_sum_dimshuffle(unittest.TestCase):
c_val
=
rng
.
randn
(
2
,
2
,
2
)
.
astype
(
config
.
floatX
)
d_val
=
numpy
.
asarray
(
rng
.
randn
(),
config
.
floatX
)
backup
=
config
.
warn
.
sum_sum_bug
,
config
.
warn
.
sum_div_dimshuffle_bug
config
.
warn
.
sum_sum_bug
=
False
config
.
warn
.
sum_div_dimshuffle_bug
=
False
for
i
,
s
in
enumerate
(
sums
):
print
i
f
=
theano
.
function
([
a
,
b
,
c
,
d
],
s
,
mode
=
self
.
mode
)
theano
.
printing
.
debugprint
(
f
)
g
=
f
.
maker
.
env
.
toposort
()
#print 'g =', g
assert
isinstance
(
g
[
-
1
]
.
op
.
scalar_op
,
theano
.
scalar
.
basic
.
TrueDiv
)
f
(
a_val
,
b_val
,
c_val
,
d_val
)
try
:
for
i
,
s
in
enumerate
(
sums
):
print
i
f
=
theano
.
function
([
a
,
b
,
c
,
d
],
s
,
mode
=
self
.
mode
)
theano
.
printing
.
debugprint
(
f
)
g
=
f
.
maker
.
env
.
toposort
()
#print 'g =', g
assert
isinstance
(
g
[
-
1
]
.
op
.
scalar_op
,
theano
.
scalar
.
basic
.
TrueDiv
)
f
(
a_val
,
b_val
,
c_val
,
d_val
)
finally
:
config
.
warn
.
sum_sum_bug
,
config
.
warn
.
sum_div_dimshuffle_bug
=
backup
# TODO:
# test_local_sum_prod_dimshuffle (a * b * c)
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论