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

new api paddle.trunc #3585

Merged
merged 10 commits into from
Jun 16, 2021
Merged
Show file tree
Hide file tree
Changes from 8 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
5 changes: 5 additions & 0 deletions doc/fluid/api/paddle/trunc.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
.. _api_paddle_trunc:

trunc
-------------------------------
:doc_source: paddle.trunc
36 changes: 36 additions & 0 deletions doc/fluid/api_cn/paddle_cn/trunc_cn.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
.. _cn_api_tensor_trunc:

trunc
-------------------------------

.. py:function:: paddle.trunc(input, name=None)


将输入矩阵数据的小数部分置0,返回置0后的矩阵,如果输入矩阵的数据类型为整数,则不做处理。


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

返回:
- Tensor (Tensor),矩阵截断后的结果。


**代码示例**:

.. code-block:: python

import paddle

input = paddle.rand([2,2],'float32')
print(input)
# Tensor(shape=[2, 2], dtype=float32, place=CUDAPlace(0), stop_gradient=True,
# [[0.02331470, 0.42374918],
# [0.79647720, 0.74970269]])

output = paddle.trunc(input)
print(output)
# Tensor(shape=[2, 2], dtype=float32, place=CUDAPlace(0), stop_gradient=True,
# [[0., 0.],
# [0., 0.]])
36 changes: 36 additions & 0 deletions doc/fluid/api_cn/tensor_cn/trunc_cn.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
.. _cn_api_tensor_trunc:

trunc
-------------------------------

.. py:function:: paddle.trunc(input, name=None)


将输入矩阵数据的小数部分置0,返回置0后的矩阵,如果输入矩阵的数据类型为整数,则不做处理。
Copy link
Collaborator

Choose a reason for hiding this comment

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

输入矩阵数据 -> 输入 Tensor
矩阵 -> Tensor
输入矩阵 -> 输入 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,thanks!



参数:
Copy link
Collaborator

Choose a reason for hiding this comment

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

参数: ->
参数
:::::::::(9个英文冒号)

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,thanks!

- **input** (Tensor) : 输入变量,类型为 Tensor, 支持int、float、double数据类型。
- **name** (str,可选)- 具体用法请参见 :ref:`api_guide_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.

返回: ->
返回
:::::::::(9个英文冒号)

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,thanks!

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

代码示例: ->
代码示例
:::::::::(9个英文冒号)

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,thanks!


.. code-block:: python

import paddle

input = paddle.rand([2,2],'float32')
print(input)
# Tensor(shape=[2, 2], dtype=float32, place=CUDAPlace(0), stop_gradient=True,
# [[0.02331470, 0.42374918],
# [0.79647720, 0.74970269]])

output = paddle.trunc(input)
print(output)
# Tensor(shape=[2, 2], dtype=float32, place=CUDAPlace(0), stop_gradient=True,
# [[0., 0.],
# [0., 0.]]))
36 changes: 36 additions & 0 deletions docs/api/paddle/trunc_cn.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
.. _cn_api_tensor_trunc:

trunc
-------------------------------

.. py:function:: paddle.trunc(input, name=None)


将输入矩阵数据的小数部分置0,返回置0后的矩阵,如果输入矩阵的数据类型为整数,则不做处理。


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

返回:
- Tensor (Tensor),矩阵截断后的结果。


**代码示例**:

.. code-block:: python

import paddle

input = paddle.rand([2,2],'float32')
print(input)
# Tensor(shape=[2, 2], dtype=float32, place=CUDAPlace(0), stop_gradient=True,
# [[0.02331470, 0.42374918],
# [0.79647720, 0.74970269]])

output = paddle.trunc(input)
print(output)
# Tensor(shape=[2, 2], dtype=float32, place=CUDAPlace(0), stop_gradient=True,
# [[0., 0.],
# [0., 0.]]))