mindspore.numpy.swapaxes
- mindspore.numpy.swapaxes(x, axis1, axis2)[源代码]
Interchanges two axes of a tensor.
- 参数
- 返回
Transposed tensor, has the same data type as the original tensor x.
- 异常
TypeError – If axis1 or axis2 is not integer, or x is not tensor.
ValueError – If axis1 or axis2 is not in the range of \([-ndim, ndim-1]\).
- Supported Platforms:
Ascend
GPU
CPU
样例
>>> import mindspore.numpy as np >>> x = np.ones((2,3,4)) >>> output = np.swapaxes(x, 0, 2) >>> print(output.shape) (4,3,2)