Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
c5f8cc3d
提交
c5f8cc3d
authored
5月 02, 2013
作者:
lamblin
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #1362 from nouiz/doc_adv_idx
Document that we now support Integer advanced indexing (not boolean mask)
上级
cb371ba7
4dd2d1ba
显示空白字符变更
内嵌
并排
正在显示
1 个修改的文件
包含
22 行增加
和
8 行删除
+22
-8
basic.txt
doc/library/tensor/basic.txt
+22
-8
没有找到文件。
doc/library/tensor/basic.txt
浏览文件 @
c5f8cc3d
...
...
@@ -897,17 +897,31 @@ Reductions
Indexing
========
Like
nump
y, Theano distinguishes between *basic* and *advanced* indexing.
Like
NumP
y, Theano distinguishes between *basic* and *advanced* indexing.
Theano fully supports basic indexing
(see `
numpy's basic
indexing <http://docs.scipy.org/doc/numpy/reference/arrays.indexing.html>`_).
(see `
NumPy's
indexing <http://docs.scipy.org/doc/numpy/reference/arrays.indexing.html>`_).
Advanced indexing is almost entirely unsupported (for now).
The one sort of advanced indexing that is supported is the retrieval of the c[i]'th element of each
row of a matrix x:
`Integer advanced indexing
<http://docs.scipy.org/doc/numpy/reference/arrays.indexing.html#integer>`_
will be supported in 0.6rc4 (or the development version). We do not
support boolean masks, as Theano do not have a boolean type (we use
int8 for the output of logic operator). To imitate boolean advanced
indexing, you can do::
>>> x = T.fmatrix()
>>> c = T.lvector()
>>> x[T.arange(c.shape[0]), c]
# NumPy indexing with a mask
n = np.arange(9).reshape(3,3)
n[n>4] # array([5, 6, 7, 8])
# Theano indexing with a "mask"
t = tt.arange(9).reshape((3,3))
t[t>4].eval() # an array with shape (3, 3, 3)
# getting a Theano result like NumPy
t[(t>4).nonzero()].eval() # array([5, 6, 7, 8])
The gradient of Advanced indexing need in many cases NumPy
1.8. It isn't released as of April 30, 2013. You can use NumPy
development version to have this feature now.
Index-assignment is *not* supported. If you want to do something like ``a[5]
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论