Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
FluidDoc
提交
be5b298b
F
FluidDoc
项目概览
PaddlePaddle
/
FluidDoc
通知
10
Star
2
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
23
列表
看板
标记
里程碑
合并请求
111
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
F
FluidDoc
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
23
Issue
23
列表
看板
标记
里程碑
合并请求
111
合并请求
111
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
未验证
提交
be5b298b
编写于
8月 25, 2020
作者:
W
wangchaochaohu
提交者:
GitHub
8月 25, 2020
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
refine the doc for gather_nd test=develop (#2468)
上级
2bb43e14
变更
3
显示空白变更内容
内联
并排
Showing
3 changed file
with
81 addition
and
13 deletion
+81
-13
doc/fluid/api/tensor/gather_nd.rst
doc/fluid/api/tensor/gather_nd.rst
+7
-3
doc/fluid/api_cn/layers_cn/gather_nd_cn.rst
doc/fluid/api_cn/layers_cn/gather_nd_cn.rst
+4
-9
doc/fluid/api_cn/tensor_cn/gather_nd_cn.rst
doc/fluid/api_cn/tensor_cn/gather_nd_cn.rst
+70
-1
未找到文件。
doc/fluid/api/tensor/gather_nd.rst
浏览文件 @
be5b298b
.. _api_tensor_cn_gather_nd:
.. THIS FILE IS GENERATED BY `gen_doc.{py|sh}`
!DO NOT EDIT THIS FILE MANUALLY!
.. _api_tensor_manipulation_gather_nd:
gather_nd
gather_nd
-------------------------------
----------
:doc_source: paddle.fluid.layers.gather_nd
.. autofunction:: paddle.tensor.manipulation.gather_nd
:noindex:
doc/fluid/api_cn/layers_cn/gather_nd_cn.rst
浏览文件 @
be5b298b
...
@@ -5,11 +5,6 @@ gather_nd
...
@@ -5,11 +5,6 @@ gather_nd
.. py:function:: paddle.fluid.layers.gather_nd(input, index, name=None)
.. py:function:: paddle.fluid.layers.gather_nd(input, index, name=None)
:alias_main: paddle.gather_nd
:alias: paddle.gather_nd,paddle.tensor.gather_nd,paddle.tensor.manipulation.gather_nd
:old_api: paddle.fluid.layers.gather_nd
该OP是 :code:`gather` 的高维推广,并且支持多轴同时索引。 :code:`index` 是一个K维度的张量,它可以认为是从 :code:`input` 中取K-1维张量,每一个元素是一个切片:
该OP是 :code:`gather` 的高维推广,并且支持多轴同时索引。 :code:`index` 是一个K维度的张量,它可以认为是从 :code:`input` 中取K-1维张量,每一个元素是一个切片:
...
@@ -56,18 +51,18 @@ gather_nd
...
@@ -56,18 +51,18 @@ gather_nd
参数:
参数:
- **input** (
Variable) - 输入张量
,数据类型可以是int32,int64,float32,float64, bool。
- **input** (
Tensor) - 输入Tensor
,数据类型可以是int32,int64,float32,float64, bool。
- **index** (
Variable) - 输入的索引张量,数据类型为非负int32或非负
int64。它的维度 :code:`index.rank` 必须大于1,并且 :code:`index.shape[-1] <= input.rank` 。
- **index** (
Tensor) - 输入的索引Tensor,其数据类型为int32或者
int64。它的维度 :code:`index.rank` 必须大于1,并且 :code:`index.shape[-1] <= input.rank` 。
- **name**
(string) - 该层的名字,默认值为None,表示会自动命名
。
- **name**
(str,可选)- 具体用法请参见 :ref:`api_guide_Name` ,一般无需设置,默认值为None
。
返回:shape为index.shape[:-1] + input.shape[index.shape[-1]:]的Tensor|LoDTensor,数据类型与 :code:`input` 一致。
返回:shape为index.shape[:-1] + input.shape[index.shape[-1]:]的Tensor|LoDTensor,数据类型与 :code:`input` 一致。
返回类型:Variable
**代码示例**:
**代码示例**:
.. code-block:: python
.. code-block:: python
import paddle
import paddle.fluid as fluid
import paddle.fluid as fluid
x = fluid.layers.data(name='x', shape=[3, 4, 5], dtype='float32')
x = fluid.layers.data(name='x', shape=[3, 4, 5], dtype='float32')
index = fluid.layers.data(name='index', shape=[2, 2], dtype='int32')
index = fluid.layers.data(name='index', shape=[2, 2], dtype='int32')
...
...
doc/fluid/api_cn/tensor_cn/gather_nd_cn.rst
浏览文件 @
be5b298b
...
@@ -2,6 +2,75 @@
...
@@ -2,6 +2,75 @@
gather_nd
gather_nd
-------------------------------
-------------------------------
:doc_source: paddle.fluid.layers.gather_nd
.. py:function:: paddle.gather_nd(x, index, name=None)
该OP是 :code:`gather` 的高维推广,并且支持多轴同时索引。 :code:`index` 是一个K维度的张量,它可以认为是从 :code:`x` 中取K-1维张量,每一个元素是一个切片:
.. math::
output[(i_0, ..., i_{K-2})] = x[index[(i_0, ..., i_{K-2})]]
显然, :code:`index.shape[-1] <= x.rank` 并且输出张量的维度是 :code:`index.shape[:-1] + x.shape[index.shape[-1]:]` 。
示例:
::
给定:
x = [[[ 0, 1, 2, 3],
[ 4, 5, 6, 7],
[ 8, 9, 10, 11]],
[[12, 13, 14, 15],
[16, 17, 18, 19],
[20, 21, 22, 23]]]
x.shape = (2, 3, 4)
- 案例 1:
index = [[1]]
gather_nd(x, index)
= [x[1, :, :]]
= [[12, 13, 14, 15],
[16, 17, 18, 19],
[20, 21, 22, 23]]
- 案例 2:
index = [[0,2]]
gather_nd(x, index)
= [x[0, 2, :]]
= [8, 9, 10, 11]
- 案例 3:
index = [[1, 2, 3]]
gather_nd(x, index)
= [x[1, 2, 3]]
= [23]
参数:
- **x** (Tensor) - 输入Tensor,数据类型可以是int32,int64,float32,float64, bool。
- **index** (Tensor) - 输入的索引Tensor,其数据类型int32或者int64。它的维度 :code:`index.rank` 必须大于1,并且 :code:`index.shape[-1] <= x.rank` 。
- **name** (str,可选)- 具体用法请参见 :ref:`api_guide_Name` ,一般无需设置,默认值为None。
返回:shape为index.shape[:-1] + x.shape[index.shape[-1]:]的Tensor,数据类型与 :code:`x` 一致。
**代码示例**:
.. code-block:: python
import paddle
import numpy as np
paddle.disable_static()
np_x = np.array([[[1, 2], [3, 4], [5, 6]],
[[7, 8], [9, 10], [11, 12]]])
np_index = [[0, 1]]
x = paddle.to_tensor(np_x)
index = paddle.to_tensor(np_index)
output = paddle.gather_nd(x, index) #[[3, 4]]
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录