mindspore.ops.flip
- mindspore.ops.flip(input, dims)[source]
Reverses the order of elements in a tensor along the given axis.
The shape of the tensor is preserved, but the elements are reordered.
- Parameters
- Returns
Tensor, with the entries of dims reversed.
- Raises
TypeError – If the input is not a tensor.
ValueError – If dims is None.
ValueError – If dims is not a list/tuple of ints.
- Supported Platforms:
Ascend
GPU
CPU
Examples
>>> import mindspore >>> from mindspore import ops >>> import numpy as np >>> input = mindspore.Tensor(np.arange(1, 9).reshape((2, 2, 2))) >>> output = ops.flip(input, (0, 2)) >>> print(output) [[[6 5] [8 7]] [[2 1] [4 3]]]