Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
62e82051
提交
62e82051
authored
2月 20, 2013
作者:
abalkin
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Issue #783: python3 compatible - more test fixed.
上级
6213cb92
隐藏空白字符变更
内嵌
并排
正在显示
7 个修改的文件
包含
42 行增加
和
22 行删除
+42
-22
sched.py
theano/gof/sched.py
+5
-1
rng_mrg.py
theano/sandbox/rng_mrg.py
+2
-2
basic.py
theano/tensor/basic.py
+1
-1
conv.py
theano/tensor/nnet/conv.py
+6
-5
test_blas.py
theano/tensor/tests/test_blas.py
+23
-8
disturb_mem.py
theano/tests/disturb_mem.py
+1
-1
test_tutorial.py
theano/tests/test_tutorial.py
+4
-4
没有找到文件。
theano/gof/sched.py
浏览文件 @
62e82051
from
theano.gof.graph
import
list_of_nodes
from
theano.gof.python25
import
any
,
defaultdict
try
:
cmp
except
NameError
:
def
cmp
(
a
,
b
):
return
(
a
>
b
)
-
(
a
<
b
)
## {{{ http://code.activestate.com/recipes/578231/ (r1)
# Copyright (c) Oren Tirosh 2012
...
...
theano/sandbox/rng_mrg.py
浏览文件 @
62e82051
...
...
@@ -615,7 +615,7 @@ def guess_n_streams(size, warn=True):
for
s
in
size
:
r
*=
s
if
r
>
6
:
r
=
r
/
6
# chosen as fastest for rbm_benchmark
r
=
r
/
/
6
# chosen as fastest for rbm_benchmark
# The purpose of sampling from many streams is to be able to use
# the GPU to its full capacity. It just wastes RAM and stream-initialization time to
...
...
@@ -741,7 +741,7 @@ class MRG_RandomStreams(object):
if
isinstance
(
size
,
tuple
):
msg
=
"size must be a tuple of int or a Theano variable"
assert
all
([
isinstance
(
i
,
int
)
or
isinstance
(
i
,
Variable
)
assert
all
([
isinstance
(
i
,
(
numpy
.
integer
,
int
)
)
or
isinstance
(
i
,
Variable
)
for
i
in
size
]),
msg
if
any
([
isinstance
(
i
,
int
)
and
i
<=
0
for
i
in
size
]):
raise
ValueError
(
...
...
theano/tensor/basic.py
浏览文件 @
62e82051
...
...
@@ -4670,7 +4670,7 @@ class Subtensor(Op):
return
pos
[
1
]
def
init_entry
(
entry
,
depth
=
0
):
if
isinstance
(
entry
,
int
):
if
isinstance
(
entry
,
(
numpy
.
integer
,
int
)
):
init_cmds
.
append
(
"subtensor_spec[
%
i] =
%
i;"
%
(
spec_pos
(),
entry
))
...
...
theano/tensor/nnet/conv.py
浏览文件 @
62e82051
...
...
@@ -354,7 +354,7 @@ class ConvOp(OpenMPOp):
all_shape
=
imshp
is
not
None
and
kshp
is
not
None
and
\
nkern
is
not
None
and
bsize
is
not
None
if
(
unroll_batch
>
0
or
unroll_kern
>
0
)
and
not
all_shape
:
if
(
unroll_batch
or
unroll_kern
)
and
not
all_shape
:
raise
Exception
(
"In ConvOp, when using unroll_batch and"
" unroll_nkern, all shape are needed"
)
...
...
@@ -409,8 +409,8 @@ class ConvOp(OpenMPOp):
if
self
.
unroll_kern
and
not
self
.
unroll_batch
:
self
.
unroll_batch
=
1
#downcast unroll_batch if not a divisor of batch size
if
self
.
unroll_batch
>
0
and
self
.
bsize
%
self
.
unroll_batch
!=
0
:
#
downcast unroll_batch if not a divisor of batch size
if
self
.
unroll_batch
is
not
None
and
self
.
unroll_batch
>
0
and
self
.
bsize
%
self
.
unroll_batch
!=
0
:
if
self
.
bsize
<=
self
.
unroll_batch
:
self
.
unroll_batch
=
self
.
bsize
...
...
@@ -430,7 +430,7 @@ class ConvOp(OpenMPOp):
self
.
unroll_batch
=
new
#downcast unroll_kern if not a divisor of nb of kernel
if
self
.
unroll_kern
>
0
and
self
.
nkern
%
self
.
unroll_kern
!=
0
:
if
self
.
unroll_kern
is
not
None
and
self
.
unroll_kern
>
0
and
self
.
nkern
%
self
.
unroll_kern
!=
0
:
if
self
.
nkern
<=
self
.
unroll_kern
:
self
.
unroll_kern
=
self
.
nkern
...
...
@@ -1217,7 +1217,8 @@ if(kerns_dim[3] %% %(self_kshp1)s!=0){
_logger
.
debug
(
"return unroll patch version. all_shape=
%
s"
,
all_shape
)
return
_conv_op_code_unroll_patch
%
d
if
self
.
unroll_batch
>
0
or
self
.
unroll_kern
>
0
:
if
((
self
.
unroll_batch
is
not
None
and
self
.
unroll_batch
>
0
)
or
(
self
.
unroll_kern
is
not
None
and
self
.
unroll_kern
>
0
)):
assert
self
.
unroll_batch
>
0
assert
self
.
unroll_kern
>
0
if
self
.
verbose
:
...
...
theano/tensor/tests/test_blas.py
浏览文件 @
62e82051
...
...
@@ -2,6 +2,21 @@
#import traceback
import
itertools
import
sys
# Copied from tensor/tests/test_basic.py.
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
]
import
theano.tensor
as
T
from
theano
import
tensor
from
theano.gof.python25
import
product
as
itertools_product
...
...
@@ -112,7 +127,7 @@ class t_gemm(TestCase):
try
:
g
=
gemm_inplace
([
1.
],
1.
,
[
1.
],
[
1.
],
1.
)
except
TypeError
,
e
:
if
e
[
0
]
is
Gemm
.
E_rank
:
if
e
xc_message
(
e
)
is
Gemm
.
E_rank
:
return
self
.
fail
()
...
...
@@ -120,7 +135,7 @@ class t_gemm(TestCase):
try
:
self
.
cmp
(
1.
,
0.
,
1.0
,
1.0
,
1.0
)
except
TypeError
,
e
:
if
e
[
0
]
is
Gemm
.
E_rank
:
if
e
xc_message
(
e
)
is
Gemm
.
E_rank
:
return
self
.
fail
()
...
...
@@ -128,7 +143,7 @@ class t_gemm(TestCase):
try
:
self
.
cmp
(
2.
,
1.0
,
[
3
,
2
,
1.
],
[[
1
],
[
2
],
[
3.
]],
1.0
)
except
TypeError
,
e
:
self
.
assertTrue
(
e
[
0
]
==
Gemm
.
E_rank
)
self
.
assertTrue
(
e
xc_message
(
e
)
==
Gemm
.
E_rank
)
return
self
.
fail
()
...
...
@@ -220,7 +235,7 @@ class t_gemm(TestCase):
try
:
gemm_inplace
(
Z
,
1.0
,
Z
,
Z
,
1.0
)
except
InconsistencyError
,
e
:
if
e
[
0
]
==
Gemm
.
E_z_uniq
:
if
e
xc_message
(
e
)
==
Gemm
.
E_z_uniq
:
return
self
.
fail
()
...
...
@@ -231,7 +246,7 @@ class t_gemm(TestCase):
try
:
gemm_inplace
(
Z
,
1.0
,
A
,
inplace
.
transpose_inplace
(
Z
),
1.0
)
except
InconsistencyError
,
e
:
if
e
[
0
]
==
Gemm
.
E_z_uniq
:
if
e
xc_message
(
e
)
==
Gemm
.
E_z_uniq
:
return
self
.
fail
()
...
...
@@ -242,7 +257,7 @@ class t_gemm(TestCase):
try
:
gemm_inplace
(
Z
,
1.0
,
inplace
.
transpose_inplace
(
Z
),
A
,
1.0
)
except
InconsistencyError
,
e
:
if
e
[
0
]
==
Gemm
.
E_z_uniq
:
if
e
xc_message
(
e
)
==
Gemm
.
E_z_uniq
:
return
self
.
fail
()
...
...
@@ -253,7 +268,7 @@ class t_gemm(TestCase):
try
:
gemm_inplace
(
Z
,
1.0
,
Z
,
A
,
1.0
)
except
InconsistencyError
,
e
:
if
e
[
0
]
==
Gemm
.
E_z_uniq
:
if
e
xc_message
(
e
)
==
Gemm
.
E_z_uniq
:
return
self
.
fail
()
...
...
@@ -325,7 +340,7 @@ class t_gemm(TestCase):
try
:
t
(
C
.
T
,
A
[:
2
,
:],
B
[:,
:
2
]
.
T
)
except
ValueError
,
e
:
if
e
[
0
]
.
find
(
'aligned'
)
>=
0
:
if
e
xc_message
(
e
)
.
find
(
'aligned'
)
>=
0
:
return
self
.
fail
()
...
...
theano/tests/disturb_mem.py
浏览文件 @
62e82051
...
...
@@ -17,5 +17,5 @@ def disturb_mem():
ms
=
now
.
microsecond
ms
=
int
(
ms
)
n
=
ms
%
1000
m
=
ms
/
1000
m
=
ms
/
/
1000
l
=
[[
0
]
*
m
for
i
in
xrange
(
n
)]
theano/tests/test_tutorial.py
浏览文件 @
62e82051
...
...
@@ -732,12 +732,12 @@ class T_loading_and_saving(unittest.TestCase):
tmpdir
=
mkdtemp
()
os
.
chdir
(
tmpdir
)
f
=
file
(
'obj.save'
,
'wb'
)
f
=
open
(
'obj.save'
,
'wb'
)
cPickle
.
dump
(
my_obj
,
f
,
protocol
=
cPickle
.
HIGHEST_PROTOCOL
)
f
.
close
()
f
=
file
(
'obj.save'
,
'rb'
)
f
=
open
(
'obj.save'
,
'rb'
)
loaded_obj
=
cPickle
.
load
(
f
)
f
.
close
()
...
...
@@ -745,12 +745,12 @@ class T_loading_and_saving(unittest.TestCase):
obj2
=
my_obj
obj3
=
my_obj
f
=
file
(
'objects.save'
,
'wb'
)
f
=
open
(
'objects.save'
,
'wb'
)
for
obj
in
[
obj1
,
obj2
,
obj3
]:
cPickle
.
dump
(
obj
,
f
,
protocol
=
cPickle
.
HIGHEST_PROTOCOL
)
f
.
close
()
f
=
file
(
'objects.save'
,
'rb'
)
f
=
open
(
'objects.save'
,
'rb'
)
loaded_objects
=
[]
for
i
in
range
(
3
):
loaded_objects
.
append
(
cPickle
.
load
(
f
))
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论