Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
10082356
提交
10082356
authored
10月 05, 2020
作者:
Brandon T. Willard
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Clean up Subtensor Op and its exceptions
上级
7857774b
显示空白字符变更
内嵌
并排
正在显示
1 个修改的文件
包含
11 行增加
和
41 行删除
+11
-41
subtensor.py
theano/tensor/subtensor.py
+11
-41
没有找到文件。
theano/tensor/subtensor.py
浏览文件 @
10082356
...
@@ -432,40 +432,8 @@ def indexed_result_shape(array_shape, indices, indices_are_shapes=False):
...
@@ -432,40 +432,8 @@ def indexed_result_shape(array_shape, indices, indices_are_shapes=False):
class
Subtensor
(
Op
):
class
Subtensor
(
Op
):
"""
"""Basic NumPy indexing operator."""
Return a subtensor view.
The inputs array is the tensor x, followed by scalar integer types.
TODO: WRITEME: how are the scalar integer variables formatted?
This class uses a relatively complex internal representation of the inputs
to remember how the input tensor x should be sliced.
idx_list: instance variable TODO: WRITEME: is this a list or a tuple?
(old docstring gives two conflicting
descriptions)
elements are either integers, theano scalar types, or slices.
one element per "explicitly named dimension"
TODO: WRITEME: what is an "explicitly named dimension" ?
if integer:
indexes into the inputs array
if slice:
start/stop/step members of each slice are integer indices
into the inputs array or None
integer indices be actual integers or theano scalar types
Note that the idx_list defines the Op, so two Subtensor instances are
considered to be different Ops if they have different idx_list fields.
This means that the entries in it are theano Types, not theano Variables.
@todo: add support for advanced tensor indexing (in Subtensor_dx too).
"""
e_subslice
=
"nested slicing is not supported"
e_indextype
=
"Invalid index type or slice for Subtensor"
debug
=
0
check_input
=
False
check_input
=
False
view_map
=
{
0
:
[
0
]}
view_map
=
{
0
:
[
0
]}
_f16_ok
=
True
_f16_ok
=
True
...
@@ -513,27 +481,29 @@ class Subtensor(Op):
...
@@ -513,27 +481,29 @@ class Subtensor(Op):
when would that happen?
when would that happen?
"""
"""
invalid_scal_types
=
[
scal
.
float64
,
scal
.
float32
,
scal
.
float16
]
invalid_scal_types
=
(
scal
.
float64
,
scal
.
float32
,
scal
.
float16
)
scal_types
=
[
scal
.
int64
,
scal
.
int32
,
scal
.
int16
,
scal
.
int8
]
scal_types
=
(
scal
.
int64
,
scal
.
int32
,
scal
.
int16
,
scal
.
int8
)
tensor_types
=
[
tensor_types
=
(
theano
.
tensor
.
lscalar
,
theano
.
tensor
.
lscalar
,
theano
.
tensor
.
iscalar
,
theano
.
tensor
.
iscalar
,
theano
.
tensor
.
wscalar
,
theano
.
tensor
.
wscalar
,
theano
.
tensor
.
bscalar
,
theano
.
tensor
.
bscalar
,
]
)
invalid_tensor_types
=
[
invalid_tensor_types
=
(
theano
.
tensor
.
fscalar
,
theano
.
tensor
.
fscalar
,
theano
.
tensor
.
dscalar
,
theano
.
tensor
.
dscalar
,
theano
.
tensor
.
cscalar
,
theano
.
tensor
.
cscalar
,
theano
.
tensor
.
zscalar
,
theano
.
tensor
.
zscalar
,
]
)
if
(
if
(
isinstance
(
entry
,
(
np
.
ndarray
,
theano
.
tensor
.
Variable
))
isinstance
(
entry
,
(
np
.
ndarray
,
theano
.
tensor
.
Variable
))
and
hasattr
(
entry
,
"dtype"
)
and
hasattr
(
entry
,
"dtype"
)
and
entry
.
dtype
==
"bool"
and
entry
.
dtype
==
"bool"
):
):
raise
AdvancedBooleanIndexingError
(
Subtensor
.
e_indextype
,
entry
)
raise
AdvancedBooleanIndexingError
(
"Invalid index type or slice for Subtensor"
)
if
isinstance
(
entry
,
gof
.
Variable
)
and
(
if
isinstance
(
entry
,
gof
.
Variable
)
and
(
entry
.
type
in
invalid_scal_types
or
entry
.
type
in
invalid_tensor_types
entry
.
type
in
invalid_scal_types
or
entry
.
type
in
invalid_tensor_types
...
@@ -587,7 +557,7 @@ class Subtensor(Op):
...
@@ -587,7 +557,7 @@ class Subtensor(Op):
"Python scalar in idx_list."
"Please report this error to theano-dev."
"Python scalar in idx_list."
"Please report this error to theano-dev."
)
)
else
:
else
:
raise
AdvancedIndexingError
(
Subtensor
.
e_indextype
,
entry
)
raise
AdvancedIndexingError
(
"Invalid index type or slice for Subtensor"
)
def
get_constant_idx
(
def
get_constant_idx
(
self
,
inputs
,
allow_partial
=
False
,
only_process_constants
=
False
,
elemwise
=
True
self
,
inputs
,
allow_partial
=
False
,
only_process_constants
=
False
,
elemwise
=
True
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论