From 8e0cb1fd91109791acc7a85bb2147df7e6225c8a Mon Sep 17 00:00:00 2001 From: heliqi <1101791222@qq.com> Date: Tue, 16 Aug 2022 22:12:24 -0500 Subject: [PATCH] Fix paddle.t api docs (#5146) * fix paddle.t api docs * fix paddle.t api docs --- docs/api/paddle/t_cn.rst | 31 +++++++++++++++++++++++++++++-- 1 file changed, 29 insertions(+), 2 deletions(-) diff --git a/docs/api/paddle/t_cn.rst b/docs/api/paddle/t_cn.rst index e17982f75c3..f831621c653 100644 --- a/docs/api/paddle/t_cn.rst +++ b/docs/api/paddle/t_cn.rst @@ -17,6 +17,33 @@ t Tensor,0 维和 1 维 Tensor 返回本身,2 维 Tensor 返回转置 Tensor。 代码示例 -:::::::: +::::::::: + +.. code-block:: text + + # 例 1 (0-D tensor) + x = tensor([0.79]) + paddle.t(x) = tensor([0.79]) + + # 例 2 (1-D tensor) + x = tensor([0.79, 0.84, 0.32]) + paddle.t(x) = tensor([0.79, 0.84, 0.32]) + + # 例 3 (2-D tensor) + x = tensor([0.79, 0.84, 0.32], + [0.64, 0.14, 0.57]) + paddle.t(x) = tensor([0.79, 0.64], + [0.84, 0.14], + [0.32, 0.57]) + + +代码示例 +:::::::::::: + +.. code-block:: python -COPY-FROM: : + import paddle + x = paddle.ones(shape=[2, 3], dtype='int32') + x_transposed = paddle.t(x) + print(x_transposed.shape) + # [3, 2]