mindspore.numpy.transpose

mindspore.numpy.transpose(a, axes=None)[源代码]

Reverses or permutes the axes of a tensor; returns the modified tensor.

参数
  • a (Tensor) – a tensor to be transposed

  • axes (Union[None, tuple, list]) – the axes order, if axes is None, transpose the entire tensor. Default is None.

返回

Tensor, the transposed tensor array.

异常
  • TypeError – If input arguments have types not specified above.

  • ValueError – If the number of axes is not equal to a.ndim.

Supported Platforms:

Ascend GPU CPU

样例

>>> import mindspore.numpy as np
>>> x = np.ones((1,2,3))
>>> x = np.transpose(x)
>>> print(x.shape)
(3, 2, 1)