Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
fb4a7b3c
提交
fb4a7b3c
authored
5月 03, 2015
作者:
David Warde-Farley
提交者:
Arnaud Bergeron
6月 22, 2015
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Use integer_types in place of long.
上级
61c3957b
显示空白字符变更
内嵌
并排
正在显示
6 个修改的文件
包含
17 行增加
和
14 行删除
+17
-14
graph.py
theano/gof/graph.py
+2
-2
printing.py
theano/printing.py
+2
-2
scan_opt.py
theano/scan_module/scan_opt.py
+4
-3
basic.py
theano/tensor/basic.py
+4
-4
opt.py
theano/tensor/opt.py
+2
-1
subtensor.py
theano/tensor/subtensor.py
+3
-2
没有找到文件。
theano/gof/graph.py
浏览文件 @
fb4a7b3c
...
@@ -16,7 +16,7 @@ from itertools import count
...
@@ -16,7 +16,7 @@ from itertools import count
import
theano
import
theano
import
warnings
import
warnings
from
theano.gof
import
utils
from
theano.gof
import
utils
from
theano.compat.six
import
string_types
from
theano.compat.six
import
string_types
,
integer_types
from
theano.misc.ordered_set
import
OrderedSet
from
theano.misc.ordered_set
import
OrderedSet
# Lazy imports to avoid circular dependencies.
# Lazy imports to avoid circular dependencies.
...
@@ -147,7 +147,7 @@ class Apply(Node):
...
@@ -147,7 +147,7 @@ class Apply(Node):
else
:
else
:
raise
AttributeError
(
raise
AttributeError
(
"
%
s.default_output should be an output index."
%
self
.
op
)
"
%
s.default_output should be an output index."
%
self
.
op
)
elif
not
isinstance
(
do
,
(
int
,
long
)
):
elif
not
isinstance
(
do
,
integer_types
):
raise
AttributeError
(
"
%
s.default_output should be an int or long"
%
raise
AttributeError
(
"
%
s.default_output should be an int or long"
%
self
.
op
)
self
.
op
)
elif
do
<
0
or
do
>=
len
(
self
.
outputs
):
elif
do
<
0
or
do
>=
len
(
self
.
outputs
):
...
...
theano/printing.py
浏览文件 @
fb4a7b3c
...
@@ -13,7 +13,7 @@ import hashlib
...
@@ -13,7 +13,7 @@ import hashlib
import
numpy
as
np
import
numpy
as
np
import
collections
import
collections
from
theano.compat.six
import
string_types
from
theano.compat.six
import
string_types
,
integer_types
try
:
try
:
import
pydot
as
pd
import
pydot
as
pd
...
@@ -112,7 +112,7 @@ def debugprint(obj, depth=-1, print_type=False,
...
@@ -112,7 +112,7 @@ def debugprint(obj, depth=-1, print_type=False,
results_to_print
.
extend
(
obj
.
outputs
)
results_to_print
.
extend
(
obj
.
outputs
)
profile_list
.
extend
([
None
for
item
in
obj
.
outputs
])
profile_list
.
extend
([
None
for
item
in
obj
.
outputs
])
order
=
obj
.
toposort
()
order
=
obj
.
toposort
()
elif
isinstance
(
obj
,
(
int
,
long
,
float
,
np
.
ndarray
)):
elif
isinstance
(
obj
,
(
int
eger_types
,
float
,
np
.
ndarray
)):
print
(
obj
)
print
(
obj
)
elif
isinstance
(
obj
,
(
theano
.
In
,
theano
.
Out
)):
elif
isinstance
(
obj
,
(
theano
.
In
,
theano
.
Out
)):
results_to_print
.
append
(
obj
.
variable
)
results_to_print
.
append
(
obj
.
variable
)
...
...
theano/scan_module/scan_opt.py
浏览文件 @
fb4a7b3c
...
@@ -67,6 +67,7 @@ from theano import tensor
...
@@ -67,6 +67,7 @@ from theano import tensor
from
theano.tensor
import
opt
,
get_scalar_constant_value
from
theano.tensor
import
opt
,
get_scalar_constant_value
from
theano
import
gof
from
theano
import
gof
from
theano.compat
import
OrderedDict
from
theano.compat
import
OrderedDict
from
theano.compat.six
import
integer_types
from
theano.gof.opt
import
Optimizer
from
theano.gof.opt
import
Optimizer
from
theano.gof
import
toolbox
,
DestroyHandler
,
InconsistencyError
from
theano.gof
import
toolbox
,
DestroyHandler
,
InconsistencyError
from
theano.compile
import
optdb
from
theano.compile
import
optdb
...
@@ -1163,15 +1164,15 @@ class ScanSaveMem(gof.Optimizer):
...
@@ -1163,15 +1164,15 @@ class ScanSaveMem(gof.Optimizer):
if
isinstance
(
stop
,
tensor
.
Variable
):
if
isinstance
(
stop
,
tensor
.
Variable
):
global_nsteps
[
'sym'
]
+=
[
stop
]
global_nsteps
[
'sym'
]
+=
[
stop
]
# not if it is maxsize
# not if it is maxsize
elif
(
type
(
stop
)
in
(
int
,
long
)
and
elif
(
type
(
stop
)
in
integer_types
and
stop
==
maxsize
):
stop
==
maxsize
):
global_nsteps
=
None
global_nsteps
=
None
# yes if it is a int k, 0 < k < maxsize
# yes if it is a int k, 0 < k < maxsize
elif
(
type
(
stop
)
in
(
int
,
long
)
and
elif
(
type
(
stop
)
in
integer_types
and
global_nsteps
[
'real'
]
<
stop
):
global_nsteps
[
'real'
]
<
stop
):
global_nsteps
[
'real'
]
=
stop
global_nsteps
[
'real'
]
=
stop
# yes if it is a int k, 0 < k < maxsize
# yes if it is a int k, 0 < k < maxsize
elif
(
type
(
stop
)
in
(
int
,
long
)
and
stop
>
0
):
elif
(
type
(
stop
)
in
integer_types
and
stop
>
0
):
pass
pass
# not otherwise
# not otherwise
else
:
else
:
...
...
theano/tensor/basic.py
浏览文件 @
fb4a7b3c
...
@@ -357,7 +357,7 @@ def constant_or_value(x, rtype, name=None, ndim=None, dtype=None):
...
@@ -357,7 +357,7 @@ def constant_or_value(x, rtype, name=None, ndim=None, dtype=None):
x_
=
autocast_int
(
x
)
x_
=
autocast_int
(
x
)
elif
rtype
is
TensorConstant
and
isinstance
(
x
,
float
):
elif
rtype
is
TensorConstant
and
isinstance
(
x
,
float
):
x_
=
autocast_float
(
x
)
x_
=
autocast_float
(
x
)
elif
rtype
is
TensorConstant
and
isinstance
(
x
,
long
):
elif
rtype
is
TensorConstant
and
isinstance
(
x
,
integer_types
):
# We need to address the case where a long number is used in a
# We need to address the case where a long number is used in a
# Theano graph, because on Windows 64, all shapes are expressed
# Theano graph, because on Windows 64, all shapes are expressed
# with longs.
# with longs.
...
@@ -3870,8 +3870,8 @@ def stack(*tensors):
...
@@ -3870,8 +3870,8 @@ def stack(*tensors):
# See ticket #660
# See ticket #660
if
numpy
.
all
(
if
numpy
.
all
(
[
# in case there is direct int in tensors.
[
# in case there is direct int in tensors.
isinstance
(
t
,
(
numpy
.
number
,
float
,
int
,
python_complex
,
isinstance
(
t
,
(
numpy
.
number
,
float
,
int
eger_types
,
long
))
or
python_complex
))
or
(
isinstance
(
t
,
Variable
)
and
(
isinstance
(
t
,
Variable
)
and
isinstance
(
t
.
type
,
TensorType
)
and
isinstance
(
t
.
type
,
TensorType
)
and
t
.
ndim
==
0
)
t
.
ndim
==
0
)
...
@@ -4436,7 +4436,7 @@ def tile(x, reps, ndim=None):
...
@@ -4436,7 +4436,7 @@ def tile(x, reps, ndim=None):
iter
(
reps
)
iter
(
reps
)
except
TypeError
:
except
TypeError
:
raise
ValueError
(
"reps must be iterable"
)
raise
ValueError
(
"reps must be iterable"
)
if
not
numpy
.
all
([
isinstance
(
r
,
(
int
,
long
)
)
or
if
not
numpy
.
all
([
isinstance
(
r
,
integer_types
)
or
(
isinstance
(
r
,
TensorVariable
)
and
(
isinstance
(
r
,
TensorVariable
)
and
r
.
dtype
in
[
"int8"
,
"int16"
,
"int32"
,
"int64"
])
for
r
in
reps
]):
r
.
dtype
in
[
"int8"
,
"int16"
,
"int32"
,
"int64"
])
for
r
in
reps
]):
raise
ValueError
(
"elements of reps must be scalars of integer dtype"
)
raise
ValueError
(
"elements of reps must be scalars of integer dtype"
)
...
...
theano/tensor/opt.py
浏览文件 @
fb4a7b3c
...
@@ -21,6 +21,7 @@ import numpy as N # guys... please don't do this in the library :(
...
@@ -21,6 +21,7 @@ import numpy as N # guys... please don't do this in the library :(
import
theano
import
theano
from
theano
import
gof
from
theano
import
gof
from
theano.compat.six
import
integer_types
from
theano.compat.six.moves
import
reduce
from
theano.compat.six.moves
import
reduce
from
theano.gof
import
opt
,
InconsistencyError
,
TopoOptimizer
,
graph
from
theano.gof
import
opt
,
InconsistencyError
,
TopoOptimizer
,
graph
from
theano.gof
import
Variable
,
Constant
from
theano.gof
import
Variable
,
Constant
...
@@ -840,7 +841,7 @@ class ShapeFeature(object):
...
@@ -840,7 +841,7 @@ class ShapeFeature(object):
# don't make the optimizer merge a zillion ones together
# don't make the optimizer merge a zillion ones together
# by always returning the same object to represent 1
# by always returning the same object to represent 1
return
self
.
lscalar_one
return
self
.
lscalar_one
if
(
type
(
s_i
)
in
(
int
,
long
)
or
if
(
type
(
s_i
)
in
integer_types
or
isinstance
(
s_i
,
numpy
.
integer
)
or
isinstance
(
s_i
,
numpy
.
integer
)
or
(
isinstance
(
s_i
,
numpy
.
ndarray
)
and
s_i
.
ndim
==
0
)):
(
isinstance
(
s_i
,
numpy
.
ndarray
)
and
s_i
.
ndim
==
0
)):
# this shape is a constant
# this shape is a constant
...
...
theano/tensor/subtensor.py
浏览文件 @
fb4a7b3c
...
@@ -10,6 +10,7 @@ _logger = logging.getLogger("theano.tensor.subtensor")
...
@@ -10,6 +10,7 @@ _logger = logging.getLogger("theano.tensor.subtensor")
import
numpy
import
numpy
import
theano
import
theano
from
theano.compat.six
import
integer_types
from
theano.gradient
import
DisconnectedType
from
theano.gradient
import
DisconnectedType
from
theano
import
gof
from
theano
import
gof
from
theano.gof
import
Apply
,
Constant
,
hashtype
,
Op
,
Type
,
MethodNotDefined
from
theano.gof
import
Apply
,
Constant
,
hashtype
,
Op
,
Type
,
MethodNotDefined
...
@@ -59,7 +60,7 @@ def make_constant(args):
...
@@ -59,7 +60,7 @@ def make_constant(args):
return
slice
(
conv
(
a
.
start
),
return
slice
(
conv
(
a
.
start
),
conv
(
a
.
stop
),
conv
(
a
.
stop
),
conv
(
a
.
step
))
conv
(
a
.
step
))
elif
isinstance
(
a
,
(
int
,
long
,
numpy
.
integer
)):
elif
isinstance
(
a
,
(
int
eger_types
,
numpy
.
integer
)):
return
scal
.
ScalarConstant
(
scal
.
int64
,
a
)
return
scal
.
ScalarConstant
(
scal
.
int64
,
a
)
else
:
else
:
return
a
return
a
...
@@ -376,7 +377,7 @@ class Subtensor(Op):
...
@@ -376,7 +377,7 @@ class Subtensor(Op):
slice_c
=
None
slice_c
=
None
return
slice
(
slice_a
,
slice_b
,
slice_c
)
return
slice
(
slice_a
,
slice_b
,
slice_c
)
elif
isinstance
(
entry
,
(
int
,
long
,
numpy
.
integer
)):
elif
isinstance
(
entry
,
(
int
eger_types
,
numpy
.
integer
)):
# Disallow the use of python scalars in idx_list
# Disallow the use of python scalars in idx_list
raise
TypeError
(
"Python scalar in idx_list."
raise
TypeError
(
"Python scalar in idx_list."
"Please report this error to theano-dev."
)
"Please report this error to theano-dev."
)
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论