mindspore.numpy.moveaxis
- mindspore.numpy.moveaxis(a, source, destination)[源代码]
Moves axes of an array to new positions.
Other axes remain in their original order.
- Parameters
- Returns
Tensor, array with moved axes.
- Raises
ValueError – If axes are out of the range of
[-a.ndim, a.ndim)
, or if the axes contain duplicates.
- Supported Platforms:
Ascend
GPU
CPU
Examples
>>> import mindspore.numpy as np >>> x = np.zeros((3, 4, 5)) >>> output = np.moveaxis(x, 0, -1) >>> print(output.shape) (4, 5, 3) >>> output = np.moveaxis(x, -1, 0) >>> print(output.shape) (5, 3, 4) >>> output = np.moveaxis(x, [0, 1, 2], [-1, -2, -3]) >>> print(output.shape) (5, 4, 3)