Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

【PaddlePaddle Hackathon 3】16 新增 API paddle.take #5099

Merged
merged 22 commits into from Aug 30, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions docs/api/api_label
Expand Up @@ -245,6 +245,7 @@ paddle.subtract .. _api_paddle_subtract:
paddle.Tensor.subtract_ .. _api_paddle_Tensor_subtract_:
paddle.sum .. _api_paddle_sum:
paddle.t .. _api_paddle_t:
paddle.take .. _api_paddle_take:
paddle.tanh .. _api_paddle_tanh:
paddle.tanh_ .. _api_paddle_tanh_:
paddle.tile .. _api_paddle_tile:
Expand Down
1 change: 1 addition & 0 deletions docs/api/paddle/Overview_cn.rst
Expand Up @@ -136,6 +136,7 @@ tensor数学操作
" :ref:`paddle.acosh <cn_api_fluid_layers_acosh>` ", "反双曲余弦函数"
" :ref:`paddle.asinh <cn_api_fluid_layers_asinh>` ", "反双曲正弦函数"
" :ref:`paddle.atanh <cn_api_fluid_layers_atanh>` ", "反双曲正切函数"
" :ref:`paddle.take <cn_api_tensor_take>` ", "输出给定索引处的输入元素,结果与 index 的形状相同"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

image

还有问题,这个是说在句尾多了一个空格

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thx,done



.. _tensor_logic:
Expand Down
1 change: 1 addition & 0 deletions docs/api/paddle/Tensor/Overview_en.rst
Expand Up @@ -245,6 +245,7 @@ Methods
subtract_
sum
t
take
tanh
tanh_
tile
Expand Down
9 changes: 9 additions & 0 deletions docs/api/paddle/Tensor_cn.rst
Expand Up @@ -2404,3 +2404,12 @@ erfinv(x, name=None)
对输入x进行逆误差函数计算

请参考 :ref:`cn_api_paddle_tensor_erfinv`

take(input, index, name=None)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

作为 Tensor 的方法应该不需要第一个参数~

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

:::::::::

返回:一个新的 Tensor,其中包含给定索引处的输入元素。结果与 `index` 的形状相同
Copy link
Member

@SigureMo SigureMo Aug 5, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这里还有一个用 ` 包裹的,也许我们应该用

:attr:`arg_name`

这样?目前 Paddle 文档中引用某一个参数经常会使用这个,比如 argmax 源码和渲染分别为

image

image

这里看起来虽然与普通行内代码块一样,但应该仅仅是 Paddle 前端没有为两者样式做区分,比如 sphinx-rtd-theme 两者区别就是比较明显的

image

@BrilliantYuKaimin 有什么建议嘛?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

在 rst 中用一个 ` 包裹的表示斜体,用两个 ` 包裹的表示代码块。既然 :attr:`arg_name` 和 ``arg_name`` 确实可以渲染出不同的效果,那么当然应该使用 :attr:`arg_name`。

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thx,Done

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

「仅仅是 Paddle 前端没有为两者样式做区分」
给前端加一个需求吧


返回类型:Tensor

请参考 :ref:`cn_api_tensor_take`
28 changes: 28 additions & 0 deletions docs/api/paddle/take_cn.rst
@@ -0,0 +1,28 @@
.. _cn_api_paddle_tensor_take:

take
-------------------------------

.. py:function:: paddle.take(input, index, name)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

take(input, index, name=None)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done


返回一个新的 Tensor,其中包含给定索引处的输入元素。
将输入 Tensor 视为一维 Tensor,返回指定索引上的元素集合,返回结果与 `index` 的形状相同。

参数
:::::::::

- **input** (Tensor) - 输入的 Tensor,支持 int32、int64、float32、float64 数据类型。
- **index** (Tensor) - 索引矩阵,支持 int32、int64 数据类型。
- **name** (str,可选) - 具体用法请参见 :ref:`api_guide_Name`,一般无需设置,默认值为 None。

返回
:::::::::

- `Tensor` - 返回一个新的 Tensor,其中包含给定索引处的输入元素。结果与 `index` 的形状相同。
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

image

Tensor和index为什么要使用斜体?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

已经改回正体,
Done


代码示例
:::::::::


COPY-FROM: paddle.take