Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
30c6b4bd
提交
30c6b4bd
authored
2月 24, 2014
作者:
Arnaud Bergeron
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Remove support for python scalars in idx_list.
上级
591fd120
隐藏空白字符变更
内嵌
并排
正在显示
1 个修改的文件
包含
4 行增加
和
22 行删除
+4
-22
subtensor.py
theano/tensor/subtensor.py
+4
-22
没有找到文件。
theano/tensor/subtensor.py
浏览文件 @
30c6b4bd
...
@@ -347,18 +347,10 @@ class Subtensor(Op):
...
@@ -347,18 +347,10 @@ 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
)
# There is a bug in numpy that results in isinstance(x, int) returning
elif
isinstance
(
entry
,
(
int
,
long
,
numpy
.
integer
)):
# False for numpy integers.
# Disallow the use of python scalars in idx_list
# See <http://projects.scipy.org/numpy/ticket/2235>.
raise
TypeError
(
"Python scalar in idx_list."
elif
isinstance
(
entry
,
numpy
.
integer
):
"Please report this error to theano-dev."
)
return
entry
# On Windows 64-bit, shapes are returned as Python long, as they can
# be bigger than what a Python int can hold.
# Shapes should always fit in a numpy.int64, and we support them better
# 2) In Python3, long replaced int. So we must assert it fit in int64.
elif
isinstance
(
entry
,
(
int
,
long
)):
entry64
=
numpy
.
int64
(
entry
)
return
entry64
else
:
else
:
raise
AdvancedIndexingError
(
Subtensor
.
e_indextype
,
entry
)
raise
AdvancedIndexingError
(
Subtensor
.
e_indextype
,
entry
)
...
@@ -405,7 +397,6 @@ class Subtensor(Op):
...
@@ -405,7 +397,6 @@ class Subtensor(Op):
def
__init__
(
self
,
idx_list
):
def
__init__
(
self
,
idx_list
):
self
.
idx_list
=
tuple
(
map
(
self
.
convert
,
idx_list
))
self
.
idx_list
=
tuple
(
map
(
self
.
convert
,
idx_list
))
self
.
perform_cache_cdata
=
None
@staticmethod
@staticmethod
def
my_as_scalar
(
a
):
def
my_as_scalar
(
a
):
...
@@ -471,18 +462,9 @@ class Subtensor(Op):
...
@@ -471,18 +462,9 @@ class Subtensor(Op):
out
,
=
out_
out
,
=
out_
x
=
inputs
[
0
]
x
=
inputs
[
0
]
# The subtensor (or idx_list) does not depend on the inputs.
# (and cdata was cached on initial call)
if
self
.
perform_cache_cdata
is
not
None
:
out
[
0
]
=
numpy
.
asarray
(
x
.
__getitem__
(
self
.
perform_cache_cdata
))
return
cdata
=
get_idx_list
(
inputs
,
self
.
idx_list
)
cdata
=
get_idx_list
(
inputs
,
self
.
idx_list
)
if
len
(
cdata
)
==
1
:
if
len
(
cdata
)
==
1
:
cdata
=
cdata
[
0
]
cdata
=
cdata
[
0
]
# (first call caches cdata here)
if
len
(
inputs
)
==
1
:
self
.
perform_cache_cdata
=
cdata
out
[
0
]
=
numpy
.
asarray
(
x
.
__getitem__
(
cdata
))
out
[
0
]
=
numpy
.
asarray
(
x
.
__getitem__
(
cdata
))
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论