Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
48aa9e84
提交
48aa9e84
authored
11月 15, 2011
作者:
Razvan Pascanu
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fixed the confusion between python all / any and theano all / any
上级
cf5e084b
隐藏空白字符变更
内嵌
并排
正在显示
1 个修改的文件
包含
11 行增加
和
9 行删除
+11
-9
basic.py
theano/tensor/basic.py
+11
-9
没有找到文件。
theano/tensor/basic.py
浏览文件 @
48aa9e84
...
...
@@ -34,6 +34,8 @@ _logger=logging.getLogger("theano.tensor.basic")
#This is needed as we will hide it later
python_complex
=
complex
python_any
=
any
python_all
=
all
# Define common subsets of dtypes (as strings).
int_dtypes
=
map
(
str
,
scal
.
int_types
)
...
...
@@ -54,7 +56,7 @@ def check_equal_numpy(x, y):
if
isinstance
(
x
,
numpy
.
ndarray
)
and
isinstance
(
y
,
numpy
.
ndarray
):
return
x
.
dtype
==
y
.
dtype
and
x
.
shape
==
y
.
shape
and
numpy
.
any
(
abs
(
x
-
y
)
<
1e-10
)
elif
isinstance
(
x
,
numpy
.
random
.
RandomState
)
and
isinstance
(
y
,
numpy
.
random
.
RandomState
):
return
all
(
numpy
.
all
(
a
==
b
)
for
a
,
b
in
zip
(
x
.
__getstate__
(),
y
.
__getstate__
()))
return
python_
all
(
numpy
.
all
(
a
==
b
)
for
a
,
b
in
zip
(
x
.
__getstate__
(),
y
.
__getstate__
()))
else
:
return
x
==
y
...
...
@@ -142,7 +144,7 @@ def as_tensor_variable(x, name=None, ndim=None):
return
shape_padleft
(
x
,
n_ones
=
(
ndim
-
x
.
type
.
ndim
))
else
:
return
x
if
isinstance
(
x
,
(
tuple
,
list
))
and
any
(
isinstance
(
xi
,
Variable
)
for
xi
in
x
):
if
isinstance
(
x
,
(
tuple
,
list
))
and
python_
any
(
isinstance
(
xi
,
Variable
)
for
xi
in
x
):
try
:
return
stack
(
*
x
)
except
(
TypeError
,
ValueError
):
...
...
@@ -465,7 +467,7 @@ def get_constant_value(v):
# Ensure the Join is joining only scalar variables (so that
# the constant value can be found at the same index as the one
# used in the sub-tensor).
all
(
var
.
ndim
==
0
for
var
in
v
.
owner
.
inputs
[
0
]
.
owner
.
inputs
)
and
python_
all
(
var
.
ndim
==
0
for
var
in
v
.
owner
.
inputs
[
0
]
.
owner
.
inputs
)
and
len
(
v
.
owner
.
op
.
idx_list
)
==
1
):
# Note the '+ 1' is because the first argument to Join is the
...
...
@@ -479,7 +481,7 @@ def get_constant_value(v):
theano
.
tensor
.
opt
.
MakeVector
)
and
# MakeVector normally accept only scalar as input.
# We put this check in case there is change in the future
all
(
var
.
ndim
==
0
for
var
in
v
.
owner
.
inputs
[
0
]
.
owner
.
inputs
)
and
python_
all
(
var
.
ndim
==
0
for
var
in
v
.
owner
.
inputs
[
0
]
.
owner
.
inputs
)
and
len
(
v
.
owner
.
op
.
idx_list
)
==
1
):
ret
=
v
.
owner
.
inputs
[
0
]
.
owner
.
inputs
[
v
.
owner
.
op
.
idx_list
[
0
]]
...
...
@@ -812,7 +814,7 @@ class TensorType(Type):
if
b
in
named_broadcastable
:
bcast
=
named_broadcastable
[
b
]
else
:
if
any
(
b
):
if
python_
any
(
b
):
bcast
=
str
(
b
)
else
:
bcast
=
'
%
iD'
%
len
(
b
)
...
...
@@ -3935,7 +3937,7 @@ class Split(Op):
if
numpy
.
sum
(
splits
)
!=
len_along_axis
:
raise
ValueError
(
'The splits sum to
%
s, expected
%
s'
%
(
numpy
.
sum
(
splits
),
len_along_axis
))
if
not
all
(
splits
):
if
not
python_
all
(
splits
):
raise
ValueError
(
'Cannot have a split of zero.'
)
# Checking is done, let's roll the splitting algorithm!
...
...
@@ -4108,7 +4110,7 @@ class Join(Op):
def
_make_node_internal
(
self
,
axis
,
tensors
,
as_tensor_variable_args
,
output_maker
):
orig
=
as_tensor_variable_args
if
not
all
(
targs
.
type
.
ndim
for
targs
in
as_tensor_variable_args
):
if
not
python_
all
(
targs
.
type
.
ndim
for
targs
in
as_tensor_variable_args
):
raise
TypeError
(
'Join cannot handle arguments of dimension 0. For joining scalar values, see @stack'
);
# Handle single-tensor joins immediately.
if
len
(
as_tensor_variable_args
)
==
1
:
...
...
@@ -4166,7 +4168,7 @@ class Join(Op):
outputs
=
[
output_maker
(
bcastable
)]
node
=
Apply
(
self
,
inputs
,
outputs
)
if
any
(
not
x
.
type
.
broadcastable
[
0
]
for
x
in
orig
):
if
python_
any
(
not
x
.
type
.
broadcastable
[
0
]
for
x
in
orig
):
node
.
tag
.
shape_zero
=
None
else
:
node
.
tag
.
shape_zero
=
len
(
orig
)
...
...
@@ -4759,7 +4761,7 @@ def arange(start, stop=None, step=1, dtype=None):
config
.
floatX
==
'float32'
and
numpy_dtype
==
'float64'
and
# No explicit float64 in the three arguments?
all
(
dt
!=
'float64'
python_
all
(
dt
!=
'float64'
for
dt
in
[
s
.
dtype
for
s
in
(
start
,
stop
,
step
)])):
# We use float32 instead.
assert
dtype
!=
'float64'
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论