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.
- 参数
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.
- 返回
Tensor, with the entries of axis reversed.
- 异常
TypeError – If the input is not a tensor.
- Supported Platforms:
GPU
CPU
示例
>>> 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.]]]