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 No.17】为 Paddle 新增 sgn 文档 #5107

Merged
merged 2 commits into from Aug 11, 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 @@ -228,6 +228,7 @@ paddle.scatter_nd .. _api_paddle_scatter_nd:
paddle.scatter_nd_add .. _api_paddle_scatter_nd_add:
paddle.shard_index .. _api_paddle_shard_index:
paddle.sign .. _api_paddle_sign:
paddle.sgn .. _api_paddle_sgn:
paddle.sin .. _api_paddle_sin:
paddle.sinh .. _api_paddle_sinh:
paddle.slice .. _api_paddle_slice:
Expand Down
1 change: 1 addition & 0 deletions docs/api/paddle/Overview_cn.rst
Expand Up @@ -107,6 +107,7 @@ tensor 数学操作
" :ref:`paddle.rsqrt <cn_api_fluid_layers_rsqrt>` ", "rsqrt 激活函数"
" :ref:`paddle.scale <cn_api_fluid_layers_scale>` ", "缩放算子"
" :ref:`paddle.sign <cn_api_tensor_sign>` ", "对输入 x 中每个元素进行正负判断"
" :ref:`paddle.sgn <cn_api_tensor_sgn>` ", "对输入 x 中每个元素进行正负判断,对于复数则输出单位向量"
" :ref:`paddle.sin <cn_api_fluid_layers_sin>` ", "计算输入的正弦值"
" :ref:`paddle.sinh <cn_api_fluid_layers_sinh>` ", "双曲正弦函数"
" :ref:`paddle.sqrt <cn_api_fluid_layers_sqrt>` ", "计算输入的算数平方根"
Expand Down
24 changes: 24 additions & 0 deletions docs/api/paddle/sgn_cn.rst
@@ -0,0 +1,24 @@
.. _cn_api_tensor_sgn:

sgn
-------------------------------

.. py:function:: paddle.sgn(x, name=None)

对输入参数 ``x`` 中每个元素进行正负判断,并且输出正负判断值:1 代表正,-1 代表负,0 代表零。
对于复数张量,此函数返回一个新的张量,其元素与 input 元素的角度相同且绝对值为 1。
Copy link
Member

@SigureMo SigureMo Aug 4, 2022

Choose a reason for hiding this comment

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

这两句与英文的顺序正好是反的,中英文两者顺序也应当是一致的~

以及在 rst 中空一行才能分隔两个段落~可以看下预览里现在的效果~


参数
::::::::::::
- **x** (Tensor) – 输入 Tensor,数据类型为 float16, float32, float64, complex64 或 complex128。
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
- **x** (Tensor) – 输入 Tensor,数据类型为 float16float32float64complex64 或 complex128。
- **x** (Tensor) – 输入 Tensor,数据类型为 float16float32float64complex64 或 complex128。

- **name** (str,可选) - 具体用法请参见 :ref:`api_guide_Name`,一般无需设置,默认值为 None。

返回
::::::::::::
Tensor,输出正负号或复数的单位向量,数据的 shape 大小及数据类型和输入 ``x`` 一致。
Copy link
Member

Choose a reason for hiding this comment

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

这里的话中文应该没问题,英文有点简单了可以修改下,两者也需要一致~

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.sgn