Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
FluidDoc
提交
7a00da9d
F
FluidDoc
项目概览
PaddlePaddle
/
FluidDoc
通知
7
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看板
未验证
提交
7a00da9d
编写于
8月 24, 2020
作者:
W
wangchaochaohu
提交者:
GitHub
8月 24, 2020
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
refine the doc for gather api test=develop (#2467)
上级
e9de0c9a
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
46 addition
and
29 deletion
+46
-29
doc/fluid/api/tensor/gather.rst
doc/fluid/api/tensor/gather.rst
+8
-3
doc/fluid/api_cn/layers_cn/gather_cn.rst
doc/fluid/api_cn/layers_cn/gather_cn.rst
+6
-4
doc/fluid/api_cn/tensor_cn/gather_cn.rst
doc/fluid/api_cn/tensor_cn/gather_cn.rst
+32
-22
未找到文件。
doc/fluid/api/tensor/gather.rst
浏览文件 @
7a00da9d
.. _api_tensor_cn_gather:
.. THIS FILE IS GENERATED BY `gen_doc.{py|sh}`
!DO NOT EDIT THIS FILE MANUALLY!
.. _api_tensor_manipulation_gather:
gather
-------------------------------
:doc_source: paddle.fluid.layers.gather
--------
.. autofunction:: paddle.tensor.manipulation.gather
:noindex:
doc/fluid/api_cn/layers_cn/gather_cn.rst
浏览文件 @
7a00da9d
...
...
@@ -8,7 +8,7 @@ gather
根据索引 ``index`` 获取输入
(input)
的最外层维度的条目,并将它们拼接在一起。
根据索引 ``index`` 获取输入
``input``
的最外层维度的条目,并将它们拼接在一起。
.. math::
...
...
@@ -29,13 +29,15 @@ gather
参数:
- **input** (
Variable
) - 输入, 秩 ``rank >= 1`` , 支持的数据类型包括 int32、int64、float32、float64 和 uint8 (CPU)、float16(GPU) 。
- **index** (
Variable
) - 索引,秩 ``rank = 1``, 数据类型为 int32 或 int64。
- **input** (
Tensor
) - 输入, 秩 ``rank >= 1`` , 支持的数据类型包括 int32、int64、float32、float64 和 uint8 (CPU)、float16(GPU) 。
- **index** (
Tensor
) - 索引,秩 ``rank = 1``, 数据类型为 int32 或 int64。
- **overwrite** (bool) - 具有相同索引时在反向更新梯度的模式。如果为 ``True`` ,则使用覆盖模式更新相同索引的梯度;如果为 ``False`` ,则使用累积模式更新相同索引的梯度。默认值为 ``True`` 。
返回:和输入的秩相同的输出张量。
返回类型:Variable
抛出异常:
- ``TypeError``: - ``x`` 必须是Tensor 并且 ``x`` 的数据类型必须是uint8、float16、float32、float64、int32或者int64。
- ``TypeError``: - ``index`` 必须是Tensor并且数据类型必须是int32或者int64。
**代码示例**
...
...
doc/fluid/api_cn/tensor_cn/gather_cn.rst
浏览文件 @
7a00da9d
...
...
@@ -2,40 +2,50 @@
gather
-------------------------------
.. py:function:: paddle.
tensor.gather(input, index, overwrite=Tru
e)
.. py:function:: paddle.
gather(x, index, axis=None, name=Non
e)
:alias_main: paddle.gather
:alias: paddle.gather,paddle.tensor.gather,paddle.tensor.manipulation.gather
:update_api: paddle.fluid.layers.gather
根据索引 index 获取输入 ``x`` 的指定 ``aixs`` 维度的条目,并将它们拼接在一起。
.. code-block:: text
X = [[1, 2],
[3, 4],
[5, 6]]
根据索引 index 获取输入(input)的最外层维度的条目,并将它们拼接在一起。
Index = [1, 2]
.. math::
axis = 0
Out=X[Index]
Then:
Out = [[3, 4],
[5, 6]]
**参数**:
- **input** (Variable) - 输入, 秩 ``rank >= 1`` , 支持的数据类型包括 int32、int64、float32、float64 和 uint8 (CPU)、float16(GPU) 。
- **index** (Variable) - 索引,秩 ``rank = 1``, 数据类型为 int32 或 int64。
- **overwrite** (bool) - 具有相同索引时在反向更新梯度的模式。如果为 ``True`` ,则使用覆盖模式更新相同索引的梯度;如果为 ``False`` ,则使用累积模式更新相同索引的梯度。默认值为 ``True`` 。
- **x** (Tensor) - 输入 Tensor, 秩 ``rank >= 1`` , 支持的数据类型包括 int32、int64、float32、float64 和 uint8 (CPU)、float16(GPU) 。
- **index** (Tensor) - 索引 Tensor,秩 ``rank = 1``, 数据类型为 int32 或 int64。
- **axis** (Tensor) - 指定index 获取输入的维度, ``axis`` 的类型可以是int或者Tensor,当 ``axis`` 为Tensor的时候其数据类型为int32 或者int64。
- **name** (str,可选)- 具体用法请参见 :ref:`api_guide_Name` ,一般无需设置,默认值为None。
**返回**:和输入的秩相同的输出
张量
。
**返回**:和输入的秩相同的输出
Tensor
。
**返回类型**:Variable
抛出异常:
- ``TypeError``: - ``x`` 必须是Tensor 并且 ``x`` 的数据类型必须是uint8、float16、float32、float64、int32或者int64。
- ``TypeError``: - ``index`` 必须是Tensor并且数据类型必须是int32或者int64。
- ``TypeError``: - ``axis`` 必须是Tensor或者int, 当 ``axis`` 是Tensor的时候数据类型必须是int32或者int64。
**代码示例**:
.. code-block:: python
import paddle
import paddle.fluid as fluid
import numpy as np
with fluid.dygraph.guard():
input_1 = np.array([[1,2,3],[4,5,6],[7,8,9]])
index_1 = np.array([0,1])
input = fluid.dygraph.to_variable(input_1)
index = fluid.dygraph.to_variable(index_1)
output = paddle.fluid.layers.gather(input, index)
# expected output: [[1, 2, 3],[4, 5, 6]]
import paddle
paddle.disable_static()
input_1 = np.array([[1,2],[3,4],[5,6]])
index_1 = np.array([0,1])
input = paddle.to_tensor(input_1)
index = paddle.to_tensor(index_1)
output = paddle.gather(input, index, axis=0)
# expected output: [[1,2],[3,4]]
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录