mindspore.Tensor.swapaxes
- Tensor.swapaxes(axis1, axis2)[source]
Interchange two axes of a tensor.
- Parameters
- Returns
Transposed tensor, has the same data type as the input.
- Raises
TypeError – If axis1 or axis2 is not integer.
ValueError – If axis1 or axis2 is not in the range of \([-ndim, ndim-1]\).
- Supported Platforms:
Ascend
GPU
CPU
Examples
>>> import numpy as np >>> from mindspore import Tensor >>> x = Tensor(np.ones((2,3,4), dtype=np.float32)) >>> output = x.swapaxes(0, 2) >>> print(output.shape) (4,3,2)