Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
a1bad4b4
提交
a1bad4b4
authored
6月 16, 2014
作者:
Frederic
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
remove print in tests.
上级
75f0652f
隐藏空白字符变更
内嵌
并排
正在显示
1 个修改的文件
包含
5 行增加
和
68 行删除
+5
-68
test_opt.py
theano/tensor/tests/test_opt.py
+5
-68
没有找到文件。
theano/tensor/tests/test_opt.py
浏览文件 @
a1bad4b4
...
@@ -502,9 +502,6 @@ class test_canonize(unittest.TestCase):
...
@@ -502,9 +502,6 @@ class test_canonize(unittest.TestCase):
assert
(
out_dtype
==
out
.
dtype
)
assert
(
out_dtype
==
out
.
dtype
)
assert
numpy
.
allclose
(
out
,
val_inputs
[
1
])
assert
numpy
.
allclose
(
out
,
val_inputs
[
1
])
topo
=
f
.
maker
.
fgraph
.
toposort
()
topo
=
f
.
maker
.
fgraph
.
toposort
()
print
"ID TOPO"
,
id
,
topo
,
sym_inputs
for
r
,
t
in
f
.
maker
.
fgraph
.
shape_feature
.
shape_of
.
items
():
print
' '
,
r
,
t
if
topo
and
not
(
len
(
topo
)
==
1
and
topo
[
0
]
.
op
==
deep_copy_op
):
if
topo
and
not
(
len
(
topo
)
==
1
and
topo
[
0
]
.
op
==
deep_copy_op
):
for
node
in
topo
[:
-
1
]:
for
node
in
topo
[:
-
1
]:
assert
isinstance
(
node
.
op
,
Shape_i
)
assert
isinstance
(
node
.
op
,
Shape_i
)
...
@@ -528,7 +525,6 @@ class test_canonize(unittest.TestCase):
...
@@ -528,7 +525,6 @@ class test_canonize(unittest.TestCase):
out
=
f
(
*
val_inputs
)
out
=
f
(
*
val_inputs
)
assert
numpy
.
allclose
(
out
,
(
1
/
val_inputs
[
1
]))
assert
numpy
.
allclose
(
out
,
(
1
/
val_inputs
[
1
]))
topo
=
f
.
maker
.
fgraph
.
toposort
()
topo
=
f
.
maker
.
fgraph
.
toposort
()
print
topo
elem
=
[
t
for
t
in
topo
if
isinstance
(
t
.
op
,
T
.
Elemwise
)]
elem
=
[
t
for
t
in
topo
if
isinstance
(
t
.
op
,
T
.
Elemwise
)]
assert
len
(
elem
)
==
nb_elemwise
assert
len
(
elem
)
==
nb_elemwise
assert
isinstance
(
elem
[
0
]
.
op
,
(
T
.
Elemwise
,
))
assert
isinstance
(
elem
[
0
]
.
op
,
(
T
.
Elemwise
,
))
...
@@ -727,7 +723,6 @@ class test_canonize(unittest.TestCase):
...
@@ -727,7 +723,6 @@ class test_canonize(unittest.TestCase):
assert
numpy
.
allclose
(
out
,
val_inputs
[
0
]
/
assert
numpy
.
allclose
(
out
,
val_inputs
[
0
]
/
val_inputs
[
1
]
/
val_inputs
[
2
])
val_inputs
[
1
]
/
val_inputs
[
2
])
topo
=
f
.
maker
.
fgraph
.
toposort
()
topo
=
f
.
maker
.
fgraph
.
toposort
()
print
topo
assert
len
(
topo
)
==
2
assert
len
(
topo
)
==
2
assert
isinstance
(
topo
[
0
]
.
op
,
(
T
.
Elemwise
,
))
assert
isinstance
(
topo
[
0
]
.
op
,
(
T
.
Elemwise
,
))
assert
isinstance
(
topo
[
0
]
.
op
.
scalar_op
,
assert
isinstance
(
topo
[
0
]
.
op
.
scalar_op
,
...
@@ -746,7 +741,6 @@ class test_canonize(unittest.TestCase):
...
@@ -746,7 +741,6 @@ class test_canonize(unittest.TestCase):
assert
numpy
.
allclose
(
out
,
val_inputs
[
0
]
/
(
assert
numpy
.
allclose
(
out
,
val_inputs
[
0
]
/
(
val_inputs
[
1
]
/
val_inputs
[
2
]))
val_inputs
[
1
]
/
val_inputs
[
2
]))
topo
=
f
.
maker
.
fgraph
.
toposort
()
topo
=
f
.
maker
.
fgraph
.
toposort
()
print
topo
assert
len
(
topo
)
==
2
assert
len
(
topo
)
==
2
assert
isinstance
(
topo
[
0
]
.
op
,
(
T
.
Elemwise
,
))
assert
isinstance
(
topo
[
0
]
.
op
,
(
T
.
Elemwise
,
))
assert
isinstance
(
topo
[
0
]
.
op
.
scalar_op
,
assert
isinstance
(
topo
[
0
]
.
op
.
scalar_op
,
...
@@ -798,13 +792,11 @@ def test_local_merge_abs():
...
@@ -798,13 +792,11 @@ def test_local_merge_abs():
f
=
theano
.
function
([
y
,
z
],
(
abs
(
y
*
z
*
-
2
)),
mode
=
mode
)
f
=
theano
.
function
([
y
,
z
],
(
abs
(
y
*
z
*
-
2
)),
mode
=
mode
)
f
(
y_val
,
z_val
)
f
(
y_val
,
z_val
)
theano
.
printing
.
debugprint
(
f
)
assert
isinstance
(
f
.
maker
.
fgraph
.
toposort
()[
1
]
.
op
.
scalar_op
,
scal
.
Abs
)
assert
isinstance
(
f
.
maker
.
fgraph
.
toposort
()[
1
]
.
op
.
scalar_op
,
scal
.
Abs
)
assert
len
(
f
.
maker
.
fgraph
.
toposort
())
==
2
assert
len
(
f
.
maker
.
fgraph
.
toposort
())
==
2
f
=
theano
.
function
([
x
,
y
],
abs
(
x
/
y
),
mode
=
mode
)
f
=
theano
.
function
([
x
,
y
],
abs
(
x
/
y
),
mode
=
mode
)
f
(
x_val
,
y_val
)
f
(
x_val
,
y_val
)
theano
.
printing
.
debugprint
(
f
)
assert
isinstance
(
f
.
maker
.
fgraph
.
toposort
()[
1
]
.
op
.
scalar_op
,
scal
.
Abs
)
assert
isinstance
(
f
.
maker
.
fgraph
.
toposort
()[
1
]
.
op
.
scalar_op
,
scal
.
Abs
)
assert
len
(
f
.
maker
.
fgraph
.
toposort
())
==
2
assert
len
(
f
.
maker
.
fgraph
.
toposort
())
==
2
...
@@ -1511,17 +1503,13 @@ def test_log1p():
...
@@ -1511,17 +1503,13 @@ def test_log1p():
# check trickier cases (and use different dtype)
# check trickier cases (and use different dtype)
y
=
fmatrix
()
y
=
fmatrix
()
f
=
function
([
x
,
y
],
T
.
log
(
tensor
.
fill
(
y
,
1
)
+
(
x
)),
mode
=
m
)
f
=
function
([
x
,
y
],
T
.
log
(
tensor
.
fill
(
y
,
1
)
+
(
x
)),
mode
=
m
)
print
f
.
maker
.
fgraph
.
toposort
()
# the first three ops are Shape_i, Shape_i, and Dimshuffle
# the first three ops are Shape_i, Shape_i, and Dimshuffle
theano
.
printing
.
debugprint
(
f
)
assert
[
node
.
op
for
node
in
f
.
maker
.
fgraph
.
toposort
()][
3
:]
==
[
assert
[
node
.
op
for
node
in
f
.
maker
.
fgraph
.
toposort
()][
3
:]
==
[
T
.
log1p
,
tensor
.
alloc
]
T
.
log1p
,
tensor
.
alloc
]
f
=
function
([
x
,
y
],
T
.
log
(
0
+
(
x
)
+
tensor
.
fill
(
y
,
1.0
)),
mode
=
m
)
f
=
function
([
x
,
y
],
T
.
log
(
0
+
(
x
)
+
tensor
.
fill
(
y
,
1.0
)),
mode
=
m
)
theano
.
printing
.
debugprint
(
f
)
assert
[
node
.
op
for
node
in
f
.
maker
.
fgraph
.
toposort
()][
3
:]
==
[
assert
[
node
.
op
for
node
in
f
.
maker
.
fgraph
.
toposort
()][
3
:]
==
[
T
.
log1p
,
tensor
.
alloc
]
T
.
log1p
,
tensor
.
alloc
]
f
=
function
([
x
,
y
],
T
.
log
(
2
+
(
x
)
-
tensor
.
fill
(
y
,
1.0
)),
mode
=
m
)
f
=
function
([
x
,
y
],
T
.
log
(
2
+
(
x
)
-
tensor
.
fill
(
y
,
1.0
)),
mode
=
m
)
theano
.
printing
.
debugprint
(
f
)
assert
[
node
.
op
for
node
in
f
.
maker
.
fgraph
.
toposort
()][
3
:]
\
assert
[
node
.
op
for
node
in
f
.
maker
.
fgraph
.
toposort
()][
3
:]
\
==
[
T
.
log1p
,
tensor
.
alloc
]
==
[
T
.
log1p
,
tensor
.
alloc
]
...
@@ -1533,14 +1521,12 @@ def test_log1p():
...
@@ -1533,14 +1521,12 @@ def test_log1p():
# I was never sure if this optimization should work on complex numbers or not.
# I was never sure if this optimization should work on complex numbers or not.
z
=
tensor
.
zmatrix
()
z
=
tensor
.
zmatrix
()
f
=
function
([
z
],
T
.
log
(
1
+
(
z
)),
mode
=
m
)
f
=
function
([
z
],
T
.
log
(
1
+
(
z
)),
mode
=
m
)
theano
.
printing
.
debugprint
(
f
)
assert
[
node
.
op
for
node
in
f
.
maker
.
fgraph
.
toposort
()]
==
[
T
.
log1p
]
assert
[
node
.
op
for
node
in
f
.
maker
.
fgraph
.
toposort
()]
==
[
T
.
log1p
]
if
1
:
if
1
:
# should work for int
# should work for int
z
=
tensor
.
imatrix
()
z
=
tensor
.
imatrix
()
f
=
function
([
z
],
T
.
log
(
1
+
(
z
)),
mode
=
m
)
f
=
function
([
z
],
T
.
log
(
1
+
(
z
)),
mode
=
m
)
theano
.
printing
.
debugprint
(
f
)
assert
[
node
.
op
for
node
in
f
.
maker
.
fgraph
.
toposort
()]
==
[
T
.
log1p
]
assert
[
node
.
op
for
node
in
f
.
maker
.
fgraph
.
toposort
()]
==
[
T
.
log1p
]
...
@@ -1559,14 +1545,12 @@ def test_log_add():
...
@@ -1559,14 +1545,12 @@ def test_log_add():
y
=
dvector
()
y
=
dvector
()
f
=
function
([
x
,
y
],
T
.
log
(
T
.
exp
(
x
)
+
T
.
exp
(
y
)),
mode
=
m
)
f
=
function
([
x
,
y
],
T
.
log
(
T
.
exp
(
x
)
+
T
.
exp
(
y
)),
mode
=
m
)
theano
.
printing
.
debugprint
(
f
)
f
([
10000
],
[
10000
])
# causes overflow if handled incorrectly
print
f
([
10000
],
[
10000
])
# causes overflow if handled incorrectly
assert
numpy
.
isfinite
(
f
([
10000
],
[
10000
]))
assert
numpy
.
isfinite
(
f
([
10000
],
[
10000
]))
assert
numpy
.
allclose
(
f
([
10000
],
[
10000
]),
10000
+
numpy
.
log1p
(
1
))
assert
numpy
.
allclose
(
f
([
10000
],
[
10000
]),
10000
+
numpy
.
log1p
(
1
))
#test that it give the same result when it don't overflow
#test that it give the same result when it don't overflow
print
f
([
10
],
[
10
])
# don't causes overflow
f
([
10
],
[
10
])
# don't causes overflow
assert
numpy
.
allclose
(
f
([
10
],
[
10
]),
10
+
numpy
.
log1p
(
1
))
assert
numpy
.
allclose
(
f
([
10
],
[
10
]),
10
+
numpy
.
log1p
(
1
))
# test that it also works with more than two args, (this currently fails)
# test that it also works with more than two args, (this currently fails)
...
@@ -1574,10 +1558,9 @@ def test_log_add():
...
@@ -1574,10 +1558,9 @@ def test_log_add():
y
=
dvector
()
y
=
dvector
()
f
=
function
([
x
,
y
],
T
.
log
(
T
.
exp
(
x
)
+
T
.
exp
(
y
)
+
T
.
exp
(
x
-
y
)
+
T
.
exp
(
f
=
function
([
x
,
y
],
T
.
log
(
T
.
exp
(
x
)
+
T
.
exp
(
y
)
+
T
.
exp
(
x
-
y
)
+
T
.
exp
(
x
+
y
)),
mode
=
m
)
x
+
y
)),
mode
=
m
)
theano
.
printing
.
debugprint
(
f
)
try
:
try
:
print
f
([
10000
],
[
10000
])
# causes overflow if handled incorrectly
f
([
10000
],
[
10000
])
# causes overflow if handled incorrectly
assert
numpy
.
allclose
(
f
([
10000
],
[
10000
]),
20000
)
assert
numpy
.
allclose
(
f
([
10000
],
[
10000
]),
20000
)
except
AssertionError
:
except
AssertionError
:
raise
KnownFailureTest
((
'log(add(exp)) is not stabilized when adding '
raise
KnownFailureTest
((
'log(add(exp)) is not stabilized when adding '
...
@@ -2192,8 +2175,8 @@ class test_local_subtensor_merge(unittest.TestCase):
...
@@ -2192,8 +2175,8 @@ class test_local_subtensor_merge(unittest.TestCase):
n_ok
+=
1
n_ok
+=
1
f
(
x_val
,
b_v
,
e_v
,
s_v
,
i_v
)
f
(
x_val
,
b_v
,
e_v
,
s_v
,
i_v
)
print
'shape:
%
s'
%
(
x_s
,)
#
print 'shape: %s' % (x_s,)
print
'
%%
OK:
%
f'
%
(
float
(
n_ok
)
*
100
/
(
n_ok
+
n_index_err
))
#
print '%% OK: %f' % (float(n_ok) * 100 / (n_ok + n_index_err))
@attr
(
'slow'
)
@attr
(
'slow'
)
def
test_none_slice
(
self
):
def
test_none_slice
(
self
):
...
@@ -2873,41 +2856,30 @@ def test_local_mul_specialize():
...
@@ -2873,41 +2856,30 @@ def test_local_mul_specialize():
f
=
function
([
v
],
v
*
1
,
mode
=
mode
)
f
=
function
([
v
],
v
*
1
,
mode
=
mode
)
nodes
=
[
node
.
op
for
node
in
f
.
maker
.
fgraph
.
toposort
()]
nodes
=
[
node
.
op
for
node
in
f
.
maker
.
fgraph
.
toposort
()]
print
nodes
nodes
==
[
deep_copy_op
]
nodes
==
[
deep_copy_op
]
f
=
function
([
v
],
v
*
0
,
mode
=
mode
)
f
=
function
([
v
],
v
*
0
,
mode
=
mode
)
nodes
=
[
node
.
op
for
node
in
f
.
maker
.
fgraph
.
toposort
()]
nodes
=
[
node
.
op
for
node
in
f
.
maker
.
fgraph
.
toposort
()]
print
nodes
assert
nodes
==
[
Shape_i
(
0
),
T
.
alloc
]
assert
nodes
==
[
Shape_i
(
0
),
T
.
alloc
]
f
=
function
([
v
],
v
*
(
-
1
),
mode
=
mode
)
f
=
function
([
v
],
v
*
(
-
1
),
mode
=
mode
)
nodes
=
[
node
.
op
for
node
in
f
.
maker
.
fgraph
.
toposort
()]
nodes
=
[
node
.
op
for
node
in
f
.
maker
.
fgraph
.
toposort
()]
print
nodes
assert
nodes
==
[
T
.
neg
]
assert
nodes
==
[
T
.
neg
]
f
=
function
([
v
,
m
],
v
*
1
*
(
-
m
),
mode
=
mode
)
f
=
function
([
v
,
m
],
v
*
1
*
(
-
m
),
mode
=
mode
)
nodes
=
[
node
.
op
for
node
in
f
.
maker
.
fgraph
.
toposort
()]
nodes
=
[
node
.
op
for
node
in
f
.
maker
.
fgraph
.
toposort
()]
print
nodes
theano
.
printing
.
debugprint
(
f
)
assert
nodes
==
[
T
.
mul
]
assert
nodes
==
[
T
.
mul
]
f
=
function
([
v
,
m
],
v
*
0
*
(
-
m
),
mode
=
mode
)
f
=
function
([
v
,
m
],
v
*
0
*
(
-
m
),
mode
=
mode
)
nodes
=
[
node
.
op
for
node
in
f
.
maker
.
fgraph
.
toposort
()]
nodes
=
[
node
.
op
for
node
in
f
.
maker
.
fgraph
.
toposort
()]
print
nodes
theano
.
printing
.
debugprint
(
f
)
assert
nodes
==
[
Shape_i
(
0
),
T
.
alloc
]
assert
nodes
==
[
Shape_i
(
0
),
T
.
alloc
]
f
=
function
([
v
,
m
],
v
*
(
-
1
)
*
(
-
m
),
mode
=
mode
)
f
=
function
([
v
,
m
],
v
*
(
-
1
)
*
(
-
m
),
mode
=
mode
)
nodes
=
[
node
.
op
for
node
in
f
.
maker
.
fgraph
.
toposort
()]
nodes
=
[
node
.
op
for
node
in
f
.
maker
.
fgraph
.
toposort
()]
print
nodes
theano
.
printing
.
debugprint
(
f
)
assert
nodes
==
[
T
.
mul
]
assert
nodes
==
[
T
.
mul
]
f
=
function
([
v
,
m
],
v
*
(
-
1
)
*
m
,
mode
=
mode
)
f
=
function
([
v
,
m
],
v
*
(
-
1
)
*
m
,
mode
=
mode
)
nodes
=
[
node
.
op
for
node
in
f
.
maker
.
fgraph
.
toposort
()]
nodes
=
[
node
.
op
for
node
in
f
.
maker
.
fgraph
.
toposort
()]
print
nodes
theano
.
printing
.
debugprint
(
f
)
assert
nodes
==
[
T
.
mul
]
assert
nodes
==
[
T
.
mul
]
...
@@ -3078,7 +3050,6 @@ class T_useless_elemwise(unittest.TestCase):
...
@@ -3078,7 +3050,6 @@ class T_useless_elemwise(unittest.TestCase):
f2
=
theano
.
function
([
x
],
T
.
eq
(
x
,
x
),
mode
=
self
.
mode
)
f2
=
theano
.
function
([
x
],
T
.
eq
(
x
,
x
),
mode
=
self
.
mode
)
assert
numpy
.
all
(
f2
(
vx
)
==
numpy
.
ones
((
5
,
4
)))
assert
numpy
.
all
(
f2
(
vx
)
==
numpy
.
ones
((
5
,
4
)))
topo2
=
f2
.
maker
.
fgraph
.
toposort
()
topo2
=
f2
.
maker
.
fgraph
.
toposort
()
print
topo2
#Shape_i{1}(<TensorType(float64, matrix)>), Shape_i{0}(<TensorType(float64, matrix)>), Alloc([[1]], Shape_i{0}.0, Shape_i{1}.0
#Shape_i{1}(<TensorType(float64, matrix)>), Shape_i{0}(<TensorType(float64, matrix)>), Alloc([[1]], Shape_i{0}.0, Shape_i{1}.0
assert
len
(
topo2
)
==
3
assert
len
(
topo2
)
==
3
assert
isinstance
(
topo2
[
-
1
]
.
op
,
T
.
Alloc
)
assert
isinstance
(
topo2
[
-
1
]
.
op
,
T
.
Alloc
)
...
@@ -3097,7 +3068,6 @@ class T_useless_elemwise(unittest.TestCase):
...
@@ -3097,7 +3068,6 @@ class T_useless_elemwise(unittest.TestCase):
f2
=
theano
.
function
([
x
],
T
.
neq
(
x
,
x
),
mode
=
self
.
mode
)
f2
=
theano
.
function
([
x
],
T
.
neq
(
x
,
x
),
mode
=
self
.
mode
)
assert
numpy
.
all
(
f2
(
vx
)
==
numpy
.
zeros
((
5
,
4
)))
assert
numpy
.
all
(
f2
(
vx
)
==
numpy
.
zeros
((
5
,
4
)))
topo2
=
f2
.
maker
.
fgraph
.
toposort
()
topo2
=
f2
.
maker
.
fgraph
.
toposort
()
print
topo2
assert
len
(
topo2
)
==
3
assert
len
(
topo2
)
==
3
assert
isinstance
(
topo2
[
-
1
]
.
op
,
T
.
Alloc
)
assert
isinstance
(
topo2
[
-
1
]
.
op
,
T
.
Alloc
)
...
@@ -3114,7 +3084,6 @@ class T_useless_elemwise(unittest.TestCase):
...
@@ -3114,7 +3084,6 @@ class T_useless_elemwise(unittest.TestCase):
f2
=
theano
.
function
([
x
,
y
],
T
.
mul
(
x
,
y
),
mode
=
self
.
mode
)
f2
=
theano
.
function
([
x
,
y
],
T
.
mul
(
x
,
y
),
mode
=
self
.
mode
)
assert
numpy
.
all
(
f2
(
vx
,
vy
)
==
vx
*
vy
)
assert
numpy
.
all
(
f2
(
vx
,
vy
)
==
vx
*
vy
)
topo2
=
f2
.
maker
.
fgraph
.
toposort
()
topo2
=
f2
.
maker
.
fgraph
.
toposort
()
print
topo2
assert
len
(
topo2
)
==
1
assert
len
(
topo2
)
==
1
assert
isinstance
(
topo2
[
0
]
.
op
,
T
.
Elemwise
)
assert
isinstance
(
topo2
[
0
]
.
op
,
T
.
Elemwise
)
assert
isinstance
(
topo2
[
0
]
.
op
.
scalar_op
,
theano
.
scalar
.
Mul
)
assert
isinstance
(
topo2
[
0
]
.
op
.
scalar_op
,
theano
.
scalar
.
Mul
)
...
@@ -3132,7 +3101,6 @@ class T_useless_elemwise(unittest.TestCase):
...
@@ -3132,7 +3101,6 @@ class T_useless_elemwise(unittest.TestCase):
f2
=
theano
.
function
([
x
,
y
],
T
.
add
(
x
,
y
),
mode
=
self
.
mode
)
f2
=
theano
.
function
([
x
,
y
],
T
.
add
(
x
,
y
),
mode
=
self
.
mode
)
assert
numpy
.
all
(
f2
(
vx
,
vy
)
==
vx
+
vy
)
assert
numpy
.
all
(
f2
(
vx
,
vy
)
==
vx
+
vy
)
topo2
=
f2
.
maker
.
fgraph
.
toposort
()
topo2
=
f2
.
maker
.
fgraph
.
toposort
()
print
topo2
assert
len
(
topo2
)
==
1
assert
len
(
topo2
)
==
1
assert
isinstance
(
topo2
[
0
]
.
op
,
T
.
Elemwise
)
assert
isinstance
(
topo2
[
0
]
.
op
,
T
.
Elemwise
)
assert
isinstance
(
topo2
[
0
]
.
op
.
scalar_op
,
theano
.
scalar
.
Add
)
assert
isinstance
(
topo2
[
0
]
.
op
.
scalar_op
,
theano
.
scalar
.
Add
)
...
@@ -3264,20 +3232,17 @@ class T_local_erf(unittest.TestCase):
...
@@ -3264,20 +3232,17 @@ class T_local_erf(unittest.TestCase):
x
=
T
.
vector
()
x
=
T
.
vector
()
f
=
theano
.
function
([
x
],
1
+
T
.
erf
(
x
),
mode
=
self
.
mode
)
f
=
theano
.
function
([
x
],
1
+
T
.
erf
(
x
),
mode
=
self
.
mode
)
print
f
.
maker
.
fgraph
.
toposort
()
assert
[
n
.
op
for
n
in
f
.
maker
.
fgraph
.
toposort
()]
==
[
assert
[
n
.
op
for
n
in
f
.
maker
.
fgraph
.
toposort
()]
==
[
T
.
mul
,
T
.
erfc
],
f
.
maker
.
fgraph
.
toposort
()
T
.
mul
,
T
.
erfc
],
f
.
maker
.
fgraph
.
toposort
()
f
(
val
)
f
(
val
)
f
=
theano
.
function
([
x
],
T
.
erf
(
x
)
+
1
,
mode
=
self
.
mode
)
f
=
theano
.
function
([
x
],
T
.
erf
(
x
)
+
1
,
mode
=
self
.
mode
)
print
f
.
maker
.
fgraph
.
toposort
()
assert
[
n
.
op
for
n
in
f
.
maker
.
fgraph
.
toposort
()]
==
[
assert
[
n
.
op
for
n
in
f
.
maker
.
fgraph
.
toposort
()]
==
[
T
.
mul
,
T
.
erfc
],
f
.
maker
.
fgraph
.
toposort
()
T
.
mul
,
T
.
erfc
],
f
.
maker
.
fgraph
.
toposort
()
f
(
val
)
f
(
val
)
f
=
theano
.
function
([
x
],
T
.
erf
(
x
)
+
2
,
mode
=
self
.
mode
)
f
=
theano
.
function
([
x
],
T
.
erf
(
x
)
+
2
,
mode
=
self
.
mode
)
topo
=
f
.
maker
.
fgraph
.
toposort
()
topo
=
f
.
maker
.
fgraph
.
toposort
()
print
topo
assert
len
(
topo
)
==
2
assert
len
(
topo
)
==
2
assert
topo
[
0
]
.
op
==
T
.
erf
assert
topo
[
0
]
.
op
==
T
.
erf
assert
isinstance
(
topo
[
1
]
.
op
,
T
.
Elemwise
)
assert
isinstance
(
topo
[
1
]
.
op
,
T
.
Elemwise
)
...
@@ -3290,26 +3255,22 @@ class T_local_erf(unittest.TestCase):
...
@@ -3290,26 +3255,22 @@ class T_local_erf(unittest.TestCase):
x
=
T
.
vector
()
x
=
T
.
vector
()
f
=
theano
.
function
([
x
],
1
-
T
.
erf
(
x
),
mode
=
self
.
mode
)
f
=
theano
.
function
([
x
],
1
-
T
.
erf
(
x
),
mode
=
self
.
mode
)
print
f
.
maker
.
fgraph
.
toposort
()
assert
[
n
.
op
for
n
in
f
.
maker
.
fgraph
.
toposort
()]
==
[
T
.
erfc
]
\
assert
[
n
.
op
for
n
in
f
.
maker
.
fgraph
.
toposort
()]
==
[
T
.
erfc
]
\
,
f
.
maker
.
fgraph
.
toposort
()
,
f
.
maker
.
fgraph
.
toposort
()
print
f
(
val
)
print
f
(
val
)
f
=
theano
.
function
([
x
],
1
+
(
-
T
.
erf
(
x
)),
mode
=
self
.
mode
)
f
=
theano
.
function
([
x
],
1
+
(
-
T
.
erf
(
x
)),
mode
=
self
.
mode
)
print
f
.
maker
.
fgraph
.
toposort
()
assert
[
n
.
op
for
n
in
f
.
maker
.
fgraph
.
toposort
()]
==
[
T
.
erfc
]
\
assert
[
n
.
op
for
n
in
f
.
maker
.
fgraph
.
toposort
()]
==
[
T
.
erfc
]
\
,
f
.
maker
.
fgraph
.
toposort
()
,
f
.
maker
.
fgraph
.
toposort
()
print
f
(
val
)
print
f
(
val
)
f
=
theano
.
function
([
x
],
(
-
T
.
erf
(
x
))
+
1
,
mode
=
self
.
mode
)
f
=
theano
.
function
([
x
],
(
-
T
.
erf
(
x
))
+
1
,
mode
=
self
.
mode
)
print
f
.
maker
.
fgraph
.
toposort
()
assert
[
n
.
op
for
n
in
f
.
maker
.
fgraph
.
toposort
()]
==
[
T
.
erfc
]
\
assert
[
n
.
op
for
n
in
f
.
maker
.
fgraph
.
toposort
()]
==
[
T
.
erfc
]
\
,
f
.
maker
.
fgraph
.
toposort
()
,
f
.
maker
.
fgraph
.
toposort
()
print
f
(
val
)
print
f
(
val
)
f
=
theano
.
function
([
x
],
2
-
T
.
erf
(
x
),
mode
=
self
.
mode
)
f
=
theano
.
function
([
x
],
2
-
T
.
erf
(
x
),
mode
=
self
.
mode
)
topo
=
f
.
maker
.
fgraph
.
toposort
()
topo
=
f
.
maker
.
fgraph
.
toposort
()
print
topo
assert
len
(
topo
)
==
2
,
f
.
maker
.
fgraph
.
toposort
()
assert
len
(
topo
)
==
2
,
f
.
maker
.
fgraph
.
toposort
()
assert
topo
[
0
]
.
op
==
T
.
erf
,
f
.
maker
.
fgraph
.
toposort
()
assert
topo
[
0
]
.
op
==
T
.
erf
,
f
.
maker
.
fgraph
.
toposort
()
assert
isinstance
(
topo
[
1
]
.
op
,
T
.
Elemwise
),
f
.
maker
.
fgraph
.
toposort
()
assert
isinstance
(
topo
[
1
]
.
op
,
T
.
Elemwise
),
f
.
maker
.
fgraph
.
toposort
()
...
@@ -3323,23 +3284,19 @@ class T_local_erf(unittest.TestCase):
...
@@ -3323,23 +3284,19 @@ class T_local_erf(unittest.TestCase):
x
=
T
.
vector
()
x
=
T
.
vector
()
f
=
theano
.
function
([
x
],
T
.
erf
(
x
)
-
1
,
mode
=
self
.
mode
)
f
=
theano
.
function
([
x
],
T
.
erf
(
x
)
-
1
,
mode
=
self
.
mode
)
print
f
.
maker
.
fgraph
.
toposort
()
assert
[
n
.
op
for
n
in
f
.
maker
.
fgraph
.
toposort
()]
==
[
T
.
erfc
,
T
.
mul
]
assert
[
n
.
op
for
n
in
f
.
maker
.
fgraph
.
toposort
()]
==
[
T
.
erfc
,
T
.
mul
]
print
f
(
val
)
print
f
(
val
)
f
=
theano
.
function
([
x
],
T
.
erf
(
x
)
+
(
-
1
),
mode
=
self
.
mode
)
f
=
theano
.
function
([
x
],
T
.
erf
(
x
)
+
(
-
1
),
mode
=
self
.
mode
)
print
f
.
maker
.
fgraph
.
toposort
()
assert
[
n
.
op
for
n
in
f
.
maker
.
fgraph
.
toposort
()]
==
[
T
.
erfc
,
T
.
mul
]
assert
[
n
.
op
for
n
in
f
.
maker
.
fgraph
.
toposort
()]
==
[
T
.
erfc
,
T
.
mul
]
print
f
(
val
)
print
f
(
val
)
f
=
theano
.
function
([
x
],
-
1
+
T
.
erf
(
x
),
mode
=
self
.
mode
)
f
=
theano
.
function
([
x
],
-
1
+
T
.
erf
(
x
),
mode
=
self
.
mode
)
print
f
.
maker
.
fgraph
.
toposort
()
assert
[
n
.
op
for
n
in
f
.
maker
.
fgraph
.
toposort
()]
==
[
T
.
erfc
,
T
.
mul
]
assert
[
n
.
op
for
n
in
f
.
maker
.
fgraph
.
toposort
()]
==
[
T
.
erfc
,
T
.
mul
]
print
f
(
val
)
print
f
(
val
)
f
=
theano
.
function
([
x
],
T
.
erf
(
x
)
-
2
,
mode
=
self
.
mode
)
f
=
theano
.
function
([
x
],
T
.
erf
(
x
)
-
2
,
mode
=
self
.
mode
)
topo
=
f
.
maker
.
fgraph
.
toposort
()
topo
=
f
.
maker
.
fgraph
.
toposort
()
print
topo
assert
len
(
topo
)
==
2
assert
len
(
topo
)
==
2
assert
topo
[
0
]
.
op
==
T
.
erf
assert
topo
[
0
]
.
op
==
T
.
erf
assert
isinstance
(
topo
[
1
]
.
op
,
T
.
Elemwise
)
assert
isinstance
(
topo
[
1
]
.
op
,
T
.
Elemwise
)
...
@@ -3366,20 +3323,17 @@ class T_local_erfc(unittest.TestCase):
...
@@ -3366,20 +3323,17 @@ class T_local_erfc(unittest.TestCase):
x
=
T
.
vector
(
'x'
)
x
=
T
.
vector
(
'x'
)
f
=
theano
.
function
([
x
],
1
-
T
.
erfc
(
x
),
mode
=
self
.
mode
)
f
=
theano
.
function
([
x
],
1
-
T
.
erfc
(
x
),
mode
=
self
.
mode
)
theano
.
printing
.
debugprint
(
f
)
assert
[
n
.
op
for
n
in
f
.
maker
.
fgraph
.
toposort
()]
==
[
T
.
erf
]
\
assert
[
n
.
op
for
n
in
f
.
maker
.
fgraph
.
toposort
()]
==
[
T
.
erf
]
\
,
f
.
maker
.
fgraph
.
toposort
()
,
f
.
maker
.
fgraph
.
toposort
()
print
f
(
val
)
print
f
(
val
)
f
=
theano
.
function
([
x
],
(
-
T
.
erfc
(
x
))
+
1
,
mode
=
self
.
mode
)
f
=
theano
.
function
([
x
],
(
-
T
.
erfc
(
x
))
+
1
,
mode
=
self
.
mode
)
theano
.
printing
.
debugprint
(
f
)
assert
[
n
.
op
for
n
in
f
.
maker
.
fgraph
.
toposort
()]
==
[
T
.
erf
]
\
assert
[
n
.
op
for
n
in
f
.
maker
.
fgraph
.
toposort
()]
==
[
T
.
erf
]
\
,
f
.
maker
.
fgraph
.
toposort
()
,
f
.
maker
.
fgraph
.
toposort
()
print
f
(
val
)
print
f
(
val
)
f
=
theano
.
function
([
x
],
2
-
T
.
erfc
(
x
),
mode
=
self
.
mode
)
f
=
theano
.
function
([
x
],
2
-
T
.
erfc
(
x
),
mode
=
self
.
mode
)
topo
=
f
.
maker
.
fgraph
.
toposort
()
topo
=
f
.
maker
.
fgraph
.
toposort
()
theano
.
printing
.
debugprint
(
f
)
assert
len
(
topo
)
==
2
,
f
.
maker
.
fgraph
.
toposort
()
assert
len
(
topo
)
==
2
,
f
.
maker
.
fgraph
.
toposort
()
assert
topo
[
0
]
.
op
==
T
.
erfc
,
f
.
maker
.
fgraph
.
toposort
()
assert
topo
[
0
]
.
op
==
T
.
erfc
,
f
.
maker
.
fgraph
.
toposort
()
assert
isinstance
(
topo
[
1
]
.
op
,
T
.
Elemwise
),
f
.
maker
.
fgraph
.
toposort
()
assert
isinstance
(
topo
[
1
]
.
op
,
T
.
Elemwise
),
f
.
maker
.
fgraph
.
toposort
()
...
@@ -3394,19 +3348,16 @@ class T_local_erfc(unittest.TestCase):
...
@@ -3394,19 +3348,16 @@ class T_local_erfc(unittest.TestCase):
x
=
T
.
vector
(
'x'
)
x
=
T
.
vector
(
'x'
)
f
=
theano
.
function
([
x
],
-
1
+
T
.
erfc
(
-
x
),
mode
=
self
.
mode
)
f
=
theano
.
function
([
x
],
-
1
+
T
.
erfc
(
-
x
),
mode
=
self
.
mode
)
theano
.
printing
.
debugprint
(
f
)
assert
[
n
.
op
for
n
in
f
.
maker
.
fgraph
.
toposort
()]
==
[
T
.
erf
]
\
assert
[
n
.
op
for
n
in
f
.
maker
.
fgraph
.
toposort
()]
==
[
T
.
erf
]
\
,
f
.
maker
.
fgraph
.
toposort
()
,
f
.
maker
.
fgraph
.
toposort
()
print
f
(
val
)
print
f
(
val
)
f
=
theano
.
function
([
x
],
T
.
erfc
(
-
x
)
-
1
,
mode
=
self
.
mode
)
f
=
theano
.
function
([
x
],
T
.
erfc
(
-
x
)
-
1
,
mode
=
self
.
mode
)
theano
.
printing
.
debugprint
(
f
)
assert
[
n
.
op
for
n
in
f
.
maker
.
fgraph
.
toposort
()]
==
[
T
.
erf
]
\
assert
[
n
.
op
for
n
in
f
.
maker
.
fgraph
.
toposort
()]
==
[
T
.
erf
]
\
,
f
.
maker
.
fgraph
.
toposort
()
,
f
.
maker
.
fgraph
.
toposort
()
print
f
(
val
)
print
f
(
val
)
f
=
theano
.
function
([
x
],
T
.
erfc
(
-
x
)
+
(
-
1
),
mode
=
self
.
mode
)
f
=
theano
.
function
([
x
],
T
.
erfc
(
-
x
)
+
(
-
1
),
mode
=
self
.
mode
)
theano
.
printing
.
debugprint
(
f
)
assert
[
n
.
op
for
n
in
f
.
maker
.
fgraph
.
toposort
()]
==
[
T
.
erf
]
\
assert
[
n
.
op
for
n
in
f
.
maker
.
fgraph
.
toposort
()]
==
[
T
.
erf
]
\
,
f
.
maker
.
fgraph
.
toposort
()
,
f
.
maker
.
fgraph
.
toposort
()
print
f
(
val
)
print
f
(
val
)
...
@@ -3427,13 +3378,11 @@ class T_local_erfc(unittest.TestCase):
...
@@ -3427,13 +3378,11 @@ class T_local_erfc(unittest.TestCase):
mode_fusion
.
check_isfinite
=
False
mode_fusion
.
check_isfinite
=
False
f
=
theano
.
function
([
x
],
T
.
log
(
T
.
erfc
(
x
)),
mode
=
mode
)
f
=
theano
.
function
([
x
],
T
.
log
(
T
.
erfc
(
x
)),
mode
=
mode
)
#theano.printing.debugprint(f)
assert
len
(
f
.
maker
.
fgraph
.
apply_nodes
)
==
23
,
len
(
f
.
maker
.
fgraph
.
apply_nodes
)
assert
len
(
f
.
maker
.
fgraph
.
apply_nodes
)
==
23
,
len
(
f
.
maker
.
fgraph
.
apply_nodes
)
assert
f
.
maker
.
fgraph
.
outputs
[
0
]
.
dtype
==
theano
.
config
.
floatX
assert
f
.
maker
.
fgraph
.
outputs
[
0
]
.
dtype
==
theano
.
config
.
floatX
assert
all
(
numpy
.
isfinite
(
f
(
val
)))
assert
all
(
numpy
.
isfinite
(
f
(
val
)))
f
=
theano
.
function
([
x
],
T
.
log
(
T
.
erfc
(
-
x
)),
mode
=
mode
)
f
=
theano
.
function
([
x
],
T
.
log
(
T
.
erfc
(
-
x
)),
mode
=
mode
)
#theano.printing.debugprint(f)
assert
len
(
f
.
maker
.
fgraph
.
apply_nodes
)
==
24
,
len
(
f
.
maker
.
fgraph
.
apply_nodes
)
assert
len
(
f
.
maker
.
fgraph
.
apply_nodes
)
==
24
,
len
(
f
.
maker
.
fgraph
.
apply_nodes
)
assert
f
.
maker
.
fgraph
.
outputs
[
0
]
.
dtype
==
theano
.
config
.
floatX
assert
f
.
maker
.
fgraph
.
outputs
[
0
]
.
dtype
==
theano
.
config
.
floatX
assert
all
(
numpy
.
isfinite
(
f
(
-
val
)))
assert
all
(
numpy
.
isfinite
(
f
(
-
val
)))
...
@@ -3470,7 +3419,6 @@ class T_local_erfc(unittest.TestCase):
...
@@ -3470,7 +3419,6 @@ class T_local_erfc(unittest.TestCase):
mode_fusion
.
check_isfinite
=
False
mode_fusion
.
check_isfinite
=
False
f
=
theano
.
function
([
x
],
T
.
grad
(
T
.
log
(
T
.
erfc
(
x
))
.
sum
(),
x
),
mode
=
mode
)
f
=
theano
.
function
([
x
],
T
.
grad
(
T
.
log
(
T
.
erfc
(
x
))
.
sum
(),
x
),
mode
=
mode
)
#theano.printing.debugprint(f)
assert
len
(
f
.
maker
.
fgraph
.
apply_nodes
)
==
23
,
len
(
f
.
maker
.
fgraph
.
apply_nodes
)
assert
len
(
f
.
maker
.
fgraph
.
apply_nodes
)
==
23
,
len
(
f
.
maker
.
fgraph
.
apply_nodes
)
assert
all
(
numpy
.
isfinite
(
f
(
val
)))
assert
all
(
numpy
.
isfinite
(
f
(
val
)))
assert
f
.
maker
.
fgraph
.
outputs
[
0
]
.
dtype
==
theano
.
config
.
floatX
assert
f
.
maker
.
fgraph
.
outputs
[
0
]
.
dtype
==
theano
.
config
.
floatX
...
@@ -3478,14 +3426,12 @@ class T_local_erfc(unittest.TestCase):
...
@@ -3478,14 +3426,12 @@ class T_local_erfc(unittest.TestCase):
#test with a different mul constant
#test with a different mul constant
f
=
theano
.
function
([
x
],
T
.
mul
(
T
.
exp
(
T
.
neg
(
T
.
sqr
(
x
))),
-
f
=
theano
.
function
([
x
],
T
.
mul
(
T
.
exp
(
T
.
neg
(
T
.
sqr
(
x
))),
-
10.12837917
)
/
T
.
erfc
(
x
),
mode
=
mode
)
10.12837917
)
/
T
.
erfc
(
x
),
mode
=
mode
)
#theano.printing.debugprint(f)
assert
len
(
f
.
maker
.
fgraph
.
apply_nodes
)
==
23
,
len
(
f
.
maker
.
fgraph
.
apply_nodes
)
assert
len
(
f
.
maker
.
fgraph
.
apply_nodes
)
==
23
,
len
(
f
.
maker
.
fgraph
.
apply_nodes
)
assert
f
.
maker
.
fgraph
.
outputs
[
0
]
.
dtype
==
theano
.
config
.
floatX
assert
f
.
maker
.
fgraph
.
outputs
[
0
]
.
dtype
==
theano
.
config
.
floatX
assert
all
(
numpy
.
isfinite
(
f
(
val
)))
assert
all
(
numpy
.
isfinite
(
f
(
val
)))
#test that we work without the mul
#test that we work without the mul
f
=
theano
.
function
([
x
],
T
.
exp
(
T
.
neg
(
T
.
sqr
(
x
)))
/
T
.
erfc
(
x
),
mode
=
mode
)
f
=
theano
.
function
([
x
],
T
.
exp
(
T
.
neg
(
T
.
sqr
(
x
)))
/
T
.
erfc
(
x
),
mode
=
mode
)
#theano.printing.debugprint(f)
assert
len
(
f
.
maker
.
fgraph
.
apply_nodes
)
==
23
,
len
(
f
.
maker
.
fgraph
.
apply_nodes
)
assert
len
(
f
.
maker
.
fgraph
.
apply_nodes
)
==
23
,
len
(
f
.
maker
.
fgraph
.
apply_nodes
)
assert
f
.
maker
.
fgraph
.
outputs
[
0
]
.
dtype
==
theano
.
config
.
floatX
assert
f
.
maker
.
fgraph
.
outputs
[
0
]
.
dtype
==
theano
.
config
.
floatX
assert
all
(
numpy
.
isfinite
(
f
(
val
)))
assert
all
(
numpy
.
isfinite
(
f
(
val
)))
...
@@ -3493,14 +3439,12 @@ class T_local_erfc(unittest.TestCase):
...
@@ -3493,14 +3439,12 @@ class T_local_erfc(unittest.TestCase):
#test that we don't work if x!=y
#test that we don't work if x!=y
f
=
theano
.
function
([
x
,
y
],
T
.
exp
(
T
.
neg
(
T
.
sqr
(
x
)))
/
T
.
erfc
(
f
=
theano
.
function
([
x
,
y
],
T
.
exp
(
T
.
neg
(
T
.
sqr
(
x
)))
/
T
.
erfc
(
y
),
mode
=
mode
)
y
),
mode
=
mode
)
#theano.printing.debugprint(f)
assert
len
(
f
.
maker
.
fgraph
.
apply_nodes
)
==
5
,
len
(
f
.
maker
.
fgraph
.
apply_nodes
)
assert
len
(
f
.
maker
.
fgraph
.
apply_nodes
)
==
5
,
len
(
f
.
maker
.
fgraph
.
apply_nodes
)
assert
f
.
maker
.
fgraph
.
outputs
[
0
]
.
dtype
==
theano
.
config
.
floatX
assert
f
.
maker
.
fgraph
.
outputs
[
0
]
.
dtype
==
theano
.
config
.
floatX
f
(
val
,
val
-
3
)
f
(
val
,
val
-
3
)
#test that we work without the sqr and neg
#test that we work without the sqr and neg
f
=
theano
.
function
([
x
],
T
.
exp
(
T
.
mul
(
-
1
,
x
,
x
))
/
T
.
erfc
(
x
),
mode
=
mode
)
f
=
theano
.
function
([
x
],
T
.
exp
(
T
.
mul
(
-
1
,
x
,
x
))
/
T
.
erfc
(
x
),
mode
=
mode
)
#theano.printing.debugprint(f)
assert
len
(
f
.
maker
.
fgraph
.
apply_nodes
)
==
22
,
len
(
f
.
maker
.
fgraph
.
apply_nodes
)
assert
len
(
f
.
maker
.
fgraph
.
apply_nodes
)
==
22
,
len
(
f
.
maker
.
fgraph
.
apply_nodes
)
assert
f
.
maker
.
fgraph
.
outputs
[
0
]
.
dtype
==
theano
.
config
.
floatX
assert
f
.
maker
.
fgraph
.
outputs
[
0
]
.
dtype
==
theano
.
config
.
floatX
assert
all
(
numpy
.
isfinite
(
f
(
val
)))
assert
all
(
numpy
.
isfinite
(
f
(
val
)))
...
@@ -3508,7 +3452,6 @@ class T_local_erfc(unittest.TestCase):
...
@@ -3508,7 +3452,6 @@ class T_local_erfc(unittest.TestCase):
#test that it work correctly if x is x*2 in the graph.
#test that it work correctly if x is x*2 in the graph.
f
=
theano
.
function
([
x
],
T
.
grad
(
T
.
log
(
T
.
erfc
(
2
*
x
))
.
sum
(),
f
=
theano
.
function
([
x
],
T
.
grad
(
T
.
log
(
T
.
erfc
(
2
*
x
))
.
sum
(),
x
),
mode
=
mode
)
x
),
mode
=
mode
)
#theano.printing.debugprint(f)
assert
len
(
f
.
maker
.
fgraph
.
apply_nodes
)
==
23
,
len
(
f
.
maker
.
fgraph
.
apply_nodes
)
assert
len
(
f
.
maker
.
fgraph
.
apply_nodes
)
==
23
,
len
(
f
.
maker
.
fgraph
.
apply_nodes
)
assert
numpy
.
isfinite
(
f
(
val
))
.
all
()
assert
numpy
.
isfinite
(
f
(
val
))
.
all
()
assert
f
.
maker
.
fgraph
.
outputs
[
0
]
.
dtype
==
theano
.
config
.
floatX
assert
f
.
maker
.
fgraph
.
outputs
[
0
]
.
dtype
==
theano
.
config
.
floatX
...
@@ -3587,7 +3530,6 @@ class test_local_remove_switch_const_cond(unittest.TestCase):
...
@@ -3587,7 +3530,6 @@ class test_local_remove_switch_const_cond(unittest.TestCase):
z
=
theano
.
tensor
.
switch
(
1
,
x
,
y
)
z
=
theano
.
tensor
.
switch
(
1
,
x
,
y
)
f
=
theano
.
function
([
x
,
y
],
z
,
mode
=
self
.
mode
)
f
=
theano
.
function
([
x
,
y
],
z
,
mode
=
self
.
mode
)
#theano.printing.debugprint(f)
assert
len
([
node
.
op
for
node
in
f
.
maker
.
fgraph
.
toposort
()
if
assert
len
([
node
.
op
for
node
in
f
.
maker
.
fgraph
.
toposort
()
if
isinstance
(
node
.
op
,
theano
.
tensor
.
Elemwise
)
and
isinstance
(
node
.
op
,
theano
.
tensor
.
Elemwise
)
and
not
isinstance
(
node
.
op
.
scalar_op
,
theano
.
scalar
.
basic
.
Cast
)])
==
0
not
isinstance
(
node
.
op
.
scalar_op
,
theano
.
scalar
.
basic
.
Cast
)])
==
0
...
@@ -3597,7 +3539,6 @@ class test_local_remove_switch_const_cond(unittest.TestCase):
...
@@ -3597,7 +3539,6 @@ class test_local_remove_switch_const_cond(unittest.TestCase):
z
=
theano
.
tensor
.
switch
(
0
,
x
,
y
)
z
=
theano
.
tensor
.
switch
(
0
,
x
,
y
)
f
=
theano
.
function
([
x
,
y
],
z
,
mode
=
self
.
mode
)
f
=
theano
.
function
([
x
,
y
],
z
,
mode
=
self
.
mode
)
#theano.printing.debugprint(f)
assert
len
([
node
.
op
for
node
in
f
.
maker
.
fgraph
.
toposort
()
if
assert
len
([
node
.
op
for
node
in
f
.
maker
.
fgraph
.
toposort
()
if
isinstance
(
node
.
op
,
theano
.
tensor
.
Elemwise
)])
==
0
isinstance
(
node
.
op
,
theano
.
tensor
.
Elemwise
)])
==
0
vx
=
numpy
.
array
([[
1
,
2
,
3
],
[
4
,
5
,
6
]],
dtype
=
'int32'
)
vx
=
numpy
.
array
([[
1
,
2
,
3
],
[
4
,
5
,
6
]],
dtype
=
'int32'
)
...
@@ -3912,9 +3853,7 @@ class T_local_sum_dimshuffle(unittest.TestCase):
...
@@ -3912,9 +3853,7 @@ class T_local_sum_dimshuffle(unittest.TestCase):
print
i
print
i
f
=
theano
.
function
([
a
,
b
,
c
,
d
],
s
,
mode
=
self
.
mode
,
f
=
theano
.
function
([
a
,
b
,
c
,
d
],
s
,
mode
=
self
.
mode
,
on_unused_input
=
'ignore'
)
on_unused_input
=
'ignore'
)
theano
.
printing
.
debugprint
(
f
)
g
=
f
.
maker
.
fgraph
.
toposort
()
g
=
f
.
maker
.
fgraph
.
toposort
()
#print 'g =', g
assert
isinstance
(
g
[
-
1
]
.
op
.
scalar_op
,
assert
isinstance
(
g
[
-
1
]
.
op
.
scalar_op
,
theano
.
scalar
.
basic
.
TrueDiv
)
theano
.
scalar
.
basic
.
TrueDiv
)
f
(
a_val
,
b_val
,
c_val
,
d_val
)
f
(
a_val
,
b_val
,
c_val
,
d_val
)
...
@@ -4157,8 +4096,6 @@ def test_local_div_to_inv():
...
@@ -4157,8 +4096,6 @@ def test_local_div_to_inv():
denom_m
=
denom_s
.
dimshuffle
(
'x'
,
'x'
)
denom_m
=
denom_s
.
dimshuffle
(
'x'
,
'x'
)
out
=
num_v
/
denom_m
out
=
num_v
/
denom_m
theano
.
printing
.
debugprint
(
out
,
print_type
=
True
)
print
out
.
broadcastable
assert
numpy
.
all
(
out
.
broadcastable
==
(
True
,
False
))
assert
numpy
.
all
(
out
.
broadcastable
==
(
True
,
False
))
f
=
theano
.
function
([
num_len_s
,
denom_s
],
out
)
f
=
theano
.
function
([
num_len_s
,
denom_s
],
out
)
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论