Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
982d2659
提交
982d2659
authored
9月 13, 2011
作者:
nouiz
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #39 from dwf/isinstance_basestring
BUG: str -> basestring isinstance checks.
上级
b86b4389
8634f09d
隐藏空白字符变更
内嵌
并排
正在显示
21 个修改的文件
包含
36 行增加
和
36 行删除
+36
-36
debugging_with_stepmode.txt
doc/sandbox/debugging_with_stepmode.txt
+2
-2
debugmode.py
theano/compile/debugmode.py
+1
-1
function_module.py
theano/compile/function_module.py
+1
-1
io.py
theano/compile/io.py
+2
-2
mode.py
theano/compile/mode.py
+5
-5
module.py
theano/compile/module.py
+2
-2
profilemode.py
theano/compile/profilemode.py
+2
-2
configparser.py
theano/configparser.py
+1
-1
cc.py
theano/gof/cc.py
+2
-2
cmodule.py
theano/gof/cmodule.py
+2
-2
graph.py
theano/gof/graph.py
+1
-1
opt.py
theano/gof/opt.py
+2
-2
equilibrium.py
theano/gof/sandbox/equilibrium.py
+2
-2
test_op.py
theano/gof/tests/test_op.py
+1
-1
pycuda_example.py
theano/misc/pycuda_example.py
+1
-1
printing.py
theano/printing.py
+1
-1
symbolic_module.py
theano/sandbox/symbolic_module.py
+2
-2
scan_op.py
theano/scan_module/scan_op.py
+2
-2
scan_utils.py
theano/scan_module/scan_utils.py
+2
-2
basic.py
theano/sparse/basic.py
+1
-1
raw_random.py
theano/tensor/raw_random.py
+1
-1
没有找到文件。
doc/sandbox/debugging_with_stepmode.txt
浏览文件 @
982d2659
...
@@ -46,12 +46,12 @@ purpose of it is to hack it to investigate what your own particular program is d
...
@@ -46,12 +46,12 @@ purpose of it is to hack it to investigate what your own particular program is d
self.provided_linker = linker
self.provided_linker = linker
self.provided_optimizer = optimizer
self.provided_optimizer = optimizer
if isinstance(linker,
str
) or linker is None:
if isinstance(linker,
basestring
) or linker is None:
linker = predefined_linkers[linker]
linker = predefined_linkers[linker]
self.linker = WrapLinkerMany([linker], [blah])
self.linker = WrapLinkerMany([linker], [blah])
if isinstance(optimizer,
str
) or optimizer is None:
if isinstance(optimizer,
basestring
) or optimizer is None:
optimizer = predefined_optimizers[optimizer]
optimizer = predefined_optimizers[optimizer]
self._optimizer = optimizer
self._optimizer = optimizer
...
...
theano/compile/debugmode.py
浏览文件 @
982d2659
...
@@ -58,7 +58,7 @@ AddConfigVar('DebugMode.warn_input_not_reused',
...
@@ -58,7 +58,7 @@ AddConfigVar('DebugMode.warn_input_not_reused',
in_c_key
=
False
)
in_c_key
=
False
)
def
is_valid_check_preallocated_output_param
(
param
):
def
is_valid_check_preallocated_output_param
(
param
):
if
not
isinstance
(
param
,
str
):
if
not
isinstance
(
param
,
basestring
):
return
False
return
False
valid
=
[
"previous"
,
"c_contiguous"
,
"f_contiguous"
,
"neg_strides"
,
"ALL"
,
""
]
valid
=
[
"previous"
,
"c_contiguous"
,
"f_contiguous"
,
"neg_strides"
,
"ALL"
,
""
]
for
p
in
param
.
split
(
":"
):
for
p
in
param
.
split
(
":"
):
...
...
theano/compile/function_module.py
浏览文件 @
982d2659
...
@@ -1272,7 +1272,7 @@ def convert_function_input(input):
...
@@ -1272,7 +1272,7 @@ def convert_function_input(input):
orig
=
input
orig
=
input
if
not
input
:
if
not
input
:
raise
TypeError
(
"Nonsensical input specification:
%
s"
%
input
)
raise
TypeError
(
"Nonsensical input specification:
%
s"
%
input
)
if
isinstance
(
input
[
0
],
str
):
if
isinstance
(
input
[
0
],
basestring
):
name
=
input
[
0
]
name
=
input
[
0
]
input
=
input
[
1
:]
input
=
input
[
1
:]
else
:
else
:
...
...
theano/compile/io.py
浏览文件 @
982d2659
...
@@ -56,7 +56,7 @@ class SymbolicInput(object):
...
@@ -56,7 +56,7 @@ class SymbolicInput(object):
else
:
else
:
self
.
name
=
name
self
.
name
=
name
if
self
.
name
is
not
None
and
not
isinstance
(
self
.
name
,
str
):
if
self
.
name
is
not
None
and
not
isinstance
(
self
.
name
,
basestring
):
raise
TypeError
(
"name must be a string! (got:
%
s)"
%
self
.
name
)
raise
TypeError
(
"name must be a string! (got:
%
s)"
%
self
.
name
)
self
.
update
=
update
self
.
update
=
update
if
(
mutable
is
not
None
):
if
(
mutable
is
not
None
):
...
@@ -90,7 +90,7 @@ class SymbolicInputKit(object):
...
@@ -90,7 +90,7 @@ class SymbolicInputKit(object):
"""
"""
def
__init__
(
self
,
name
):
def
__init__
(
self
,
name
):
if
not
isinstance
(
name
,
str
):
if
not
isinstance
(
name
,
basestring
):
raise
TypeError
(
'naem must be a string (got:
%
s)'
%
name
)
raise
TypeError
(
'naem must be a string (got:
%
s)'
%
name
)
self
.
name
=
name
self
.
name
=
name
self
.
sinputs
=
[]
self
.
sinputs
=
[]
...
...
theano/compile/mode.py
浏览文件 @
982d2659
...
@@ -245,10 +245,10 @@ class Mode(object):
...
@@ -245,10 +245,10 @@ class Mode(object):
linker
,
optimizer
=
state
linker
,
optimizer
=
state
self
.
provided_linker
=
linker
self
.
provided_linker
=
linker
self
.
provided_optimizer
=
optimizer
self
.
provided_optimizer
=
optimizer
if
isinstance
(
linker
,
str
)
or
linker
is
None
:
if
isinstance
(
linker
,
basestring
)
or
linker
is
None
:
linker
=
predefined_linkers
[
linker
]
linker
=
predefined_linkers
[
linker
]
self
.
linker
=
linker
self
.
linker
=
linker
if
isinstance
(
optimizer
,
str
)
or
optimizer
is
None
:
if
isinstance
(
optimizer
,
basestring
)
or
optimizer
is
None
:
optimizer
=
predefined_optimizers
[
optimizer
]
optimizer
=
predefined_optimizers
[
optimizer
]
if
isinstance
(
optimizer
,
gof
.
Query
):
if
isinstance
(
optimizer
,
gof
.
Query
):
self
.
provided_optimizer
=
optimizer
self
.
provided_optimizer
=
optimizer
...
@@ -271,9 +271,9 @@ class Mode(object):
...
@@ -271,9 +271,9 @@ class Mode(object):
optimizer
=
property
(
__get_optimizer
)
optimizer
=
property
(
__get_optimizer
)
def
get_linker_optimizer
(
self
,
linker
,
optimizer
):
def
get_linker_optimizer
(
self
,
linker
,
optimizer
):
if
isinstance
(
linker
,
str
)
or
linker
is
None
:
if
isinstance
(
linker
,
basestring
)
or
linker
is
None
:
linker
=
predefined_linkers
[
linker
]
linker
=
predefined_linkers
[
linker
]
if
isinstance
(
optimizer
,
str
)
or
optimizer
is
None
:
if
isinstance
(
optimizer
,
basestring
)
or
optimizer
is
None
:
optimizer
=
predefined_optimizers
[
optimizer
]
optimizer
=
predefined_optimizers
[
optimizer
]
return
(
linker
,
optimizer
)
return
(
linker
,
optimizer
)
...
@@ -313,7 +313,7 @@ def get_mode(orig_string):
...
@@ -313,7 +313,7 @@ def get_mode(orig_string):
string
=
config
.
mode
string
=
config
.
mode
else
:
else
:
string
=
orig_string
string
=
orig_string
if
not
isinstance
(
string
,
str
):
if
not
isinstance
(
string
,
basestring
):
return
string
#it is hopefully already a mode...
return
string
#it is hopefully already a mode...
global
instanciated_default_mode
global
instanciated_default_mode
...
...
theano/compile/module.py
浏览文件 @
982d2659
...
@@ -305,7 +305,7 @@ class Method(Component):
...
@@ -305,7 +305,7 @@ class Method(Component):
# return self.resolve(x).r
# return self.resolve(x).r
def
resolve_inputs
():
def
resolve_inputs
():
if
isinstance
(
self
.
inputs
,
(
io
.
In
,
gof
.
Variable
,
str
)):
if
isinstance
(
self
.
inputs
,
(
io
.
In
,
gof
.
Variable
,
basestring
)):
inputs
=
[
self
.
inputs
]
inputs
=
[
self
.
inputs
]
else
:
else
:
inputs
=
list
(
self
.
inputs
)
inputs
=
list
(
self
.
inputs
)
...
@@ -313,7 +313,7 @@ class Method(Component):
...
@@ -313,7 +313,7 @@ class Method(Component):
passthrough
=
(
gof
.
Variable
,
io
.
In
))
for
input
in
inputs
]
passthrough
=
(
gof
.
Variable
,
io
.
In
))
for
input
in
inputs
]
def
resolve_outputs
():
def
resolve_outputs
():
if
isinstance
(
self
.
outputs
,
(
io
.
Out
,
gof
.
Variable
,
str
,
type
(
None
))):
if
isinstance
(
self
.
outputs
,
(
io
.
Out
,
gof
.
Variable
,
basestring
,
type
(
None
))):
output
=
self
.
outputs
output
=
self
.
outputs
self
.
outputs
=
resolve_variable
(
output
,
self
.
outputs
=
resolve_variable
(
output
,
passthrough
=
(
gof
.
Variable
,
io
.
Out
,
type
(
None
)))
passthrough
=
(
gof
.
Variable
,
io
.
Out
,
type
(
None
)))
...
...
theano/compile/profilemode.py
浏览文件 @
982d2659
...
@@ -184,7 +184,7 @@ class ProfileMode(Mode):
...
@@ -184,7 +184,7 @@ class ProfileMode(Mode):
self
.
provided_linker
=
linker
self
.
provided_linker
=
linker
self
.
provided_optimizer
=
optimizer
self
.
provided_optimizer
=
optimizer
if
isinstance
(
linker
,
str
)
or
linker
is
None
:
if
isinstance
(
linker
,
basestring
)
or
linker
is
None
:
linker
=
predefined_linkers
[
linker
]
linker
=
predefined_linkers
[
linker
]
if
not
config
.
ProfileMode
.
profile_memory
:
if
not
config
.
ProfileMode
.
profile_memory
:
...
@@ -194,7 +194,7 @@ class ProfileMode(Mode):
...
@@ -194,7 +194,7 @@ class ProfileMode(Mode):
linker
=
WrapLinker
([
linker
],
p_thunk
)
linker
=
WrapLinker
([
linker
],
p_thunk
)
self
.
linker
=
linker
self
.
linker
=
linker
if
isinstance
(
optimizer
,
str
)
or
optimizer
is
None
:
if
isinstance
(
optimizer
,
basestring
)
or
optimizer
is
None
:
optimizer
=
predefined_optimizers
[
optimizer
]
optimizer
=
predefined_optimizers
[
optimizer
]
self
.
_optimizer
=
optimizer
self
.
_optimizer
=
optimizer
...
...
theano/configparser.py
浏览文件 @
982d2659
...
@@ -243,7 +243,7 @@ class EnumStr(ConfigParam):
...
@@ -243,7 +243,7 @@ class EnumStr(ConfigParam):
# All options should be strings
# All options should be strings
for
val
in
self
.
all
:
for
val
in
self
.
all
:
if
not
isinstance
(
val
,
str
):
if
not
isinstance
(
val
,
basestring
):
raise
ValueError
(
'Valid values for an EnumStr parameter '
raise
ValueError
(
'Valid values for an EnumStr parameter '
'should be strings'
,
val
,
type
(
val
))
'should be strings'
,
val
,
type
(
val
))
...
...
theano/gof/cc.py
浏览文件 @
982d2659
...
@@ -521,7 +521,7 @@ class CLinker(link.Linker):
...
@@ -521,7 +521,7 @@ class CLinker(link.Linker):
pass
pass
else
:
else
:
# The following will be executed if the "try" block succeeds
# The following will be executed if the "try" block succeeds
assert
isinstance
(
c_support_code_apply
[
-
1
],
str
),
(
assert
isinstance
(
c_support_code_apply
[
-
1
],
basestring
),
(
str
(
node
.
op
)
+
" didn't returned a string for c_support_code_apply"
)
str
(
node
.
op
)
+
" didn't returned a string for c_support_code_apply"
)
# emit c_code
# emit c_code
...
@@ -529,7 +529,7 @@ class CLinker(link.Linker):
...
@@ -529,7 +529,7 @@ class CLinker(link.Linker):
behavior
=
op
.
c_code
(
node
,
name
,
isyms
,
osyms
,
sub
)
behavior
=
op
.
c_code
(
node
,
name
,
isyms
,
osyms
,
sub
)
except
utils
.
MethodNotDefined
:
except
utils
.
MethodNotDefined
:
raise
NotImplementedError
(
"
%
s cannot produce C code"
%
op
)
raise
NotImplementedError
(
"
%
s cannot produce C code"
%
op
)
assert
isinstance
(
behavior
,
str
),
str
(
node
.
op
)
+
" didn't returned a string for c_code"
assert
isinstance
(
behavior
,
basestring
),
str
(
node
.
op
)
+
" didn't returned a string for c_code"
try
:
try
:
cleanup
=
op
.
c_code_cleanup
(
node
,
name
,
isyms
,
osyms
,
sub
)
cleanup
=
op
.
c_code_cleanup
(
node
,
name
,
isyms
,
osyms
,
sub
)
...
...
theano/gof/cmodule.py
浏览文件 @
982d2659
...
@@ -268,7 +268,7 @@ def get_module_hash(src_code, key):
...
@@ -268,7 +268,7 @@ def get_module_hash(src_code, key):
# This should be the C++ compilation command line parameters or the
# This should be the C++ compilation command line parameters or the
# libraries to link against.
# libraries to link against.
to_hash
+=
list
(
key_element
)
to_hash
+=
list
(
key_element
)
elif
isinstance
(
key_element
,
str
):
elif
isinstance
(
key_element
,
basestring
):
if
key_element
.
startswith
(
'md5:'
):
if
key_element
.
startswith
(
'md5:'
):
# This is the md5 hash of the config options. We can stop
# This is the md5 hash of the config options. We can stop
# here.
# here.
...
@@ -298,7 +298,7 @@ def get_safe_part(key):
...
@@ -298,7 +298,7 @@ def get_safe_part(key):
# Find the md5 hash part.
# Find the md5 hash part.
c_link_key
=
key
[
1
]
c_link_key
=
key
[
1
]
for
key_element
in
c_link_key
[
1
:]:
for
key_element
in
c_link_key
[
1
:]:
if
isinstance
(
key_element
,
str
)
and
key_element
.
startswith
(
'md5:'
):
if
isinstance
(
key_element
,
basestring
)
and
key_element
.
startswith
(
'md5:'
):
md5
=
key_element
[
4
:]
md5
=
key_element
[
4
:]
break
break
...
...
theano/gof/graph.py
浏览文件 @
982d2659
...
@@ -269,7 +269,7 @@ class Variable(utils.object2):
...
@@ -269,7 +269,7 @@ class Variable(utils.object2):
if
index
is
not
None
and
not
isinstance
(
index
,
int
):
if
index
is
not
None
and
not
isinstance
(
index
,
int
):
raise
TypeError
(
"index must be an int"
,
index
)
raise
TypeError
(
"index must be an int"
,
index
)
self
.
index
=
index
self
.
index
=
index
if
name
is
not
None
and
not
isinstance
(
name
,
str
):
if
name
is
not
None
and
not
isinstance
(
name
,
basestring
):
raise
TypeError
(
"name must be a string"
,
name
)
raise
TypeError
(
"name must be a string"
,
name
)
self
.
name
=
name
self
.
name
=
name
def
__str__
(
self
):
def
__str__
(
self
):
...
...
theano/gof/opt.py
浏览文件 @
982d2659
...
@@ -698,7 +698,7 @@ class PatternSub(LocalOptimizer):
...
@@ -698,7 +698,7 @@ class PatternSub(LocalOptimizer):
return
match
(
real_pattern
,
expr
,
u
,
pattern
.
get
(
'allow_multiple_clients'
,
allow_multiple_clients
))
return
match
(
real_pattern
,
expr
,
u
,
pattern
.
get
(
'allow_multiple_clients'
,
allow_multiple_clients
))
else
:
else
:
return
retry_with_equiv
()
return
retry_with_equiv
()
elif
isinstance
(
pattern
,
str
):
elif
isinstance
(
pattern
,
basestring
):
v
=
unify
.
Var
(
pattern
)
v
=
unify
.
Var
(
pattern
)
if
u
[
v
]
is
not
v
and
u
[
v
]
is
not
expr
:
if
u
[
v
]
is
not
v
and
u
[
v
]
is
not
expr
:
return
retry_with_equiv
()
return
retry_with_equiv
()
...
@@ -721,7 +721,7 @@ class PatternSub(LocalOptimizer):
...
@@ -721,7 +721,7 @@ class PatternSub(LocalOptimizer):
if
isinstance
(
pattern
,
(
list
,
tuple
)):
if
isinstance
(
pattern
,
(
list
,
tuple
)):
args
=
[
build
(
p
,
u
)
for
p
in
pattern
[
1
:]]
args
=
[
build
(
p
,
u
)
for
p
in
pattern
[
1
:]]
return
pattern
[
0
](
*
args
)
return
pattern
[
0
](
*
args
)
elif
isinstance
(
pattern
,
str
):
elif
isinstance
(
pattern
,
basestring
):
return
u
[
unify
.
Var
(
pattern
)]
return
u
[
unify
.
Var
(
pattern
)]
elif
isinstance
(
pattern
,
(
int
,
float
)):
elif
isinstance
(
pattern
,
(
int
,
float
)):
return
pattern
return
pattern
...
...
theano/gof/sandbox/equilibrium.py
浏览文件 @
982d2659
...
@@ -63,7 +63,7 @@ if 0:
...
@@ -63,7 +63,7 @@ if 0:
_nodes
=
nodes
_nodes
=
nodes
nodes
=
reduce
(
list
.
__iadd__
,
nodes
=
reduce
(
list
.
__iadd__
,
[
reduce
(
list
.
__iadd__
,
[
reduce
(
list
.
__iadd__
,
[[
n
for
n
,
i
in
out
.
clients
if
not
isinstance
(
n
,
str
)]
for
out
in
node
.
outputs
],
[[
n
for
n
,
i
in
out
.
clients
if
not
isinstance
(
n
,
basestring
)]
for
out
in
node
.
outputs
],
[])
for
node
in
nodes
],
[])
for
node
in
nodes
],
[])
[])
candidates
=
tracks
candidates
=
tracks
...
@@ -121,7 +121,7 @@ if 0:
...
@@ -121,7 +121,7 @@ if 0:
# for candidate in candidates:
# for candidate in candidates:
# if candidate.current.inputs is not None:
# if candidate.current.inputs is not None:
# for in1, in2 in zip(candidate.current.inputs, node.inputs):
# for in1, in2 in zip(candidate.current.inputs, node.inputs):
# if isinstance(in1,
str
):
# if isinstance(in1,
basestring
):
# candidate.match[in1] = in2
# candidate.match[in1] = in2
# for client in node.clients:
# for client in node.clients:
...
...
theano/gof/tests/test_op.py
浏览文件 @
982d2659
...
@@ -33,7 +33,7 @@ class MyType(Type):
...
@@ -33,7 +33,7 @@ class MyType(Type):
def
filter
(
self
,
x
,
strict
=
False
,
allow_downcast
=
None
):
def
filter
(
self
,
x
,
strict
=
False
,
allow_downcast
=
None
):
# Dummy filter: we want this type to represent strings that
# Dummy filter: we want this type to represent strings that
# start with `self.thingy`.
# start with `self.thingy`.
assert
isinstance
(
x
,
str
)
and
x
.
startswith
(
self
.
thingy
)
assert
isinstance
(
x
,
basestring
)
and
x
.
startswith
(
self
.
thingy
)
return
x
return
x
class
MyOp
(
Op
):
class
MyOp
(
Op
):
...
...
theano/misc/pycuda_example.py
浏览文件 @
982d2659
...
@@ -45,7 +45,7 @@ def theano_parse_c_arg(c_arg):
...
@@ -45,7 +45,7 @@ def theano_parse_c_arg(c_arg):
class
TheanoElementwiseKernel
(
pycuda
.
elementwise
.
ElementwiseKernel
):
class
TheanoElementwiseKernel
(
pycuda
.
elementwise
.
ElementwiseKernel
):
def
__init__
(
self
,
arguments
,
operation
,
def
__init__
(
self
,
arguments
,
operation
,
name
=
"kernel"
,
keep
=
False
,
options
=
[],
**
kwargs
):
name
=
"kernel"
,
keep
=
False
,
options
=
[],
**
kwargs
):
if
isinstance
(
arguments
,
str
):
if
isinstance
(
arguments
,
basestring
):
arguments
=
[
theano_parse_c_arg
(
arg
)
for
arg
in
arguments
.
split
(
","
)]
arguments
=
[
theano_parse_c_arg
(
arg
)
for
arg
in
arguments
.
split
(
","
)]
pycuda
.
elementwise
.
ElementwiseKernel
.
__init__
(
self
,
arguments
,
operation
,
name
,
keep
,
options
,
**
kwargs
)
pycuda
.
elementwise
.
ElementwiseKernel
.
__init__
(
self
,
arguments
,
operation
,
name
,
keep
,
options
,
**
kwargs
)
...
...
theano/printing.py
浏览文件 @
982d2659
...
@@ -190,7 +190,7 @@ class PatternPrinter:
...
@@ -190,7 +190,7 @@ class PatternPrinter:
def
__init__
(
self
,
*
patterns
):
def
__init__
(
self
,
*
patterns
):
self
.
patterns
=
[]
self
.
patterns
=
[]
for
pattern
in
patterns
:
for
pattern
in
patterns
:
if
isinstance
(
pattern
,
str
):
if
isinstance
(
pattern
,
basestring
):
self
.
patterns
.
append
((
pattern
,
()))
self
.
patterns
.
append
((
pattern
,
()))
else
:
else
:
self
.
patterns
.
append
((
pattern
[
0
],
pattern
[
1
:]))
self
.
patterns
.
append
((
pattern
[
0
],
pattern
[
1
:]))
...
...
theano/sandbox/symbolic_module.py
浏览文件 @
982d2659
...
@@ -119,7 +119,7 @@ def compile(smod, initial_values={}):
...
@@ -119,7 +119,7 @@ def compile(smod, initial_values={}):
elif
issymbolicmodule
(
val
):
elif
issymbolicmodule
(
val
):
for
s
in
modwalker
(
val
.
__dict__
,
[
v
for
k
,
v
in
sym_items
(
val
)]):
for
s
in
modwalker
(
val
.
__dict__
,
[
v
for
k
,
v
in
sym_items
(
val
)]):
yield
s
yield
s
elif
isinstance
(
val
,
(
str
,
int
,
float
)):
elif
isinstance
(
val
,
(
basestring
,
int
,
float
)):
pass
pass
elif
isinstance
(
val
,
theano
.
Variable
):
elif
isinstance
(
val
,
theano
.
Variable
):
pass
pass
...
@@ -170,7 +170,7 @@ def compile(smod, initial_values={}):
...
@@ -170,7 +170,7 @@ def compile(smod, initial_values={}):
reflected
[
thing
]
=
cmod
reflected
[
thing
]
=
cmod
for
key
,
val
in
sym_items
(
thing
):
for
key
,
val
in
sym_items
(
thing
):
setattr
(
CMod
,
key
,
reflect
(
val
))
setattr
(
CMod
,
key
,
reflect
(
val
))
elif
isinstance
(
thing
,
(
str
,
int
,
float
)):
elif
isinstance
(
thing
,
(
basestring
,
int
,
float
)):
reflected
[
thing
]
=
thing
reflected
[
thing
]
=
thing
elif
isinstance
(
thing
,
theano
.
Variable
):
elif
isinstance
(
thing
,
theano
.
Variable
):
if
thing
.
owner
is
None
:
if
thing
.
owner
is
None
:
...
...
theano/scan_module/scan_op.py
浏览文件 @
982d2659
...
@@ -355,9 +355,9 @@ class Scan(PureOp):
...
@@ -355,9 +355,9 @@ class Scan(PureOp):
self
.
outputs
[:
slices
]
]
self
.
outputs
[:
slices
]
]
wrapped_outputs
+=
self
.
outputs
[
slices
:]
wrapped_outputs
+=
self
.
outputs
[
slices
:]
profile
=
None
profile
=
None
if
(
theano
.
config
.
profile
or
(
isinstance
(
self
.
profile
,
(
str
,
bool
,
int
))
if
(
theano
.
config
.
profile
or
(
isinstance
(
self
.
profile
,
(
basestring
,
bool
,
int
))
and
self
.
profile
)):
and
self
.
profile
)):
if
isinstance
(
self
.
profile
,
str
):
if
isinstance
(
self
.
profile
,
basestring
):
profile
=
ScanProfileStats
(
name
=
self
.
profile
)
profile
=
ScanProfileStats
(
name
=
self
.
profile
)
else
:
else
:
profile
=
ScanProfileStats
(
name
=
self
.
name
)
profile
=
ScanProfileStats
(
name
=
self
.
name
)
...
...
theano/scan_module/scan_utils.py
浏览文件 @
982d2659
...
@@ -245,7 +245,7 @@ def isNaN_or_Inf_or_None(x):
...
@@ -245,7 +245,7 @@ def isNaN_or_Inf_or_None(x):
try
:
try
:
isNaN
=
numpy
.
isnan
(
x
)
isNaN
=
numpy
.
isnan
(
x
)
isInf
=
numpy
.
isinf
(
x
)
isInf
=
numpy
.
isinf
(
x
)
isStr
=
isinstance
(
x
,
str
)
isStr
=
isinstance
(
x
,
basestring
)
except
Exception
:
except
Exception
:
isNaN
=
False
isNaN
=
False
isInf
=
False
isInf
=
False
...
@@ -258,7 +258,7 @@ def isNaN_or_Inf_or_None(x):
...
@@ -258,7 +258,7 @@ def isNaN_or_Inf_or_None(x):
except
Exception
:
except
Exception
:
isNaN
=
False
isNaN
=
False
isInf
=
False
isInf
=
False
if
isinstance
(
x
,
gof
.
Constant
)
and
isinstance
(
x
.
data
,
str
):
if
isinstance
(
x
,
gof
.
Constant
)
and
isinstance
(
x
.
data
,
basestring
):
isStr
=
True
isStr
=
True
else
:
else
:
isStr
=
False
isStr
=
False
...
...
theano/sparse/basic.py
浏览文件 @
982d2659
...
@@ -239,7 +239,7 @@ class SparseType(gof.Type):
...
@@ -239,7 +239,7 @@ class SparseType(gof.Type):
else
:
else
:
raise
NotImplementedError
(
'unsupported dtype "
%
s" not in list'
%
dtype
,
list
(
self
.
dtype_set
))
raise
NotImplementedError
(
'unsupported dtype "
%
s" not in list'
%
dtype
,
list
(
self
.
dtype_set
))
assert
isinstance
(
format
,
str
)
assert
isinstance
(
format
,
basestring
)
if
format
in
self
.
format_cls
:
if
format
in
self
.
format_cls
:
self
.
format
=
format
self
.
format
=
format
else
:
else
:
...
...
theano/tensor/raw_random.py
浏览文件 @
982d2659
...
@@ -105,7 +105,7 @@ class RandomFunction(gof.Op):
...
@@ -105,7 +105,7 @@ class RandomFunction(gof.Op):
def
__setstate__
(
self
,
state
):
def
__setstate__
(
self
,
state
):
self
.
state
=
state
self
.
state
=
state
fn
,
outtype
,
inplace
,
ndim_added
=
state
fn
,
outtype
,
inplace
,
ndim_added
=
state
if
isinstance
(
fn
,
str
):
if
isinstance
(
fn
,
basestring
):
self
.
fn
=
getattr
(
numpy
.
random
.
RandomState
,
fn
)
self
.
fn
=
getattr
(
numpy
.
random
.
RandomState
,
fn
)
else
:
else
:
self
.
fn
=
fn
self
.
fn
=
fn
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论