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

【Hackathon No.27】为 Paddle 新增 frac 数学计算API #4539

Merged
merged 3 commits into from
Apr 14, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions docs/api/paddle/Overview_cn.rst
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ tensor数学操作
" :ref:`paddle.var <cn_api_tensor_cn_var>` ", "沿给定的轴 axis 计算 x 中元素的方差"
" :ref:`paddle.diagonal <cn_api_tensor_diagonal>` ", "根据给定的轴 axis 返回输入 Tensor 的局部视图"
" :ref:`paddle.trunc <cn_api_tensor_trunc>` ", "对输入 Tensor 每个元素的小数部分进行截断"
" :ref:`paddle.frac <cn_api_tensor_frac>` ", "得到输入 Tensor 每个元素的小数部分"
" :ref:`paddle.log1p <cn_api_paddle_tensor_log1p>` ", "该OP计算Log1p(加一的自然对数)结果"
" :ref:`paddle.take_along_axis <cn_api_paddle_tensor_take_along_axis>` ", "根据axis和index获取输入 Tensor 的对应元素"
" :ref:`paddle.put_along_axis <cn_api_paddle_tensor_put_along_axis>` ", "根据axis和index放置value值至输入 Tensor"
Expand Down
1 change: 1 addition & 0 deletions docs/api/paddle/Tensor/Overview_en.rst
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,7 @@ Methods
trace
transpose
trunc
frac
unbind
uniform_
unique
Expand Down
9 changes: 9 additions & 0 deletions docs/api/paddle/Tensor_cn.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2165,6 +2165,15 @@ trunc(name=None)

请参考 :ref:`cn_api_tensor_trunc`

frac(name=None)
Copy link
Collaborator

Choose a reason for hiding this comment

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

frac(x, 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.

对于Tensor.frac来说,并不需要显式地传入x

:::::::::

返回:计算后的tensor

返回类型:Tensor

请参考 :ref:`cn_api_tensor_frac`

tensordot(y, axes=2, name=None)
:::::::::

Expand Down
25 changes: 25 additions & 0 deletions docs/api/paddle/frac_cn.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
.. _cn_api_tensor_frac:

frac
-------------------------------

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


得到输入 `Tensor` 的小数部分。


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

返回
:::::::::
- Tensor (Tensor),输入矩阵只保留小数部分的结果。


代码示例
Copy link
Collaborator

Choose a reason for hiding this comment

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

https://github.com/PaddlePaddle/docs/pull/4130/files
COPY-FROM: paddle.gcd
使用这种写法,保证中英文同步示例

Copy link
Contributor Author

Choose a reason for hiding this comment

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

已修改

:::::::::

COPY-FROM: paddle.frac