Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
c9d1922b
提交
c9d1922b
authored
6月 05, 2013
作者:
Frédéric Bastien
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #1403 from HapeMask/py3k-fixes
Py3k Fixes Bugfixes
上级
f0e1111b
2a1142f6
显示空白字符变更
内嵌
并排
正在显示
20 个修改的文件
包含
60 行增加
和
63 行删除
+60
-63
debugmode.py
theano/compile/debugmode.py
+1
-1
test_module.py
theano/compile/tests/test_module.py
+3
-2
configparser.py
theano/configparser.py
+2
-2
cc.py
theano/gof/cc.py
+2
-2
cmodule.py
theano/gof/cmodule.py
+2
-2
opt.py
theano/gof/opt.py
+3
-3
optdb.py
theano/gof/optdb.py
+2
-2
check_whitespace.py
theano/misc/hooks/check_whitespace.py
+1
-1
printing.py
theano/printing.py
+2
-2
basic_ops.py
theano/sandbox/cuda/basic_ops.py
+7
-7
blas.py
theano/sandbox/cuda/blas.py
+4
-4
elemwise.py
theano/sandbox/cuda/elemwise.py
+8
-7
nnet.py
theano/sandbox/cuda/nnet.py
+2
-2
type.py
theano/sandbox/cuda/type.py
+2
-2
opt.py
theano/tensor/opt.py
+2
-3
test_basic.py
theano/tensor/tests/test_basic.py
+5
-5
test_naacl09.py
theano/tensor/tests/test_naacl09.py
+2
-2
test_opt.py
theano/tensor/tests/test_opt.py
+2
-2
test_determinism.py
theano/tests/test_determinism.py
+1
-2
test_printing.py
theano/tests/test_printing.py
+7
-10
没有找到文件。
theano/compile/debugmode.py
浏览文件 @
c9d1922b
...
@@ -7,13 +7,13 @@ __docformat__ = "restructuredtext en"
...
@@ -7,13 +7,13 @@ __docformat__ = "restructuredtext en"
import
copy
,
sys
,
copy_reg
,
gc
import
copy
,
sys
,
copy_reg
,
gc
from
itertools
import
izip
from
itertools
import
izip
from
StringIO
import
StringIO
import
numpy
import
numpy
import
theano
import
theano
from
theano
import
gof
from
theano
import
gof
from
theano.compat
import
get_unbound_function
from
theano.compat
import
get_unbound_function
from
theano.compat.six
import
StringIO
from
theano.gof
import
FunctionGraph
,
graph
,
utils
,
link
,
ops_with_inner_function
from
theano.gof
import
FunctionGraph
,
graph
,
utils
,
link
,
ops_with_inner_function
from
theano.gof.link
import
raise_with_op
from
theano.gof.link
import
raise_with_op
from
theano.gof.cc
import
CLinker
from
theano.gof.cc
import
CLinker
...
...
theano/compile/tests/test_module.py
浏览文件 @
c9d1922b
...
@@ -720,9 +720,10 @@ def test_pickle_aliased_memory():
...
@@ -720,9 +720,10 @@ def test_pickle_aliased_memory():
m
.
x
[
0
,
0
]
=
3.14
m
.
x
[
0
,
0
]
=
3.14
assert
m
.
y
[
0
,
0
]
==
3.14
assert
m
.
y
[
0
,
0
]
==
3.14
import
StringIO
,
logging
import
logging
from
theano.compat.six
import
StringIO
sio
=
StringIO
.
StringIO
()
sio
=
StringIO
()
handler
=
logging
.
StreamHandler
(
sio
)
handler
=
logging
.
StreamHandler
(
sio
)
logging
.
getLogger
(
'theano.compile.function_module'
)
.
addHandler
(
handler
)
logging
.
getLogger
(
'theano.compile.function_module'
)
.
addHandler
(
handler
)
# Silence original handler when intentionnally generating warning messages
# Silence original handler when intentionnally generating warning messages
...
...
theano/configparser.py
浏览文件 @
c9d1922b
...
@@ -7,7 +7,7 @@ import os
...
@@ -7,7 +7,7 @@ import os
import
sys
import
sys
import
warnings
import
warnings
import
StringIO
from
theano.compat.six
import
StringIO
import
theano
import
theano
from
theano.compat
import
configparser
as
ConfigParser
from
theano.compat
import
configparser
as
ConfigParser
...
@@ -150,7 +150,7 @@ class TheanoConfigParser(object):
...
@@ -150,7 +150,7 @@ class TheanoConfigParser(object):
_i_am_a_config_class
=
True
_i_am_a_config_class
=
True
def
__str__
(
self
):
def
__str__
(
self
):
sio
=
StringIO
.
StringIO
()
sio
=
StringIO
()
_config_print
(
self
.
__class__
,
sio
)
_config_print
(
self
.
__class__
,
sio
)
return
sio
.
getvalue
()
return
sio
.
getvalue
()
...
...
theano/gof/cc.py
浏览文件 @
c9d1922b
...
@@ -5,13 +5,13 @@ Defines Linkers that deal with C implementations.
...
@@ -5,13 +5,13 @@ Defines Linkers that deal with C implementations.
# Python imports
# Python imports
from
copy
import
copy
from
copy
import
copy
import
os
import
os
import
StringIO
import
sys
import
sys
from
itertools
import
izip
from
itertools
import
izip
import
numpy
import
numpy
from
theano.compat
import
PY3
from
theano.compat
import
PY3
from
theano.compat.six
import
StringIO
if
PY3
:
if
PY3
:
import
hashlib
import
hashlib
...
@@ -1320,7 +1320,7 @@ class CLinker(link.Linker):
...
@@ -1320,7 +1320,7 @@ class CLinker(link.Linker):
return
ret
return
ret
def
instantiate_code
(
self
,
n_args
):
def
instantiate_code
(
self
,
n_args
):
code
=
StringIO
.
StringIO
()
code
=
StringIO
()
struct_name
=
self
.
struct_name
struct_name
=
self
.
struct_name
print
>>
code
,
"static PyObject * instantiate(PyObject * self, PyObject *argtuple) {"
print
>>
code
,
"static PyObject * instantiate(PyObject * self, PyObject *argtuple) {"
print
>>
code
,
' assert(PyTuple_Check(argtuple));'
print
>>
code
,
' assert(PyTuple_Check(argtuple));'
...
...
theano/gof/cmodule.py
浏览文件 @
c9d1922b
...
@@ -8,7 +8,6 @@ import os
...
@@ -8,7 +8,6 @@ import os
import
re
import
re
import
shutil
import
shutil
import
stat
import
stat
import
StringIO
import
subprocess
import
subprocess
import
sys
import
sys
import
tempfile
import
tempfile
...
@@ -21,6 +20,7 @@ import numpy.distutils # TODO: TensorType should handle this
...
@@ -21,6 +20,7 @@ import numpy.distutils # TODO: TensorType should handle this
import
theano
import
theano
from
theano.compat
import
PY3
,
next
,
decode
,
decode_iter
from
theano.compat
import
PY3
,
next
,
decode
,
decode_iter
from
theano.compat.six
import
StringIO
from
theano.gof.utils
import
flatten
from
theano.gof.utils
import
flatten
from
theano.configparser
import
config
from
theano.configparser
import
config
from
theano.gof.cc
import
hash_from_code
from
theano.gof.cc
import
hash_from_code
...
@@ -196,7 +196,7 @@ static struct PyModuleDef moduledef = {{
...
@@ -196,7 +196,7 @@ static struct PyModuleDef moduledef = {{
self
.
functions
.
append
(
fn
)
self
.
functions
.
append
(
fn
)
def
code
(
self
):
def
code
(
self
):
sio
=
StringIO
.
StringIO
()
sio
=
StringIO
()
for
inc
in
self
.
includes
:
for
inc
in
self
.
includes
:
if
not
inc
:
if
not
inc
:
continue
continue
...
...
theano/gof/opt.py
浏览文件 @
c9d1922b
...
@@ -274,7 +274,7 @@ class SeqOptimizer(Optimizer, list):
...
@@ -274,7 +274,7 @@ class SeqOptimizer(Optimizer, list):
new_sub_profile
.
append
(
None
)
new_sub_profile
.
append
(
None
)
# merge not common opt
# merge not common opt
import
StringIO
from
theano.compat.six
import
StringIO
for
l
in
set
(
prof1
[
0
])
.
symmetric_difference
(
set
(
prof2
[
0
])):
for
l
in
set
(
prof1
[
0
])
.
symmetric_difference
(
set
(
prof2
[
0
])):
#The set trick above only work for the same object optimization
#The set trick above only work for the same object optimization
#It don't work for equivalent optimization.
#It don't work for equivalent optimization.
...
@@ -282,8 +282,8 @@ class SeqOptimizer(Optimizer, list):
...
@@ -282,8 +282,8 @@ class SeqOptimizer(Optimizer, list):
new_l_names
=
[
o
.
name
for
o
in
new_l
]
new_l_names
=
[
o
.
name
for
o
in
new_l
]
if
l
.
name
in
new_l_names
:
if
l
.
name
in
new_l_names
:
idx
=
new_l_names
.
index
(
l
.
name
)
idx
=
new_l_names
.
index
(
l
.
name
)
io1
=
StringIO
.
StringIO
()
io1
=
StringIO
()
io2
=
StringIO
.
StringIO
()
io2
=
StringIO
()
l
.
print_summary
(
io1
)
l
.
print_summary
(
io1
)
new_l
[
idx
]
.
print_summary
(
io2
)
new_l
[
idx
]
.
print_summary
(
io2
)
if
io1
.
read
()
==
io2
.
read
():
if
io1
.
read
()
==
io2
.
read
():
...
...
theano/gof/optdb.py
浏览文件 @
c9d1922b
import
StringIO
import
sys
import
sys
from
theano.gof.python25
import
DefaultOrderedDict
from
theano.gof.python25
import
DefaultOrderedDict
import
numpy
import
numpy
from
theano.compat.six
import
StringIO
from
theano.gof
import
opt
from
theano.gof
import
opt
from
theano.configparser
import
AddConfigVar
,
FloatParam
from
theano.configparser
import
AddConfigVar
,
FloatParam
from
theano
import
config
from
theano
import
config
...
@@ -258,7 +258,7 @@ class SequenceDB(DB):
...
@@ -258,7 +258,7 @@ class SequenceDB(DB):
print
>>
stream
,
" db"
,
self
.
__db__
print
>>
stream
,
" db"
,
self
.
__db__
def
__str__
(
self
):
def
__str__
(
self
):
sio
=
StringIO
.
StringIO
()
sio
=
StringIO
()
self
.
print_summary
(
sio
)
self
.
print_summary
(
sio
)
return
sio
.
getvalue
()
return
sio
.
getvalue
()
...
...
theano/misc/hooks/check_whitespace.py
浏览文件 @
c9d1922b
...
@@ -5,7 +5,6 @@ import difflib
...
@@ -5,7 +5,6 @@ import difflib
import
operator
import
operator
import
os
import
os
import
string
import
string
from
StringIO
import
StringIO
from
subprocess
import
Popen
,
PIPE
from
subprocess
import
Popen
,
PIPE
import
sys
import
sys
import
tabnanny
import
tabnanny
...
@@ -13,6 +12,7 @@ import tokenize
...
@@ -13,6 +12,7 @@ import tokenize
import
argparse
import
argparse
import
reindent
import
reindent
from
theano.compat.six.StringIO
import
StringIO
SKIP_WHITESPACE_CHECK_FILENAME
=
".hg/skip_whitespace_check"
SKIP_WHITESPACE_CHECK_FILENAME
=
".hg/skip_whitespace_check"
...
...
theano/printing.py
浏览文件 @
c9d1922b
...
@@ -6,7 +6,6 @@ in a graph(Print Op)
...
@@ -6,7 +6,6 @@ in a graph(Print Op)
from
copy
import
copy
from
copy
import
copy
import
logging
import
logging
import
os
import
os
import
StringIO
import
sys
import
sys
# Not available on all platforms
# Not available on all platforms
hashlib
=
None
hashlib
=
None
...
@@ -26,6 +25,7 @@ except ImportError:
...
@@ -26,6 +25,7 @@ except ImportError:
import
theano
import
theano
from
theano
import
gof
from
theano
import
gof
from
theano
import
config
from
theano
import
config
from
theano.compat.six
import
StringIO
from
theano.gof
import
Op
,
Apply
from
theano.gof
import
Op
,
Apply
from
theano.gof.python25
import
any
from
theano.gof.python25
import
any
from
theano.compile
import
Function
,
debugmode
from
theano.compile
import
Function
,
debugmode
...
@@ -74,7 +74,7 @@ def debugprint(obj, depth=-1, print_type=False,
...
@@ -74,7 +74,7 @@ def debugprint(obj, depth=-1, print_type=False,
"""
"""
if
file
==
'str'
:
if
file
==
'str'
:
_file
=
StringIO
.
StringIO
()
_file
=
StringIO
()
elif
file
is
None
:
elif
file
is
None
:
_file
=
sys
.
stdout
_file
=
sys
.
stdout
else
:
else
:
...
...
theano/sandbox/cuda/basic_ops.py
浏览文件 @
c9d1922b
import
copy
import
copy
import
logging
import
logging
import
StringIO
import
sys
import
sys
import
numpy
import
numpy
...
@@ -8,6 +7,7 @@ import numpy
...
@@ -8,6 +7,7 @@ import numpy
import
theano
import
theano
from
theano
import
Op
,
Type
,
Apply
,
Variable
,
Constant
from
theano
import
Op
,
Type
,
Apply
,
Variable
,
Constant
from
theano
import
tensor
,
scalar
,
config
from
theano
import
tensor
,
scalar
,
config
from
theano.compat.six
import
StringIO
from
theano.scalar
import
Scalar
from
theano.scalar
import
Scalar
scal
=
scalar
# somewhere scalar gets reassigned to be a function
scal
=
scalar
# somewhere scalar gets reassigned to be a function
...
@@ -385,7 +385,7 @@ class GpuDimShuffle(GpuOp):
...
@@ -385,7 +385,7 @@ class GpuDimShuffle(GpuOp):
nd_in
=
len
(
self
.
input_broadcastable
)
nd_in
=
len
(
self
.
input_broadcastable
)
nd_out
=
len
(
self
.
new_order
)
nd_out
=
len
(
self
.
new_order
)
sio
=
StringIO
.
StringIO
()
sio
=
StringIO
()
fail
=
sub
[
'fail'
]
fail
=
sub
[
'fail'
]
#check input
#check input
...
@@ -618,7 +618,7 @@ class GpuCAReduce(GpuOp):
...
@@ -618,7 +618,7 @@ class GpuCAReduce(GpuOp):
assert
nd_in
-
nd_out
==
sum
(
self
.
reduce_mask
)
assert
nd_in
-
nd_out
==
sum
(
self
.
reduce_mask
)
sio
=
StringIO
.
StringIO
()
sio
=
StringIO
()
fail
=
sub
[
'fail'
]
fail
=
sub
[
'fail'
]
#check input
#check input
...
@@ -661,7 +661,7 @@ class GpuCAReduce(GpuOp):
...
@@ -661,7 +661,7 @@ class GpuCAReduce(GpuOp):
j
=
0
j
=
0
for
i
in
xrange
(
nd_in
):
for
i
in
xrange
(
nd_in
):
if
not
self
.
reduce_mask
[
i
]:
if
not
self
.
reduce_mask
[
i
]:
print
>>
sio
,
" || (CudaNdarray_HOST_DIMS(
%(z)
s)[
%(j)
s] !=
CudaNdarray_HOST_DIMS(
%
s)[
%
d]) "
%
(
x
,
i
)
print
>>
sio
,
" || (CudaNdarray_HOST_DIMS(
%(z)
s)[
%(j)
s] !=
CudaNdarray_HOST_DIMS(
%(x)
s)[
%(i)
d]) "
%
locals
(
)
j
+=
1
j
+=
1
print
>>
sio
,
"""
print
>>
sio
,
"""
...
@@ -750,7 +750,7 @@ class GpuCAReduce(GpuOp):
...
@@ -750,7 +750,7 @@ class GpuCAReduce(GpuOp):
%(fail)
s;
%(fail)
s;
}
}
"""
"""
sio
=
StringIO
.
StringIO
()
sio
=
StringIO
()
if
pattern
is
None
:
if
pattern
is
None
:
pattern
=
''
.
join
(
str
(
c
)
for
c
in
self
.
reduce_mask
)
pattern
=
''
.
join
(
str
(
c
)
for
c
in
self
.
reduce_mask
)
ndim
=
len
(
self
.
reduce_mask
)
ndim
=
len
(
self
.
reduce_mask
)
...
@@ -843,7 +843,7 @@ class GpuCAReduce(GpuOp):
...
@@ -843,7 +843,7 @@ class GpuCAReduce(GpuOp):
ndim
=
len
(
reduce_mask
)
ndim
=
len
(
reduce_mask
)
if
pattern
is
None
:
if
pattern
is
None
:
pattern
=
''
.
join
(
str
(
i
)
for
i
in
reduce_mask
)
pattern
=
''
.
join
(
str
(
i
)
for
i
in
reduce_mask
)
sio
=
StringIO
.
StringIO
()
sio
=
StringIO
()
print
>>
sio
,
"""
print
>>
sio
,
"""
static __global__ void kernel_reduce_
%(pattern)
s_
%(nodename)
s(
static __global__ void kernel_reduce_
%(pattern)
s_
%(nodename)
s(
...
@@ -1590,7 +1590,7 @@ class GpuCAReduce(GpuOp):
...
@@ -1590,7 +1590,7 @@ class GpuCAReduce(GpuOp):
raise
NotImplementedError
()
raise
NotImplementedError
()
def
c_support_code_apply
(
self
,
node
,
nodename
):
def
c_support_code_apply
(
self
,
node
,
nodename
):
sio
=
StringIO
.
StringIO
()
sio
=
StringIO
()
nd_in
=
len
(
self
.
reduce_mask
)
nd_in
=
len
(
self
.
reduce_mask
)
if
all
(
i
==
1
for
i
in
self
.
reduce_mask
):
if
all
(
i
==
1
for
i
in
self
.
reduce_mask
):
self
.
_op_guard
()
self
.
_op_guard
()
...
...
theano/sandbox/cuda/blas.py
浏览文件 @
c9d1922b
import
copy
import
copy
import
os
import
os
import
StringIO
import
theano
import
theano
from
theano
import
Apply
from
theano
import
Apply
from
theano
import
tensor
from
theano
import
tensor
from
theano.compat.six
import
StringIO
from
theano.sandbox.cuda.type
import
CudaNdarrayType
from
theano.sandbox.cuda.type
import
CudaNdarrayType
from
theano.sandbox.cuda
import
GpuOp
from
theano.sandbox.cuda
import
GpuOp
...
@@ -226,7 +226,7 @@ class GpuGemm(GpuOp):
...
@@ -226,7 +226,7 @@ class GpuGemm(GpuOp):
z_out
,
=
outputs
z_out
,
=
outputs
inplace
=
int
(
self
.
inplace
)
inplace
=
int
(
self
.
inplace
)
fail
=
sub
[
'fail'
]
fail
=
sub
[
'fail'
]
sio
=
StringIO
.
StringIO
()
sio
=
StringIO
()
print
>>
sio
,
"""
print
>>
sio
,
"""
...
@@ -341,7 +341,7 @@ class GpuGemv(GpuOp):
...
@@ -341,7 +341,7 @@ class GpuGemv(GpuOp):
z_out
,
=
outputs
z_out
,
=
outputs
inplace
=
int
(
self
.
inplace
)
inplace
=
int
(
self
.
inplace
)
fail
=
sub
[
'fail'
]
fail
=
sub
[
'fail'
]
sio
=
StringIO
.
StringIO
()
sio
=
StringIO
()
print
>>
sio
,
"""
print
>>
sio
,
"""
float
%(name)
s_alpha = ((dtype_
%(a)
s*)(
%(a)
s->data))[0];
float
%(name)
s_alpha = ((dtype_
%(a)
s*)(
%(a)
s->data))[0];
...
@@ -438,7 +438,7 @@ class GpuGer(GpuOp):
...
@@ -438,7 +438,7 @@ class GpuGer(GpuOp):
z_out
,
=
outputs
z_out
,
=
outputs
inplace
=
int
(
self
.
inplace
)
inplace
=
int
(
self
.
inplace
)
fail
=
sub
[
'fail'
]
fail
=
sub
[
'fail'
]
sio
=
StringIO
.
StringIO
()
sio
=
StringIO
()
print
>>
sio
,
"""
print
>>
sio
,
"""
float
%(name)
s_alpha = ((dtype_
%(a)
s*)(
%(a)
s->data))[0];
float
%(name)
s_alpha = ((dtype_
%(a)
s*)(
%(a)
s->data))[0];
...
...
theano/sandbox/cuda/elemwise.py
浏览文件 @
c9d1922b
...
@@ -5,12 +5,13 @@ The elemwise fct are also used with scalar operation! So it can happen that ndim
...
@@ -5,12 +5,13 @@ The elemwise fct are also used with scalar operation! So it can happen that ndim
"""
"""
import
copy
,
logging
,
StringIO
,
sys
import
copy
,
logging
,
sys
import
numpy
import
numpy
from
theano.scalar.basic
import
upgrade_to_float_no_complex
,
complex_types
from
theano.scalar.basic
import
upgrade_to_float_no_complex
,
complex_types
from
theano.scalar.basic_scipy
import
Erfinv
from
theano.scalar.basic_scipy
import
Erfinv
from
theano.compat.six
import
StringIO
from
theano
import
Apply
,
Constant
,
Op
,
Type
,
Variable
from
theano
import
Apply
,
Constant
,
Op
,
Type
,
Variable
from
theano
import
gof
,
scalar
,
tensor
from
theano
import
gof
,
scalar
,
tensor
...
@@ -65,7 +66,7 @@ class NaiveAlgo(object):
...
@@ -65,7 +66,7 @@ class NaiveAlgo(object):
self
.
inplace_pattern
=
inplace_pattern
self
.
inplace_pattern
=
inplace_pattern
def
c_src_kernel
(
self
,
node
,
nodename
,
nd
):
def
c_src_kernel
(
self
,
node
,
nodename
,
nd
):
sio
=
StringIO
.
StringIO
()
sio
=
StringIO
()
#print 'C_SRC_KERNEL', sio.getvalue()
#print 'C_SRC_KERNEL', sio.getvalue()
for
ipos
,
i
in
enumerate
(
node
.
inputs
):
for
ipos
,
i
in
enumerate
(
node
.
inputs
):
...
@@ -166,7 +167,7 @@ class NaiveAlgo(object):
...
@@ -166,7 +167,7 @@ class NaiveAlgo(object):
"""
"""
nd
=
node
.
outputs
[
0
]
.
type
.
ndim
nd
=
node
.
outputs
[
0
]
.
type
.
ndim
sio
=
StringIO
.
StringIO
()
sio
=
StringIO
()
#print 'C_SRC_KERNEL', sio.getvalue()
#print 'C_SRC_KERNEL', sio.getvalue()
if
nd
in
(
4
,):
if
nd
in
(
4
,):
...
@@ -267,7 +268,7 @@ class NaiveAlgo(object):
...
@@ -267,7 +268,7 @@ class NaiveAlgo(object):
nd
=
node
.
outputs
[
0
]
.
type
.
ndim
nd
=
node
.
outputs
[
0
]
.
type
.
ndim
n_in
=
len
(
node
.
inputs
)
n_in
=
len
(
node
.
inputs
)
n_out
=
len
(
node
.
outputs
)
n_out
=
len
(
node
.
outputs
)
sio
=
StringIO
.
StringIO
()
sio
=
StringIO
()
if
nd
not
in
(
2
,):
if
nd
not
in
(
2
,):
return
sio
.
getvalue
()
return
sio
.
getvalue
()
...
@@ -418,7 +419,7 @@ class NaiveAlgo(object):
...
@@ -418,7 +419,7 @@ class NaiveAlgo(object):
def
c_src_kernel_Ccontiguous
(
self
,
node
,
nodename
):
def
c_src_kernel_Ccontiguous
(
self
,
node
,
nodename
):
nd
=
node
.
outputs
[
0
]
.
type
.
ndim
nd
=
node
.
outputs
[
0
]
.
type
.
ndim
sio
=
StringIO
.
StringIO
()
sio
=
StringIO
()
#print 'C_SRC_KERNEL', sio.getvalue()
#print 'C_SRC_KERNEL', sio.getvalue()
for
ipos
,
i
in
enumerate
(
node
.
inputs
):
for
ipos
,
i
in
enumerate
(
node
.
inputs
):
...
@@ -503,7 +504,7 @@ class NaiveAlgo(object):
...
@@ -503,7 +504,7 @@ class NaiveAlgo(object):
scalar_op
=
self
.
scalar_op
.
__class__
.
__name__
scalar_op
=
self
.
scalar_op
.
__class__
.
__name__
sio
=
StringIO
.
StringIO
()
sio
=
StringIO
()
print
>>
sio
,
"""
print
>>
sio
,
"""
static void can_collapse_
%(nodename)
s(int nd, const int * dims, const int * strides, int collapse[])
static void can_collapse_
%(nodename)
s(int nd, const int * dims, const int * strides, int collapse[])
{
{
...
@@ -856,7 +857,7 @@ nd_collapse_[i]=0;
...
@@ -856,7 +857,7 @@ nd_collapse_[i]=0;
d
=
dict
(
sub
)
d
=
dict
(
sub
)
nd
=
node
.
outputs
[
0
]
.
type
.
ndim
nd
=
node
.
outputs
[
0
]
.
type
.
ndim
d
.
update
(
locals
())
d
.
update
(
locals
())
sio
=
StringIO
.
StringIO
()
sio
=
StringIO
()
nin
=
len
(
inputs
)
nin
=
len
(
inputs
)
nout
=
len
(
outputs
)
nout
=
len
(
outputs
)
fail
=
sub
[
'fail'
]
fail
=
sub
[
'fail'
]
...
...
theano/sandbox/cuda/nnet.py
浏览文件 @
c9d1922b
from
theano
import
Op
,
Apply
from
theano
import
Op
,
Apply
import
StringIO
from
theano.compat.six
import
StringIO
from
theano.sandbox.cuda
import
GpuOp
from
theano.sandbox.cuda
import
GpuOp
...
@@ -92,7 +92,7 @@ class GpuCrossentropySoftmaxArgmax1HotWithBias (GpuOp):
...
@@ -92,7 +92,7 @@ class GpuCrossentropySoftmaxArgmax1HotWithBias (GpuOp):
nll
,
sm
,
am
=
out
nll
,
sm
,
am
=
out
classname
=
self
.
__class__
.
__name__
classname
=
self
.
__class__
.
__name__
fail
=
sub
[
'fail'
]
fail
=
sub
[
'fail'
]
sio
=
StringIO
.
StringIO
()
sio
=
StringIO
()
print
>>
sio
,
"""
print
>>
sio
,
"""
if (
%(y_idx)
s->nd != 1)
if (
%(y_idx)
s->nd != 1)
{
{
...
...
theano/sandbox/cuda/type.py
浏览文件 @
c9d1922b
"""Provide CudaNdarrayType
"""Provide CudaNdarrayType
"""
"""
import
os
import
os
import
StringIO
import
copy_reg
import
copy_reg
import
numpy
import
numpy
...
@@ -10,6 +9,7 @@ import theano
...
@@ -10,6 +9,7 @@ import theano
from
theano
import
Type
,
Variable
from
theano
import
Type
,
Variable
from
theano
import
tensor
,
config
from
theano
import
tensor
,
config
from
theano
import
scalar
as
scal
from
theano
import
scalar
as
scal
from
theano.compat.six
import
StringIO
try
:
try
:
# We must do those import to be able to create the full doc when nvcc
# We must do those import to be able to create the full doc when nvcc
...
@@ -274,7 +274,7 @@ class CudaNdarrayType(Type):
...
@@ -274,7 +274,7 @@ class CudaNdarrayType(Type):
return
"
%(name)
s = NULL;"
%
locals
()
return
"
%(name)
s = NULL;"
%
locals
()
def
c_extract
(
self
,
name
,
sub
):
def
c_extract
(
self
,
name
,
sub
):
sio
=
StringIO
.
StringIO
()
sio
=
StringIO
()
fail
=
sub
[
'fail'
]
fail
=
sub
[
'fail'
]
nd
=
self
.
ndim
nd
=
self
.
ndim
print
>>
sio
,
"""
print
>>
sio
,
"""
...
...
theano/tensor/opt.py
浏览文件 @
c9d1922b
...
@@ -9,7 +9,6 @@ _logger = logging.getLogger('theano.tensor.opt')
...
@@ -9,7 +9,6 @@ _logger = logging.getLogger('theano.tensor.opt')
import
operator
import
operator
import
itertools
import
itertools
import
StringIO
import
sys
import
sys
import
traceback
import
traceback
from
itertools
import
izip
from
itertools
import
izip
...
@@ -35,7 +34,7 @@ from theano.gof.opt import (Optimizer, pre_constant_merge,
...
@@ -35,7 +34,7 @@ from theano.gof.opt import (Optimizer, pre_constant_merge,
from
theano.gof.opt
import
merge_optimizer
from
theano.gof.opt
import
merge_optimizer
from
theano.gof
import
toolbox
,
DestroyHandler
from
theano.gof
import
toolbox
,
DestroyHandler
from
theano.tensor.basic
import
get_scalar_constant_value
,
ShapeError
,
NotScalarConstantError
from
theano.tensor.basic
import
get_scalar_constant_value
,
ShapeError
,
NotScalarConstantError
from
theano.compat.six
import
StringIO
theano
.
configparser
.
AddConfigVar
(
'on_shape_error'
,
theano
.
configparser
.
AddConfigVar
(
'on_shape_error'
,
"warn: print a warning and use the default"
"warn: print a warning and use the default"
...
@@ -836,7 +835,7 @@ class ShapeFeature(object):
...
@@ -836,7 +835,7 @@ class ShapeFeature(object):
raise
TypeError
(
'shapes must be tuple/list'
,
(
r
,
s
))
raise
TypeError
(
'shapes must be tuple/list'
,
(
r
,
s
))
if
r
.
ndim
!=
len
(
s
):
if
r
.
ndim
!=
len
(
s
):
sio
=
StringIO
.
StringIO
()
sio
=
StringIO
()
theano
.
printing
.
debugprint
(
r
,
file
=
sio
,
print_type
=
True
)
theano
.
printing
.
debugprint
(
r
,
file
=
sio
,
print_type
=
True
)
raise
AssertionError
(
raise
AssertionError
(
"Something inferred a shape with
%
d dimensions "
"Something inferred a shape with
%
d dimensions "
...
...
theano/tensor/tests/test_basic.py
浏览文件 @
c9d1922b
...
@@ -2,7 +2,6 @@ import itertools
...
@@ -2,7 +2,6 @@ import itertools
import
logging
import
logging
import
operator
import
operator
import
os
import
os
import
StringIO
import
sys
import
sys
from
tempfile
import
mkstemp
from
tempfile
import
mkstemp
import
unittest
import
unittest
...
@@ -20,6 +19,7 @@ from numpy.testing.noseclasses import KnownFailureTest
...
@@ -20,6 +19,7 @@ from numpy.testing.noseclasses import KnownFailureTest
import
theano
import
theano
from
theano.compat
import
PY3
,
exc_message
,
operator_div
from
theano.compat
import
PY3
,
exc_message
,
operator_div
from
theano.compat.six
import
StringIO
from
theano
import
compile
,
config
,
function
,
gof
,
tensor
,
shared
from
theano
import
compile
,
config
,
function
,
gof
,
tensor
,
shared
from
theano.compile
import
DeepCopyOp
from
theano.compile
import
DeepCopyOp
from
theano.compile.mode
import
get_default_mode
from
theano.compile.mode
import
get_default_mode
...
@@ -2269,7 +2269,7 @@ class T_max_and_argmax(unittest.TestCase):
...
@@ -2269,7 +2269,7 @@ class T_max_and_argmax(unittest.TestCase):
def
test2_invalid_neg
(
self
):
def
test2_invalid_neg
(
self
):
n
=
as_tensor_variable
(
rand
(
2
,
3
))
n
=
as_tensor_variable
(
rand
(
2
,
3
))
old_stderr
=
sys
.
stderr
old_stderr
=
sys
.
stderr
sys
.
stderr
=
StringIO
.
StringIO
()
sys
.
stderr
=
StringIO
()
try
:
try
:
try
:
try
:
eval_outputs
(
max_and_argmax
(
n
,
-
3
))
eval_outputs
(
max_and_argmax
(
n
,
-
3
))
...
@@ -2463,7 +2463,7 @@ class T_argmin_argmax(unittest.TestCase):
...
@@ -2463,7 +2463,7 @@ class T_argmin_argmax(unittest.TestCase):
for
fct
,
nfct
in
[(
argmax
,
numpy
.
argmax
),
(
argmin
,
numpy
.
argmin
)]:
for
fct
,
nfct
in
[(
argmax
,
numpy
.
argmax
),
(
argmin
,
numpy
.
argmin
)]:
n
=
as_tensor_variable
(
rand
(
2
,
3
))
n
=
as_tensor_variable
(
rand
(
2
,
3
))
old_stderr
=
sys
.
stderr
old_stderr
=
sys
.
stderr
sys
.
stderr
=
StringIO
.
StringIO
()
sys
.
stderr
=
StringIO
()
try
:
try
:
try
:
try
:
eval_outputs
(
fct
(
n
,
-
3
))
eval_outputs
(
fct
(
n
,
-
3
))
...
@@ -2596,7 +2596,7 @@ class T_min_max(unittest.TestCase):
...
@@ -2596,7 +2596,7 @@ class T_min_max(unittest.TestCase):
for
fct
in
[
max
,
min
]:
for
fct
in
[
max
,
min
]:
n
=
as_tensor_variable
(
rand
(
2
,
3
))
n
=
as_tensor_variable
(
rand
(
2
,
3
))
old_stderr
=
sys
.
stderr
old_stderr
=
sys
.
stderr
sys
.
stderr
=
StringIO
.
StringIO
()
sys
.
stderr
=
StringIO
()
try
:
try
:
try
:
try
:
eval_outputs
(
fct
(
n
,
-
3
))
eval_outputs
(
fct
(
n
,
-
3
))
...
@@ -2931,7 +2931,7 @@ class T_subtensor(unittest.TestCase, utt.TestOptimizationMixin):
...
@@ -2931,7 +2931,7 @@ class T_subtensor(unittest.TestCase, utt.TestOptimizationMixin):
t
=
n
[
4
:
5
,
3
]
t
=
n
[
4
:
5
,
3
]
self
.
assertTrue
(
isinstance
(
t
.
owner
.
op
,
Subtensor
))
self
.
assertTrue
(
isinstance
(
t
.
owner
.
op
,
Subtensor
))
old_stderr
=
sys
.
stderr
old_stderr
=
sys
.
stderr
sys
.
stderr
=
StringIO
.
StringIO
()
sys
.
stderr
=
StringIO
()
try
:
try
:
self
.
assertRaises
(
IndexError
,
self
.
assertRaises
(
IndexError
,
self
.
eval_output_and_check
,
[
t
])
self
.
eval_output_and_check
,
[
t
])
...
...
theano/tensor/tests/test_naacl09.py
浏览文件 @
c9d1922b
...
@@ -652,10 +652,10 @@ def profile_main():
...
@@ -652,10 +652,10 @@ def profile_main():
# We've renamed our original main() above to real_main()
# We've renamed our original main() above to real_main()
import
cProfile
import
cProfile
import
pstats
import
pstats
import
StringIO
from
theano.compat.six
import
StringIO
prof
=
cProfile
.
Profile
()
prof
=
cProfile
.
Profile
()
prof
=
prof
.
runctx
(
"real_main()"
,
globals
(),
locals
())
prof
=
prof
.
runctx
(
"real_main()"
,
globals
(),
locals
())
stream
=
StringIO
.
StringIO
()
stream
=
StringIO
()
stats
=
pstats
.
Stats
(
prof
)
stats
=
pstats
.
Stats
(
prof
)
stats
.
sort_stats
(
"time"
)
# Or cumulative
stats
.
sort_stats
(
"time"
)
# Or cumulative
stats
.
print_stats
(
80
)
# 80 = how many to print
stats
.
print_stats
(
80
)
# 80 = how many to print
...
...
theano/tensor/tests/test_opt.py
浏览文件 @
c9d1922b
...
@@ -2,7 +2,6 @@
...
@@ -2,7 +2,6 @@
import
copy
import
copy
import
logging
import
logging
import
StringIO
import
time
import
time
import
unittest
import
unittest
...
@@ -13,6 +12,7 @@ from numpy.testing.noseclasses import KnownFailureTest
...
@@ -13,6 +12,7 @@ from numpy.testing.noseclasses import KnownFailureTest
import
theano
import
theano
import
theano.scalar
as
scal
import
theano.scalar
as
scal
from
theano.compat.six
import
StringIO
from
theano
import
compile
from
theano
import
compile
from
theano.compile
import
deep_copy_op
,
DeepCopyOp
from
theano.compile
import
deep_copy_op
,
DeepCopyOp
from
theano
import
config
from
theano
import
config
...
@@ -742,7 +742,7 @@ class test_canonize(unittest.TestCase):
...
@@ -742,7 +742,7 @@ class test_canonize(unittest.TestCase):
This bug caused an infinite loop which was caught by the equilibrium
This bug caused an infinite loop which was caught by the equilibrium
optimizer, resulting in an error log message.
optimizer, resulting in an error log message.
"""
"""
sio
=
StringIO
.
StringIO
()
sio
=
StringIO
()
handler
=
logging
.
StreamHandler
(
sio
)
handler
=
logging
.
StreamHandler
(
sio
)
handler
.
setLevel
(
logging
.
ERROR
)
handler
.
setLevel
(
logging
.
ERROR
)
logging
.
getLogger
(
'theano.gof.opt'
)
.
addHandler
(
handler
)
logging
.
getLogger
(
'theano.gof.opt'
)
.
addHandler
(
handler
)
...
...
theano/tests/test_determinism.py
浏览文件 @
c9d1922b
...
@@ -5,12 +5,11 @@ from theano.tests import disturb_mem
...
@@ -5,12 +5,11 @@ from theano.tests import disturb_mem
import
numpy
as
np
import
numpy
as
np
import
theano
import
theano
from
theano.printing
import
var_descriptor
from
theano.printing
import
var_descriptor
from
cStringIO
import
StringIO
from
nose.plugins.skip
import
SkipTest
from
nose.plugins.skip
import
SkipTest
from
theano
import
config
from
theano
import
config
from
theano
import
shared
from
theano
import
shared
from
theano.compat.six
import
StringIO
def
sharedX
(
x
,
name
=
None
):
def
sharedX
(
x
,
name
=
None
):
x
=
np
.
cast
[
config
.
floatX
](
x
)
x
=
np
.
cast
[
config
.
floatX
](
x
)
...
...
theano/tests/test_printing.py
浏览文件 @
c9d1922b
"""
"""
Tests of printing functionality
Tests of printing functionality
"""
"""
import
logging
import
logging
import
StringIO
from
nose.plugins.skip
import
SkipTest
from
nose.plugins.skip
import
SkipTest
...
@@ -12,7 +9,7 @@ import theano
...
@@ -12,7 +9,7 @@ import theano
import
theano.tensor
as
tensor
import
theano.tensor
as
tensor
from
theano.printing
import
min_informative_str
,
debugprint
from
theano.printing
import
min_informative_str
,
debugprint
from
theano.compat.six
import
StringIO
def
test_pydotprint_cond_highlight
():
def
test_pydotprint_cond_highlight
():
"""
"""
...
@@ -29,7 +26,7 @@ def test_pydotprint_cond_highlight():
...
@@ -29,7 +26,7 @@ def test_pydotprint_cond_highlight():
f
=
theano
.
function
([
x
],
x
*
2
)
f
=
theano
.
function
([
x
],
x
*
2
)
f
([
1
,
2
,
3
,
4
])
f
([
1
,
2
,
3
,
4
])
s
=
StringIO
.
StringIO
()
s
=
StringIO
()
new_handler
=
logging
.
StreamHandler
(
s
)
new_handler
=
logging
.
StreamHandler
(
s
)
new_handler
.
setLevel
(
logging
.
DEBUG
)
new_handler
.
setLevel
(
logging
.
DEBUG
)
orig_handler
=
theano
.
logging_default_handler
orig_handler
=
theano
.
logging_default_handler
...
@@ -65,7 +62,7 @@ def test_pydotprint_long_name():
...
@@ -65,7 +62,7 @@ def test_pydotprint_long_name():
f
=
theano
.
function
([
x
],
[
x
*
2
,
x
+
x
],
mode
=
mode
)
f
=
theano
.
function
([
x
],
[
x
*
2
,
x
+
x
],
mode
=
mode
)
f
([
1
,
2
,
3
,
4
])
f
([
1
,
2
,
3
,
4
])
s
=
StringIO
.
StringIO
()
s
=
StringIO
()
new_handler
=
logging
.
StreamHandler
(
s
)
new_handler
=
logging
.
StreamHandler
(
s
)
new_handler
.
setLevel
(
logging
.
DEBUG
)
new_handler
.
setLevel
(
logging
.
DEBUG
)
orig_handler
=
theano
.
logging_default_handler
orig_handler
=
theano
.
logging_default_handler
...
@@ -131,7 +128,7 @@ def test_debugprint():
...
@@ -131,7 +128,7 @@ def test_debugprint():
debugprint
(
G
)
debugprint
(
G
)
# test ids=int
# test ids=int
s
=
StringIO
.
StringIO
()
s
=
StringIO
()
debugprint
(
G
,
file
=
s
,
ids
=
'int'
)
debugprint
(
G
,
file
=
s
,
ids
=
'int'
)
s
=
s
.
getvalue
()
s
=
s
.
getvalue
()
# The additional white space are needed!
# The additional white space are needed!
...
@@ -151,7 +148,7 @@ def test_debugprint():
...
@@ -151,7 +148,7 @@ def test_debugprint():
assert
s
==
reference
assert
s
==
reference
# test ids=CHAR
# test ids=CHAR
s
=
StringIO
.
StringIO
()
s
=
StringIO
()
debugprint
(
G
,
file
=
s
,
ids
=
'CHAR'
)
debugprint
(
G
,
file
=
s
,
ids
=
'CHAR'
)
s
=
s
.
getvalue
()
s
=
s
.
getvalue
()
# The additional white space are needed!
# The additional white space are needed!
...
@@ -171,7 +168,7 @@ def test_debugprint():
...
@@ -171,7 +168,7 @@ def test_debugprint():
assert
s
==
reference
assert
s
==
reference
# test ids=CHAR, stop_on_name=True
# test ids=CHAR, stop_on_name=True
s
=
StringIO
.
StringIO
()
s
=
StringIO
()
debugprint
(
G
,
file
=
s
,
ids
=
'CHAR'
,
stop_on_name
=
True
)
debugprint
(
G
,
file
=
s
,
ids
=
'CHAR'
,
stop_on_name
=
True
)
s
=
s
.
getvalue
()
s
=
s
.
getvalue
()
# The additional white space are needed!
# The additional white space are needed!
...
@@ -189,7 +186,7 @@ def test_debugprint():
...
@@ -189,7 +186,7 @@ def test_debugprint():
assert
s
==
reference
assert
s
==
reference
# test ids=
# test ids=
s
=
StringIO
.
StringIO
()
s
=
StringIO
()
debugprint
(
G
,
file
=
s
,
ids
=
''
)
debugprint
(
G
,
file
=
s
,
ids
=
''
)
s
=
s
.
getvalue
()
s
=
s
.
getvalue
()
# The additional white space are needed!
# The additional white space are needed!
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论