Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
201b8102
提交
201b8102
authored
9月 11, 2012
作者:
Ian Goodfellow
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fixed a bunch more things autopep8 broke
上级
3c015aca
隐藏空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
46 行增加
和
46 行删除
+46
-46
test_basic.py
theano/tensor/tests/test_basic.py
+12
-12
test_opt.py
theano/tensor/tests/test_opt.py
+34
-34
没有找到文件。
theano/tensor/tests/test_basic.py
浏览文件 @
201b8102
...
...
@@ -4960,8 +4960,8 @@ class TestARange(unittest.TestCase):
assert
arange
(
iscalar
(),
dscalar
())
.
dtype
==
dscalar
()
.
dtype
assert
arange
(
fscalar
(),
dscalar
())
.
dtype
==
dscalar
()
.
dtype
assert
arange
(
iscalar
(),
fscalar
(),
dscalar
())
.
dtype
==
dscalar
()
.
dtype
assert
arange
(
iscalar
(),
fscalar
(),
dscalar
())
.
dtype
==
\
dscalar
()
.
dtype
elif
config
.
cast_policy
in
(
'numpy'
,
'numpy+floatX'
):
for
dtype
in
get_numeric_types
():
# Test with a single argument.
...
...
@@ -5612,10 +5612,10 @@ def _test_autocast_custom():
ac
.
__enter__
()
assert
(
dvector
()
+
1.1
)
.
dtype
==
'float64'
assert
(
fvector
()
+
1.1
)
.
dtype
==
'float32'
assert
(
fvector
()
+
theano
.
_asarray
(
1.1
,
dtype
=
'float64'
))
.
dtype
==
'float64'
assert
(
fvector
()
+
theano
.
_asarray
(
1.1
,
dtype
=
'float32'
))
.
dtype
==
'float32'
assert
(
fvector
()
+
theano
.
_asarray
(
1.1
,
dtype
=
'float64'
))
.
dtype
==
\
'float64'
assert
(
fvector
()
+
theano
.
_asarray
(
1.1
,
dtype
=
'float32'
))
.
dtype
==
\
'float32'
assert
(
dvector
()
+
1
)
.
dtype
==
'float64'
assert
(
fvector
()
+
1
)
.
dtype
==
'float32'
...
...
@@ -5629,10 +5629,10 @@ def _test_autocast_custom():
assert
(
dvector
()
+
1.1
)
.
dtype
==
'float64'
assert
(
fvector
()
+
1.1
)
.
dtype
==
'float64'
assert
(
fvector
()
+
1.0
)
.
dtype
==
'float64'
assert
(
fvector
()
+
theano
.
_asarray
(
1.1
,
dtype
=
'float64'
))
.
dtype
==
'float64'
assert
(
fvector
()
+
theano
.
_asarray
(
1.1
,
dtype
=
'float32'
))
.
dtype
==
'float32'
assert
(
fvector
()
+
theano
.
_asarray
(
1.1
,
dtype
=
'float64'
))
.
dtype
==
\
'float64'
assert
(
fvector
()
+
theano
.
_asarray
(
1.1
,
dtype
=
'float32'
))
.
dtype
==
\
'float32'
assert
(
dvector
()
+
1
)
.
dtype
==
'float64'
assert
(
fvector
()
+
1
)
.
dtype
==
'float32'
...
...
@@ -5981,8 +5981,8 @@ def test_mod():
as Python. That is what we want.
"""
x
,
y
=
fscalars
(
'xy'
)
fn
=
gof
.
DualLinker
()
.
accept
(
gof
.
FunctionGraph
([
x
,
y
],
[
x
%
y
]))
.
make_function
()
fn
=
gof
.
DualLinker
()
.
accept
(
gof
.
FunctionGraph
([
x
,
y
],
[
x
%
y
]))
.
make_function
()
for
a
,
b
in
((
0
,
1
),
(
1
,
1
),
(
0
,
-
1
),
(
1
,
-
1
),
(
-
1
,
-
1
),
(
1
,
2
),
(
-
1
,
2
),
(
1
,
-
2
),
(
-
1
,
-
2
),
(
5
,
3
),
(
-
5
,
3
),
(
5
,
-
3
),
(
-
5
,
-
3
)
...
...
theano/tensor/tests/test_opt.py
浏览文件 @
201b8102
...
...
@@ -631,11 +631,11 @@ class test_canonize(unittest.TestCase):
a
=
T
.
abs_
(
x
)
if
theano
.
config
.
mode
==
'FAST_COMPILE'
:
mode
=
theano
.
compile
.
mode
.
get_mode
(
'FAST_RUN'
)
.
excluding
(
"local_elemwise_fusion"
)
mode
=
theano
.
compile
.
mode
.
get_mode
(
'FAST_RUN'
)
.
excluding
(
"local_elemwise_fusion"
)
else
:
mode
=
theano
.
compile
.
mode
.
get_default_mode
()
.
excluding
(
"local_elemwise_fusion"
)
mode
=
theano
.
compile
.
mode
.
get_default_mode
()
.
excluding
(
"local_elemwise_fusion"
)
f
=
theano
.
function
([
x
],
[(
4
*
x
)
/
abs
(
2
*
x
)],
mode
=
mode
)
print
f
.
maker
.
fgraph
.
toposort
()
...
...
@@ -1106,11 +1106,11 @@ class test_fusion(unittest.TestCase):
shp
=
(
5
,
5
)
#we need the optimisation enabled, debug do this.
if
theano
.
config
.
mode
==
"FAST_COMPILE"
:
mode
=
theano
.
compile
.
mode
.
get_mode
(
"FAST_RUN"
)
.
including
(
'local_elemwise_fusion'
,
'canonicalize'
,
'gpu'
)
mode
=
theano
.
compile
.
mode
.
get_mode
(
"FAST_RUN"
)
.
including
(
'local_elemwise_fusion'
,
'canonicalize'
,
'gpu'
)
else
:
mode
=
theano
.
compile
.
mode
.
get_default_mode
()
.
including
(
'local_elemwise_fusion'
,
'canonicalize'
,
'gpu'
)
mode
=
theano
.
compile
.
mode
.
get_default_mode
()
.
including
(
'local_elemwise_fusion'
,
'canonicalize'
,
'gpu'
)
import
theano.sandbox.cuda
as
cuda
if
not
cuda
.
cuda_available
:
raise
SkipTest
(
"cuda not available"
)
...
...
@@ -1120,11 +1120,11 @@ class test_fusion(unittest.TestCase):
def
test_gpu_fusion_Xd
(
self
):
#we need the optimisation enabled, debug do this.
if
theano
.
config
.
mode
==
"FAST_COMPILE"
:
mode
=
theano
.
compile
.
mode
.
get_mode
(
"FAST_RUN"
)
.
including
(
'local_elemwise_fusion'
,
'canonicalize'
,
'gpu'
)
mode
=
theano
.
compile
.
mode
.
get_mode
(
"FAST_RUN"
)
.
including
(
'local_elemwise_fusion'
,
'canonicalize'
,
'gpu'
)
else
:
mode
=
theano
.
compile
.
mode
.
get_default_mode
()
.
including
(
'local_elemwise_fusion'
,
'canonicalize'
,
'gpu'
)
mode
=
theano
.
compile
.
mode
.
get_default_mode
()
.
including
(
'local_elemwise_fusion'
,
'canonicalize'
,
'gpu'
)
import
theano.sandbox.cuda
as
cuda
if
not
cuda
.
cuda_available
:
raise
SkipTest
(
"cuda not available"
)
...
...
@@ -1166,7 +1166,7 @@ class test_fusion(unittest.TestCase):
print
"times2/times1"
print
d
print
"min"
,
d
.
min
(),
"argmin"
,
d
.
argmin
(),
"max"
,
d
.
max
(),
print
"min"
,
d
.
min
(),
"argmin"
,
d
.
argmin
(),
"max"
,
d
.
max
(),
\
"mean"
,
d
.
mean
(),
"std"
,
d
.
std
()
def
test_fusion_inplace
(
self
):
...
...
@@ -1272,8 +1272,8 @@ class test_fusion(unittest.TestCase):
for
x
in
ndl
:
cmp
=
not
isinstance
(
x
,
list
)
if
not
cmp
and
x
:
cmp
=
x
[
0
]
.
__class__
.
__name__
!=
'array_converter'
cmp
=
x
[
0
]
.
__class__
.
__name__
!=
\
'array_converter'
if
cmp
:
cmp
=
x
[
0
]
!=
'Option'
if
cmp
:
...
...
@@ -2946,8 +2946,8 @@ def test_constant_get_stabilized():
f2
=
theano
.
function
([
x2
],
y2
)
try
:
assert
len
(
f2
.
maker
.
fgraph
.
toposort
())
==
1
assert
f2
.
maker
.
fgraph
.
toposort
()[
0
]
.
op
==
theano
.
tensor
.
nnet
.
sigm
.
softplus
assert
f2
.
maker
.
fgraph
.
toposort
()[
0
]
.
op
==
\
theano
.
tensor
.
nnet
.
sigm
.
softplus
assert
f2
(
800
)
==
800
x
=
T
.
as_tensor_variable
(
800
)
...
...
@@ -2985,8 +2985,8 @@ class T_local_switch_sink(unittest.TestCase):
[[
numpy
.
asarray
(
1.0
),
numpy
.
asarray
(
0.0
),
numpy
.
asarray
(
1.0
),
numpy
.
asarray
(
0.0
)]]
self
.
mode
=
theano
.
compile
.
mode
.
get_default_mode
()
.
including
(
'canonicalize'
,
'fast_run'
)
.
excluding
(
'gpu'
,
'fusion'
)
self
.
mode
=
theano
.
compile
.
mode
.
get_default_mode
()
.
including
(
'canonicalize'
,
'fast_run'
)
.
excluding
(
'gpu'
,
'fusion'
)
self
.
mode
=
copy
.
copy
(
self
.
mode
)
self
.
mode
.
check_isfinite
=
False
...
...
@@ -3033,8 +3033,8 @@ class T_local_switch_sink(unittest.TestCase):
class
T_local_erf
(
unittest
.
TestCase
):
def
setUp
(
self
):
self
.
mode
=
theano
.
compile
.
mode
.
get_default_mode
()
.
including
(
'canonicalize'
,
'fast_run'
)
.
excluding
(
'gpu'
,
'fusion'
)
self
.
mode
=
theano
.
compile
.
mode
.
get_default_mode
()
.
including
(
'canonicalize'
,
'fast_run'
)
.
excluding
(
'gpu'
,
'fusion'
)
self
.
mode
.
_optimizer
.
position_cutoff
=
1.50001
def
test_local_one_plus_erf
(
self
):
...
...
@@ -3070,19 +3070,19 @@ class T_local_erf(unittest.TestCase):
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
()
print
f
(
val
)
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
()
print
f
(
val
)
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
()
print
f
(
val
)
...
...
@@ -3092,7 +3092,7 @@ class T_local_erf(unittest.TestCase):
assert
len
(
topo
)
==
2
,
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
.
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
()
print
f
(
val
)
...
...
@@ -3122,15 +3122,15 @@ class T_local_erf(unittest.TestCase):
assert
len
(
topo
)
==
2
assert
topo
[
0
]
.
op
==
T
.
erf
assert
isinstance
(
topo
[
1
]
.
op
,
T
.
Elemwise
)
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
)
print
f
(
val
)
class
T_local_erfc
(
unittest
.
TestCase
):
def
setUp
(
self
):
self
.
mode_fusion
=
theano
.
compile
.
mode
.
get_default_mode
()
.
including
(
'canonicalize'
)
.
including
(
'fast_run'
)
.
excluding
(
'gpu'
)
self
.
mode_fusion
=
theano
.
compile
.
mode
.
get_default_mode
()
.
including
(
'canonicalize'
)
.
including
(
'fast_run'
)
.
excluding
(
'gpu'
)
self
.
mode
=
self
.
mode_fusion
.
excluding
(
'fusion'
)
self
.
mode
.
_optimizer
.
position_cutoff
=
1.50001
...
...
@@ -3143,13 +3143,13 @@ class T_local_erfc(unittest.TestCase):
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
()
print
f
(
val
)
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
()
print
f
(
val
)
...
...
@@ -3159,7 +3159,7 @@ class T_local_erfc(unittest.TestCase):
assert
len
(
topo
)
==
2
,
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
.
scalar_op
,
scal
.
Sub
)
assert
isinstance
(
topo
[
1
]
.
op
.
scalar_op
,
scal
.
Sub
)
\
,
f
.
maker
.
fgraph
.
toposort
()
print
f
(
val
)
...
...
@@ -3171,19 +3171,19 @@ class T_local_erfc(unittest.TestCase):
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
()
print
f
(
val
)
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
()
print
f
(
val
)
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
()
print
f
(
val
)
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论