Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
1c0dec42
提交
1c0dec42
authored
1月 12, 2015
作者:
abergeron
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #2392 from dmitriy-serdyuk/none_checks
Fixed 'comparison with None' warnings
上级
925dd14b
e17ba874
隐藏空白字符变更
内嵌
并排
正在显示
3 个修改的文件
包含
10 行增加
和
10 行删除
+10
-10
opt.py
theano/tensor/opt.py
+5
-5
subtensor.py
theano/tensor/subtensor.py
+4
-4
var.py
theano/tensor/var.py
+1
-1
没有找到文件。
theano/tensor/opt.py
浏览文件 @
1c0dec42
...
@@ -1935,11 +1935,11 @@ def local_useless_subtensor(node):
...
@@ -1935,11 +1935,11 @@ def local_useless_subtensor(node):
# If idx is not a slice, this means we remove this dimension
# If idx is not a slice, this means we remove this dimension
# from the output, so the subtensor is not useless
# from the output, so the subtensor is not useless
return
False
return
False
if
idx
.
start
not
in
[
0
,
None
]
:
if
idx
.
start
is
not
None
and
idx
.
start
!=
0
:
# If the start of the slice is different from 0, or is a
# If the start of the slice is different from 0, or is a
# variable, then we assume the subtensor is not useless
# variable, then we assume the subtensor is not useless
return
False
return
False
if
idx
.
step
not
in
[
1
,
None
]
:
if
idx
.
step
is
not
None
and
idx
.
step
!=
1
:
# If we are going backwards, or skipping elements, then this
# If we are going backwards, or skipping elements, then this
# is not a useless subtensor
# is not a useless subtensor
return
False
return
False
...
@@ -2543,9 +2543,9 @@ def local_setsubtensor_of_constants(node):
...
@@ -2543,9 +2543,9 @@ def local_setsubtensor_of_constants(node):
except
NotScalarConstantError
:
except
NotScalarConstantError
:
pass
pass
if
(
replace_x
==
replace_y
and
if
(
replace_x
is
not
None
and
replace_
x
is
not
None
and
replace_
y
is
not
None
and
replace_
y
is
not
None
):
replace_
x
==
replace_y
):
return
[
x
]
return
[
x
]
else
:
else
:
return
False
return
False
...
...
theano/tensor/subtensor.py
浏览文件 @
1c0dec42
...
@@ -137,11 +137,11 @@ def get_canonical_form_slice(theslice, length):
...
@@ -137,11 +137,11 @@ def get_canonical_form_slice(theslice, length):
# in the generic case below.
# in the generic case below.
if
step
==
1
:
if
step
==
1
:
is_start_0
=
(
is_start_0
=
(
start
i
n
[
None
,
0
]
or
start
i
s
None
or
start
==
0
or
(
is_start_constant
and
is_length_constant
and
(
is_start_constant
and
is_length_constant
and
start
<
0
and
start
+
length
<=
0
))
start
<
0
and
start
+
length
<=
0
))
is_stop_length
=
(
is_stop_length
=
(
stop
i
n
[
None
,
length
,
maxsize
]
or
stop
i
s
None
or
stop
in
[
length
,
maxsize
]
or
(
is_stop_constant
and
is_length_constant
and
(
is_stop_constant
and
is_length_constant
and
stop
>=
length
))
stop
>=
length
))
if
is_start_0
:
if
is_start_0
:
...
@@ -217,7 +217,7 @@ def get_canonical_form_slice(theslice, length):
...
@@ -217,7 +217,7 @@ def get_canonical_form_slice(theslice, length):
start
=
switch
(
ge
(
start
,
length
),
start
=
switch
(
ge
(
start
,
length
),
switch_neg_step
(
length
-
1
,
length
),
switch_neg_step
(
length
-
1
,
length
),
start
)
start
)
if
stop
i
n
[
None
,
maxsize
]
:
if
stop
i
s
None
or
stop
==
maxsize
:
# The special "maxsize" case is probably not needed here,
# The special "maxsize" case is probably not needed here,
# as slices containing maxsize are not generated by
# as slices containing maxsize are not generated by
# __getslice__ anymore.
# __getslice__ anymore.
...
@@ -478,7 +478,7 @@ class Subtensor(Op):
...
@@ -478,7 +478,7 @@ class Subtensor(Op):
start
=
get_scalar_constant_value
(
start
)
start
=
get_scalar_constant_value
(
start
)
except
NotScalarConstantError
:
except
NotScalarConstantError
:
pass
pass
if
start
i
n
[
None
,
0
]
:
if
start
i
s
None
or
start
==
0
:
start
=
p
.
start
start
=
p
.
start
if
start
is
None
:
if
start
is
None
:
start
=
0
start
=
0
...
...
theano/tensor/var.py
浏览文件 @
1c0dec42
...
@@ -369,7 +369,7 @@ class _tensor_py_operators:
...
@@ -369,7 +369,7 @@ class _tensor_py_operators:
axis
=
None
axis
=
None
for
i
,
arg
in
enumerate
(
args
):
for
i
,
arg
in
enumerate
(
args
):
try
:
try
:
if
arg
!=
numpy
.
newaxis
:
if
arg
is
not
numpy
.
newaxis
:
theano
.
tensor
.
subtensor
.
Subtensor
.
convert
(
arg
)
theano
.
tensor
.
subtensor
.
Subtensor
.
convert
(
arg
)
except
theano
.
tensor
.
subtensor
.
AdvancedIndexingError
:
except
theano
.
tensor
.
subtensor
.
AdvancedIndexingError
:
if
advanced
:
if
advanced
:
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论