mindspore.numpy.rot90

View Source On Gitee
mindspore.numpy.rot90(a, k=1, axes=(0, 1))[source]

Rotates a tensor by 90 degrees in the plane specified by axes. Rotation direction is from the first towards the second axis.

Parameters
  • a (Tensor) – Input tensor of two or more dimensions.

  • k (int) – Number of times the tensor is rotated by 90 degrees. Default: 1 .

  • axes (Union[tuple(int), list(int)]) – The tensor is rotated in the plane defined by the axes. Default: (0, 1) . Axes must be different and with the shape of (2,).

Returns

Tensor.

Raises
  • TypeError – If input a is not a Tensor or the argument k is not integer or the argument axes is not tuple of integers or list of ints.

  • ValueError – If any axis is out of range or the length of axes is not 2.

Supported Platforms:

GPU

Examples

>>> import mindspore.numpy as np
>>> a = np.arange(24).reshape((2, 3, 4))
>>> output = np.rot90(a)
>>> print(output)
[[[ 8  9 10 11]
  [20 21 22 23]]
 [[ 4  5  6  7]
  [16 17 18 19]]
 [[ 0  1  2  3]
  [12 13 14 15]]]
>>> output = np.rot90(a, 3, (1, 2))
>>> print(output)
[[[ 8  4  0]
  [ 9  5  1]
  [10  6  2]
  [11  7  3]]
 [[20 16 12]
  [21 17 13]
  [22 18 14]
  [23 19 15]]]