Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
23adf69e
提交
23adf69e
authored
4月 09, 2014
作者:
Frederic
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
some pep8
上级
64590a18
显示空白字符变更
内嵌
并排
正在显示
1 个修改的文件
包含
25 行增加
和
22 行删除
+25
-22
test_opt.py
theano/tensor/tests/test_opt.py
+25
-22
没有找到文件。
theano/tensor/tests/test_opt.py
浏览文件 @
23adf69e
...
@@ -1495,11 +1495,11 @@ def test_log1p():
...
@@ -1495,11 +1495,11 @@ def test_log1p():
f
=
function
([
x
],
T
.
log
(
1
+
(
x
)),
mode
=
m
)
f
=
function
([
x
],
T
.
log
(
1
+
(
x
)),
mode
=
m
)
assert
[
node
.
op
for
node
in
f
.
maker
.
fgraph
.
toposort
()]
==
[
T
.
log1p
]
assert
[
node
.
op
for
node
in
f
.
maker
.
fgraph
.
toposort
()]
==
[
T
.
log1p
]
f
=
function
([
x
],
T
.
log
(
1
+
(
-
x
)),
mode
=
m
)
f
=
function
([
x
],
T
.
log
(
1
+
(
-
x
)),
mode
=
m
)
assert
[
node
.
op
for
node
in
f
.
maker
.
fgraph
.
toposort
()]
==
[
T
.
neg
,
assert
[
node
.
op
for
node
in
f
.
maker
.
fgraph
.
toposort
()]
==
[
inplace
.
log1p_inplace
]
T
.
neg
,
inplace
.
log1p_inplace
]
f
=
function
([
x
],
-
T
.
log
(
1
+
(
-
x
)),
mode
=
m
)
f
=
function
([
x
],
-
T
.
log
(
1
+
(
-
x
)),
mode
=
m
)
assert
[
node
.
op
for
node
in
f
.
maker
.
fgraph
.
toposort
()]
==
[
T
.
neg
,
assert
[
node
.
op
for
node
in
f
.
maker
.
fgraph
.
toposort
()]
==
[
inplace
.
log1p_inplace
,
inplace
.
neg_inplace
]
T
.
neg
,
inplace
.
log1p_inplace
,
inplace
.
neg_inplace
]
# check trickier cases (and use different dtype)
# check trickier cases (and use different dtype)
y
=
fmatrix
()
y
=
fmatrix
()
...
@@ -1507,12 +1507,12 @@ def test_log1p():
...
@@ -1507,12 +1507,12 @@ def test_log1p():
print
f
.
maker
.
fgraph
.
toposort
()
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
)
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
)
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
)
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
:]
\
...
@@ -2333,7 +2333,8 @@ class Test_alloc_zero(unittest.TestCase):
...
@@ -2333,7 +2333,8 @@ class Test_alloc_zero(unittest.TestCase):
def
setUp
(
self
):
def
setUp
(
self
):
mode
=
theano
.
compile
.
mode
.
get_default_mode
()
mode
=
theano
.
compile
.
mode
.
get_default_mode
()
self
.
mode
=
mode
.
including
(
"local_incsubtensor_of_allocs"
,
self
.
mode
=
mode
.
including
(
"local_incsubtensor_of_allocs"
,
"local_setsubtensor_of_allocs"
,
"local_0_dot_x"
)
"local_setsubtensor_of_allocs"
,
"local_0_dot_x"
)
def
test_setsubtensor_allocs0
(
self
):
def
test_setsubtensor_allocs0
(
self
):
x
=
tensor
.
matrix
()
x
=
tensor
.
matrix
()
...
@@ -2427,7 +2428,7 @@ class Test_alloc_zero(unittest.TestCase):
...
@@ -2427,7 +2428,7 @@ class Test_alloc_zero(unittest.TestCase):
f
(
_e1
[
1
],
_e2
[
1
])
f
(
_e1
[
1
],
_e2
[
1
])
f
(
_e1
[
2
],
_e2
[
2
])
f
(
_e1
[
2
],
_e2
[
2
])
assert
numpy
.
all
([
not
isinstance
(
x
.
op
,
tensor
.
Dot
)
for
x
in
assert
numpy
.
all
([
not
isinstance
(
x
.
op
,
tensor
.
Dot
)
for
x
in
f
.
maker
.
fgraph
.
toposort
()
])
f
.
maker
.
fgraph
.
toposort
()])
#test that we don't remove shape errors
#test that we don't remove shape errors
self
.
assertRaises
((
ValueError
,
AssertionError
),
f
,
self
.
assertRaises
((
ValueError
,
AssertionError
),
f
,
...
@@ -2809,8 +2810,8 @@ class test_assert(utt.InferShapeTester):
...
@@ -2809,8 +2810,8 @@ class test_assert(utt.InferShapeTester):
x
=
T
.
scalar
()
x
=
T
.
scalar
()
y
=
T
.
scalar
()
y
=
T
.
scalar
()
f
=
theano
.
function
([
x
,
y
],
theano
.
tensor
.
opt
.
assert_
(
x
,
y
,
f
=
theano
.
function
([
x
,
y
],
theano
.
tensor
.
opt
.
assert_
(
x
,
y
,
1
),
1
),
mode
=
mode
)
mode
=
mode
)
assert
f
(
1
,
1
)
==
1
assert
f
(
1
,
1
)
==
1
assert
f
(
5
,
1
)
==
5
assert
f
(
5
,
1
)
==
5
topo
=
f
.
maker
.
fgraph
.
toposort
()
topo
=
f
.
maker
.
fgraph
.
toposort
()
...
@@ -2827,8 +2828,8 @@ class test_assert(utt.InferShapeTester):
...
@@ -2827,8 +2828,8 @@ class test_assert(utt.InferShapeTester):
x
=
T
.
scalar
()
x
=
T
.
scalar
()
y
=
T
.
scalar
()
y
=
T
.
scalar
()
f
=
theano
.
function
([
x
,
y
],
theano
.
tensor
.
opt
.
assert_
(
x
,
y
,
f
=
theano
.
function
([
x
,
y
],
theano
.
tensor
.
opt
.
assert_
(
x
,
y
,
0
),
0
),
mode
=
mode
)
mode
=
mode
)
self
.
assertRaises
(
AssertionError
,
f
,
1
,
0
)
self
.
assertRaises
(
AssertionError
,
f
,
1
,
0
)
topo
=
f
.
maker
.
fgraph
.
toposort
()
topo
=
f
.
maker
.
fgraph
.
toposort
()
assert
len
(
topo
)
==
2
assert
len
(
topo
)
==
2
...
@@ -3177,8 +3178,9 @@ def test_constant_get_stabilized():
...
@@ -3177,8 +3178,9 @@ def test_constant_get_stabilized():
class
T_local_switch_sink
(
unittest
.
TestCase
):
class
T_local_switch_sink
(
unittest
.
TestCase
):
def
setUp
(
self
):
def
setUp
(
self
):
# condition values
# condition values
self
.
condm
=
numpy
.
asarray
([[
0.1
,
0
,
1
,
-
1
],
[
0.
,
0.
,
0.
,
self
.
condm
=
numpy
.
asarray
([[
0.1
,
0
,
1
,
-
1
],
0.
],
[
1
,
1
,
1
,
1
]])
[
0.
,
0.
,
0.
,
0.
],
[
1
,
1
,
1
,
1
]])
self
.
condv
=
numpy
.
asarray
([
0.1
,
0
,
1
,
-
1
])
self
.
condv
=
numpy
.
asarray
([
0.1
,
0
,
1
,
-
1
])
self
.
conds
=
[
0.1
,
0
,
1
,
-
1
]
self
.
conds
=
[
0.1
,
0
,
1
,
-
1
]
...
@@ -3256,14 +3258,14 @@ class T_local_erf(unittest.TestCase):
...
@@ -3256,14 +3258,14 @@ class T_local_erf(unittest.TestCase):
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
()
print
f
.
maker
.
fgraph
.
toposort
()
assert
[
n
.
op
for
n
in
f
.
maker
.
fgraph
.
toposort
()]
==
[
T
.
mul
,
T
.
assert
[
n
.
op
for
n
in
f
.
maker
.
fgraph
.
toposort
()]
==
[
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
()
print
f
.
maker
.
fgraph
.
toposort
()
assert
[
n
.
op
for
n
in
f
.
maker
.
fgraph
.
toposort
()]
==
[
T
.
mul
,
T
.
assert
[
n
.
op
for
n
in
f
.
maker
.
fgraph
.
toposort
()]
==
[
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
)
...
@@ -3305,7 +3307,7 @@ class T_local_erf(unittest.TestCase):
...
@@ -3305,7 +3307,7 @@ class T_local_erf(unittest.TestCase):
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
()
assert
isinstance
(
topo
[
1
]
.
op
.
scalar_op
,
scal
.
Add
)
\
assert
isinstance
(
topo
[
1
]
.
op
.
scalar_op
,
scal
.
Add
)
\
or
isinstance
(
topo
[
1
]
.
op
.
scalar_op
,
scal
.
Sub
),
f
.
maker
.
fgraph
.
toposort
()
or
isinstance
(
topo
[
1
]
.
op
.
scalar_op
,
scal
.
Sub
),
f
.
maker
.
fgraph
.
toposort
()
print
f
(
val
)
print
f
(
val
)
def
test_local_erf_minus_one
(
self
):
def
test_local_erf_minus_one
(
self
):
...
@@ -3345,7 +3347,8 @@ class T_local_erfc(unittest.TestCase):
...
@@ -3345,7 +3347,8 @@ class T_local_erfc(unittest.TestCase):
'canonicalize'
)
.
including
(
'fast_run'
)
.
excluding
(
'gpu'
)
'canonicalize'
)
.
including
(
'fast_run'
)
.
excluding
(
'gpu'
)
self
.
mode
=
self
.
mode_fusion
.
excluding
(
'fusion'
)
self
.
mode
=
self
.
mode_fusion
.
excluding
(
'fusion'
)
self
.
mode
.
_optimizer
.
position_cutoff
=
1.50001
self
.
mode
.
_optimizer
.
position_cutoff
=
1.50001
if
theano
.
config
.
cxx
==
''
and
not
theano
.
scalar
.
basic_scipy
.
imported_scipy_special
:
if
(
theano
.
config
.
cxx
==
''
and
not
theano
.
scalar
.
basic_scipy
.
imported_scipy_special
):
raise
SkipTest
(
"erfc need a c++ compiler or scipy"
)
raise
SkipTest
(
"erfc need a c++ compiler or scipy"
)
def
test_local_one_minus_erfc
(
self
):
def
test_local_one_minus_erfc
(
self
):
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论