未验证 提交 7d32e100 编写于 作者: D danleifeng 提交者: GitHub

upgrade to use paddle-2.0 API for sample code of paddle.t (#28726)

上级 e5f0e6b0
...@@ -613,25 +613,25 @@ def dot(x, y, name=None): ...@@ -613,25 +613,25 @@ def dot(x, y, name=None):
def t(input, name=None): def t(input, name=None):
""" """
:alias_main: paddle.t
:alias: paddle.t,paddle.tensor.t,paddle.tensor.linalg.t
Transpose <=2-D tensor. Transpose <=2-D tensor.
0-D and 1-D tensors are returned as it is and 2-D tensor is equal to 0-D and 1-D tensors are returned as it is and 2-D tensor is equal to
the fluid.layers.transpose function which perm dimensions set 0 and 1. the paddle.transpose function which perm dimensions set 0 and 1.
Args: Args:
input (Variable): The input Tensor. It is a N-D (N<=2) Tensor of data types float16, float32, float64, int32. input (Tensor): The input Tensor. It is a N-D (N<=2) Tensor of data types float16, float32, float64, int32.
name(str, optional): The default value is None. Normally there is no need for name(str, optional): The default value is None. Normally there is no need for
user to set this property. For more information, please refer to :ref:`api_guide_Name` user to set this property. For more information, please refer to :ref:`api_guide_Name`
Returns: Returns:
Variable: A transposed n-D Tensor, with data type being float16, float32, float64, int32, int64. Tensor: A transposed n-D Tensor, with data type being float16, float32, float64, int32, int64.
For Example: For Example:
.. code-block:: text .. code-block:: text
# Example 1 (0-D tensor) # Example 1 (0-D tensor)
x = tensor([0.79]) x = tensor([0.79])
paddle.t(x) = tensor([0.79]) paddle.t(x) = tensor([0.79])
# Example 2 (1-D tensor) # Example 2 (1-D tensor)
x = tensor([0.79, 0.84, 0.32]) x = tensor([0.79, 0.84, 0.32])
paddle.t(x) = tensor([0.79, 0.84, 0.32]) paddle.t(x) = tensor([0.79, 0.84, 0.32])
...@@ -644,14 +644,14 @@ def t(input, name=None): ...@@ -644,14 +644,14 @@ def t(input, name=None):
[0.32, 0.57]) [0.32, 0.57])
Examples: Examples:
.. code-block:: python .. code-block:: python
import paddle import paddle
import paddle.fluid as fluid x = paddle.ones(shape=[2, 3], dtype='int32')
x = fluid.data(name='x', shape=[2, 3],
dtype='float32')
x_transposed = paddle.t(x) x_transposed = paddle.t(x)
print x_transposed.shape print(x_transposed.shape)
#(3L, 2L) # [3, 2]
""" """
if len(input.shape) > 2: if len(input.shape) > 2:
raise ValueError( raise ValueError(
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册