Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
【PaddlePaddle Hackathon 3】16 新增 API paddle.take (#5099)
* add docs for paddle.take * fix docs * fix conflict * fix conflict * Update docs/api/paddle/take_cn.rst Co-authored-by: Nyakku Shigure <sigure.qaq@gmail.com> * fix docs * revert commit 498c668 * fix revert 498c668 * Revert "fix conflict" This reverts commit 6d7633e. * Revert "Revert "fix conflict"" This reverts commit e2d5299. fix e2d5299# * fix docs * fix take_cn by pre-commit * fix take_cn by pre-commit * fix take_cn by pre-commit * fix take_cn by pre-commit * fix take_cn.rst by pre-commit * fix Overview_cn.rst * fix doc, add param 'mode' * fix 嵌套列表 Co-authored-by: Nyakku Shigure <sigure.qaq@gmail.com>
- Loading branch information
Showing
5 changed files
with
44 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -247,6 +247,7 @@ Methods | |
subtract_ | ||
sum | ||
t | ||
take | ||
tanh | ||
tanh_ | ||
tile | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
.. _cn_api_paddle_tensor_take: | ||
|
||
take | ||
------------------------------- | ||
|
||
.. py:function:: paddle.take(x, index, mode='raise', name=None) | ||
返回一个新的 Tensor,其中包含给定索引处的输入元素。 | ||
将输入 Tensor 视为一维 Tensor,返回指定索引上的元素集合,返回结果与 :attr:`index` 的形状相同。 | ||
|
||
参数 | ||
::::::::: | ||
|
||
- **x** (Tensor) - 输入的 Tensor,支持 int32、int64、float32、float64 数据类型。 | ||
- **index** (Tensor) - 索引矩阵,支持 int32、int64 数据类型。 | ||
- **mode** (str,可选) - 索引越界处理,可选 ``'raise'``,``'wrap'``,``'clip'``,默认为 ``'raise'``。 | ||
|
||
- ``raise``:直接抛出错误; | ||
- ``wrap``:通过取余数来约束超出范围的索引; | ||
- ``clip``:将超出范围的索引剪裁到允许的最小(大)范围。此模式意味着所有超出范围的索引都将被最后一个元素的索引替换,而且将禁用负值索引。 | ||
|
||
- **name** (str,可选) - 具体用法请参见 :ref:`api_guide_Name`,一般无需设置,默认值为 None。 | ||
|
||
返回 | ||
::::::::: | ||
|
||
Tensor,其中包含给定索引处的输入元素。与 index 的形状相同。 | ||
|
||
代码示例 | ||
::::::::: | ||
|
||
COPY-FROM: paddle.take |