mindspore.numpy.flip
- mindspore.numpy.flip(m, axis=None)[源代码]
Reverses the order of elements in an array along the given axis.
The shape of the array is preserved, but the elements are reordered.
- Parameters
m (Tensor) – Input array.
axis (None or int or tuple of integers, optional) – Axis or axes along which to flip over. The default,
axis=None
, will flip over all of the axes of the input array. If axis is negative it counts from the last to the first axis. If axis is a tuple of integers, flipping is performed on all of the axes specified in the tuple.
- Returns
Tensor, with the entries of axis reversed.
- Raises
TypeError – If the input is not a tensor.
- Supported Platforms:
GPU
CPU
Example
>>> import mindspore.numpy as np >>> A = np.arange(8.0).reshape((2,2,2)) >>> output = np.flip(A) >>> print(output) [[[7. 6.] [5. 4.]] [[3. 2.] [1. 0.]]] >>> output = np.flip(A, (0, 2)) >>> print(output) [[[5. 4.] [7. 6.]] [[1. 0.] [3. 2.]]]