t

paddle.fluid.layers.t(input, name=None)[source]

Transpose <=2-D tensor. 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.

Parameters
  • input (Variable) – The input Tensor. It is a N-D (N<=2) Tensor of data types float32, float64, int32.

  • 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 Name

Returns

A transposed n-D Tensor, with data type being float32, float64, int32, int64.

Return type

Variable

For Example:

System Message: WARNING/2 (/usr/local/lib/python2.7/dist-packages/paddle/fluid/layers/nn.py:docstring of paddle.fluid.layers.t, line 16)

Explicit markup ends without a blank line; unexpected unindent.

# Example 1 (0-D tensor)

x = tensor([0.79]) fluid.layers.t(x) = tensor([0.79]) # Example 2 (1-D tensor) x = tensor([0.79, 0.84, 0.32]) fluid.layers.t(x) = tensor([0.79, 0.84, 0.32])

# Example 3 (2-D tensor) x = tensor([0.79, 0.84, 0.32],

System Message: ERROR/3 (/usr/local/lib/python2.7/dist-packages/paddle/fluid/layers/nn.py:docstring of paddle.fluid.layers.t, line 25)

Unexpected indentation.

[0.64, 0.14, 0.57])

System Message: WARNING/2 (/usr/local/lib/python2.7/dist-packages/paddle/fluid/layers/nn.py:docstring of paddle.fluid.layers.t, line 26)

Block quote ends without a blank line; unexpected unindent.

fluid.layers.t(x) = tensor([0.79, 0.64],

[0.84, 0.14], [0.32, 0.57])

Examples:

System Message: ERROR/3 (/usr/local/lib/python2.7/dist-packages/paddle/fluid/layers/nn.py:docstring of paddle.fluid.layers.t, line 31)

Error in “code-block” directive: maximum 1 argument(s) allowed, 20 supplied.

.. code-block:: python
    import paddle
    import paddle.fluid as fluid
    x = fluid.data(name='x', shape=[2, 3],
                    dtype='float32')
    x_transposed = fluid.layers.t(x)
    print x_transposed.shape
    #(3L, 2L)