-
Notifications
You must be signed in to change notification settings - Fork 724
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
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -250,6 +250,7 @@ Methods | |
trace | ||
transpose | ||
trunc | ||
frac | ||
unbind | ||
uniform_ | ||
unique | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
.. _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),输入矩阵只保留小数部分的结果。 | ||
|
||
|
||
代码示例 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. https://github.com/PaddlePaddle/docs/pull/4130/files There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 已修改 |
||
::::::::: | ||
|
||
.. code-block:: python | ||
|
||
import paddle | ||
|
||
= paddle.rand([3,4],'float32') | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [3,4] 怎么变成[3,3] 了 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 抱歉,已修改 |
||
print(x) | ||
# Tensor(shape=[3, 3], dtype=float32, place=Place(cpu), stop_gradient=True, | ||
# [[5.29032421, 7.70876980, 5.14640331], | ||
# [2.30558801, 7.60625172, 2.57993436], | ||
# [1.53053904, 1.51977015, 2.96169519]]) | ||
|
||
output = paddle.frac(x) | ||
print(output) | ||
# Tensor(shape=[3, 3], dtype=float32, place=Place(cpu), stop_gradient=True, | ||
# [[0.29032421, 0.70876980, 0.14640331], | ||
# [0.30558801, 0.60625172, 0.57993436], | ||
# [0.53053904, 0.51977015, 0.96169519]]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
frac(x, name=None)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
对于Tensor.frac来说,并不需要显式地传入x