mindspore.Tensor.rot90
- Tensor.rot90(k, dims)[source]
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.
- Parameters
- Returns
Tensor.
- Raises
TypeError – If x is not a Tensor.
TypeError – If k is not an integer.
TypeError – If dims is not a list or a tuple of integers.
ValueError – If the length of dims is not 2.
ValueError – If any dims is out of range of [-self.ndim, self.ndim).
RuntimeError – If rotation dims are not different.
- Supported Platforms:
Ascend
GPU
Examples
>>> import numpy as np >>> import mindspore as ms >>> from mindspore import Tensor >>> x = Tensor(np.array([[0, 1], [2, 3]])).astype(np.float32) >>> k = 1 >>> dims = [0, 1] >>> output = x.rot90(k, dims) >>> print(output) [[1. 3.] [0. 2.]]