From b72e6021e1944620bdc42600de9dff83120b510e Mon Sep 17 00:00:00 2001 From: zmxdream Date: Wed, 8 Dec 2021 19:33:25 +0800 Subject: [PATCH] [new api]fix rot90 eng doc (#37935) --- python/paddle/tensor/manipulation.py | 42 ++++++++++++++++++---------- 1 file changed, 27 insertions(+), 15 deletions(-) diff --git a/python/paddle/tensor/manipulation.py b/python/paddle/tensor/manipulation.py index f48e5a3a764..b4f00ab4ffb 100644 --- a/python/paddle/tensor/manipulation.py +++ b/python/paddle/tensor/manipulation.py @@ -497,42 +497,54 @@ def flip(x, axis, name=None): def rot90(x, k=1, axes=[0, 1], name=None): """ - Rotate a n-D tensor by 90 degrees in the plane specified by dims axis. Rotation direction is from the first towards the second axis if k > 0, and from the second towards the first for k < 0. + Rotate a n-D tensor by 90 degrees. The rotation direction and times are specified by axes. Rotation direction is from axes[0] towards axes[1] if k > 0, and from axes[1] towards axes[0] for k < 0. Args: x (Tensor): The input Tensor(or LoDTensor). The data type of the input Tensor x - should be float32, float64, int32, int64, bool. - k (int): Number of times to rotate - axes (list|tuple): Axis to rotate + should be float16, float32, float64, int32, int64, bool. + k (int, optional): Direction and number of times to rotate, default value: 1. + axes (list|tuple, optional): Axes to rotate, dimension must be 2. default value: [0, 1]. 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` . Returns: Tensor: Tensor or LoDTensor calculated by rot90 layer. The data type is same with input x. - Raises: - TypeError: If the data type of ``x`` is not Variable - TypeError: If the dtype of ``x`` is not float16, float32, float64, int32, int64, bool - TypeError: If the data type of ``dims`` is not list, tuple - Examples: .. code-block:: python import paddle - import numpy as np data = paddle.arange(4) data = paddle.reshape(data, (2, 2)) - print(data) ## [[0, 1],[2, 3]] + print(data) + #[[0, 1], + # [2, 3]] + y = paddle.rot90(data, 1, [0, 1]) - print(y) #[[1, 3],[0, 2]] + print(y) + #[[1, 3], + # [0, 2]] + y= paddle.rot90(data, -1, [0, 1]) - print(y) #[[2, 0],[3, 1]] + print(y) + #[[2, 0], + # [3, 1]] + data2 = paddle.arange(8) data2 = paddle.reshape(data2, (2,2,2)) - print(data2) ###[[[0, 1],[2, 3]],[[4, 5],[6, 7]]] + print(data2) + #[[[0, 1], + # [2, 3]], + # [[4, 5], + # [6, 7]]] + y = paddle.rot90(data2, 1, [1, 2]) - print(y) ### [[[1, 3],[0, 2]],[[5, 7],[4, 6]]] + print(y) + #[[[1, 3], + # [0, 2]], + # [[5, 7], + # [4, 6]]] """ helper = LayerHelper("rot90", **locals()) -- GitLab