mindspore.numpy.swapaxes
- mindspore.numpy.swapaxes(x, axis1, axis2)[源代码]
Interchanges two axes of a tensor.
- Parameters
- Returns
Transposed tensor, has the same data type as the original tensor x.
- Raises
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
Examples
>>> import mindspore.numpy as np >>> x = np.ones((2,3,4)) >>> output = np.swapaxes(x, 0, 2) >>> print(output.shape) (4,3,2)