Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
19ec1bfd
提交
19ec1bfd
authored
2月 21, 2013
作者:
abalkin
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Issue #783: python3 compatible - fixed remaining test failures.
Python 3 port now passes default "theano-nose" tests under pythobn 3.2.
上级
c4441bd4
隐藏空白字符变更
内嵌
并排
正在显示
5 个修改的文件
包含
48 行增加
和
16 行删除
+48
-16
test_optdb.py
theano/gof/tests/test_optdb.py
+16
-3
test_sched.py
theano/gof/tests/test_sched.py
+5
-0
rng_mrg.py
theano/sandbox/rng_mrg.py
+2
-2
test_sp.py
theano/sparse/sandbox/test_sp.py
+6
-5
test_basic.py
theano/sparse/tests/test_basic.py
+19
-6
没有找到文件。
theano/gof/tests/test_optdb.py
浏览文件 @
19ec1bfd
from
unittest
import
TestCase
from
unittest
import
TestCase
from
six
import
PY3
if
PY3
:
# In python 3.x, when an exception is reraised it saves original
# exception in its args, therefore in order to find the actual
# message, we need to unpack arguments recurcively.
def
exc_message
(
e
):
msg
=
e
.
args
[
0
]
if
isinstance
(
msg
,
Exception
):
return
exc_message
(
msg
)
return
msg
else
:
def
exc_message
(
e
):
return
e
[
0
]
from
theano.gof.optdb
import
opt
,
DB
from
theano.gof.optdb
import
opt
,
DB
...
@@ -21,7 +34,7 @@ class Test_DB(TestCase):
...
@@ -21,7 +34,7 @@ class Test_DB(TestCase):
db
.
register
(
'c'
,
Opt
())
# name taken
db
.
register
(
'c'
,
Opt
())
# name taken
self
.
fail
()
self
.
fail
()
except
ValueError
,
e
:
except
ValueError
,
e
:
if
e
[
0
]
.
startswith
(
"The name"
):
if
e
xc_message
(
e
)
.
startswith
(
"The name"
):
pass
pass
else
:
else
:
raise
raise
...
@@ -32,7 +45,7 @@ class Test_DB(TestCase):
...
@@ -32,7 +45,7 @@ class Test_DB(TestCase):
db
.
register
(
'z'
,
Opt
())
# name collides with tag
db
.
register
(
'z'
,
Opt
())
# name collides with tag
self
.
fail
()
self
.
fail
()
except
ValueError
,
e
:
except
ValueError
,
e
:
if
e
[
0
]
.
startswith
(
"The name"
):
if
e
xc_message
(
e
)
.
startswith
(
"The name"
):
pass
pass
else
:
else
:
raise
raise
...
@@ -43,7 +56,7 @@ class Test_DB(TestCase):
...
@@ -43,7 +56,7 @@ class Test_DB(TestCase):
db
.
register
(
'u'
,
Opt
(),
'b'
)
# name new but tag collides with name
db
.
register
(
'u'
,
Opt
(),
'b'
)
# name new but tag collides with name
self
.
fail
()
self
.
fail
()
except
ValueError
,
e
:
except
ValueError
,
e
:
if
e
[
0
]
.
startswith
(
"The tag"
):
if
e
xc_message
(
e
)
.
startswith
(
"The tag"
):
pass
pass
else
:
else
:
raise
raise
...
...
theano/gof/tests/test_sched.py
浏览文件 @
19ec1bfd
...
@@ -5,6 +5,11 @@ import theano
...
@@ -5,6 +5,11 @@ import theano
from
theano
import
tensor
from
theano
import
tensor
from
theano.gof.graph
import
io_toposort
from
theano.gof.graph
import
io_toposort
from
theano.gof.python25
import
any
from
theano.gof.python25
import
any
try
:
cmp
except
NameError
:
def
cmp
(
a
,
b
):
return
(
a
>
b
)
-
(
a
<
b
)
def
test_dependence
():
def
test_dependence
():
...
...
theano/sandbox/rng_mrg.py
浏览文件 @
19ec1bfd
...
@@ -743,7 +743,7 @@ class MRG_RandomStreams(object):
...
@@ -743,7 +743,7 @@ class MRG_RandomStreams(object):
msg
=
"size must be a tuple of int or a Theano variable"
msg
=
"size must be a tuple of int or a Theano variable"
assert
all
([
isinstance
(
i
,
(
numpy
.
integer
,
int
))
or
isinstance
(
i
,
Variable
)
assert
all
([
isinstance
(
i
,
(
numpy
.
integer
,
int
))
or
isinstance
(
i
,
Variable
)
for
i
in
size
]),
msg
for
i
in
size
]),
msg
if
any
([
isinstance
(
i
,
int
)
and
i
<=
0
for
i
in
size
]):
if
any
([
isinstance
(
i
,
(
numpy
.
integer
,
int
)
)
and
i
<=
0
for
i
in
size
]):
raise
ValueError
(
raise
ValueError
(
"The specified size contains a dimension with value <= 0"
,
"The specified size contains a dimension with value <= 0"
,
size
)
size
)
...
@@ -873,7 +873,7 @@ class MRG_RandomStreams(object):
...
@@ -873,7 +873,7 @@ class MRG_RandomStreams(object):
evened
=
False
evened
=
False
constant
=
False
constant
=
False
if
isinstance
(
size
,
tuple
)
and
all
([
isinstance
(
i
,
int
)
for
i
in
size
]):
if
isinstance
(
size
,
tuple
)
and
all
([
isinstance
(
i
,
(
numpy
.
integer
,
int
)
)
for
i
in
size
]):
constant
=
True
constant
=
True
n_samples
=
numpy
.
prod
(
size
)
n_samples
=
numpy
.
prod
(
size
)
...
...
theano/sparse/sandbox/test_sp.py
浏览文件 @
19ec1bfd
...
@@ -2,6 +2,7 @@ from nose.plugins.skip import SkipTest
...
@@ -2,6 +2,7 @@ from nose.plugins.skip import SkipTest
import
sys
import
sys
import
time
import
time
import
unittest
import
unittest
from
six
import
next
import
theano.sparse
import
theano.sparse
if
not
theano
.
sparse
.
enable_sparse
:
if
not
theano
.
sparse
.
enable_sparse
:
...
@@ -63,7 +64,7 @@ class TestSP(unittest.TestCase):
...
@@ -63,7 +64,7 @@ class TestSP(unittest.TestCase):
it
=
reversed
(
filters
[
k
,
:])
it
=
reversed
(
filters
[
k
,
:])
for
i
in
range
(
kshp
[
0
]):
for
i
in
range
(
kshp
[
0
]):
for
j
in
range
(
kshp
[
1
]):
for
j
in
range
(
kshp
[
1
]):
filtersflipped
[
k
,
i
,
j
]
=
it
.
next
(
)
filtersflipped
[
k
,
i
,
j
]
=
next
(
it
)
# compute output with convolve2d
# compute output with convolve2d
if
conv_mode
==
'valid'
:
if
conv_mode
==
'valid'
:
...
@@ -314,14 +315,14 @@ class TestSP(unittest.TestCase):
...
@@ -314,14 +315,14 @@ class TestSP(unittest.TestCase):
# numeric verification
# numeric verification
my_output_val
=
numpy
.
zeros
((
imval
.
shape
[
0
],
imval
.
shape
[
1
],
my_output_val
=
numpy
.
zeros
((
imval
.
shape
[
0
],
imval
.
shape
[
1
],
imval
.
shape
[
2
]
/
maxpoolshp
[
0
],
imval
.
shape
[
2
]
//
maxpoolshp
[
0
],
imval
.
shape
[
3
]
/
maxpoolshp
[
1
]))
imval
.
shape
[
3
]
//
maxpoolshp
[
1
]))
assert
numpy
.
prod
(
my_output_val
.
shape
[
1
:])
==
numpy
.
prod
(
numpy
.
r_
[
imval
.
shape
[
1
],
outshp
])
assert
numpy
.
prod
(
my_output_val
.
shape
[
1
:])
==
numpy
.
prod
(
numpy
.
r_
[
imval
.
shape
[
1
],
outshp
])
for
n
in
range
(
imval
.
shape
[
0
]):
for
n
in
range
(
imval
.
shape
[
0
]):
for
k
in
range
(
imval
.
shape
[
1
]):
for
k
in
range
(
imval
.
shape
[
1
]):
for
i
in
range
(
imval
.
shape
[
2
]
/
maxpoolshp
[
0
]):
for
i
in
range
(
imval
.
shape
[
2
]
//
maxpoolshp
[
0
]):
for
j
in
range
(
imval
.
shape
[
3
]
/
maxpoolshp
[
1
]):
for
j
in
range
(
imval
.
shape
[
3
]
//
maxpoolshp
[
1
]):
ii
,
jj
=
i
*
maxpoolshp
[
0
],
j
*
maxpoolshp
[
1
]
ii
,
jj
=
i
*
maxpoolshp
[
0
],
j
*
maxpoolshp
[
1
]
patch
=
imval
[
n
,
k
,
ii
:
ii
+
maxpoolshp
[
0
],
jj
:
jj
+
maxpoolshp
[
1
]]
patch
=
imval
[
n
,
k
,
ii
:
ii
+
maxpoolshp
[
0
],
jj
:
jj
+
maxpoolshp
[
1
]]
my_output_val
[
n
,
k
,
i
,
j
]
=
numpy
.
max
(
patch
)
my_output_val
[
n
,
k
,
i
,
j
]
=
numpy
.
max
(
patch
)
...
...
theano/sparse/tests/test_basic.py
浏览文件 @
19ec1bfd
...
@@ -1774,6 +1774,15 @@ class Remove0Tester(utt.InferShapeTester):
...
@@ -1774,6 +1774,15 @@ class Remove0Tester(utt.InferShapeTester):
# list of apply nodes in the optimized graph.
# list of apply nodes in the optimized graph.
nodes
=
f
.
maker
.
fgraph
.
toposort
()
nodes
=
f
.
maker
.
fgraph
.
toposort
()
v
=
[
True
for
node
in
nodes
]
v
=
[
True
for
node
in
nodes
]
# In python 3, list comprehention variables do not leak
# in the outside scope, so we bind node varible below
# to make the code behave the same under all
# versions. However, the logic here does not look
# right: the length of v is always the same as that of
# nodes and the only result of the assert is to check
# that nodes is not empty. The intent was probably to
# keep if clause inside the [] and check every node.
node
=
nodes
[
-
1
]
if
isinstance
(
node
.
op
,
Remove0
)
and
node
.
op
.
inplace
:
if
isinstance
(
node
.
op
,
Remove0
)
and
node
.
op
.
inplace
:
assert
len
(
v
),
\
assert
len
(
v
),
\
'Inplacing optimization should have been applied.'
'Inplacing optimization should have been applied.'
...
@@ -2060,12 +2069,7 @@ class CastTester(utt.InferShapeTester):
...
@@ -2060,12 +2069,7 @@ class CastTester(utt.InferShapeTester):
verify_grad_sparse
(
Cast
(
o_dtype
),
data
,
eps
=
eps
)
verify_grad_sparse
(
Cast
(
o_dtype
),
data
,
eps
=
eps
)
def
_format_info
(
nb
):
class
_HVStackTester
(
utt
.
InferShapeTester
):
"""Test for both HStack and VStack.
"""
nb
=
3
# Number of sparse matrix to stack
x
=
{}
x
=
{}
mat
=
{}
mat
=
{}
...
@@ -2077,6 +2081,15 @@ class _HVStackTester(utt.InferShapeTester):
...
@@ -2077,6 +2081,15 @@ class _HVStackTester(utt.InferShapeTester):
mat
[
format
]
=
[
spa
(
numpy
.
random
.
random_integers
(
5
,
size
=
(
3
,
4
))
-
1
,
mat
[
format
]
=
[
spa
(
numpy
.
random
.
random_integers
(
5
,
size
=
(
3
,
4
))
-
1
,
dtype
=
theano
.
config
.
floatX
)
dtype
=
theano
.
config
.
floatX
)
for
t
in
range
(
nb
)]
for
t
in
range
(
nb
)]
return
x
,
mat
class
_HVStackTester
(
utt
.
InferShapeTester
):
"""Test for both HStack and VStack.
"""
nb
=
3
# Number of sparse matrix to stack
x
,
mat
=
_format_info
(
nb
)
def
test_op
(
self
):
def
test_op
(
self
):
for
format
in
sparse
.
sparse_formats
:
for
format
in
sparse
.
sparse_formats
:
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论