mindspore.ops.flip
- mindspore.ops.flip(x, 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 tuple of ints.
- Supported Platforms:
GPU
CPU
Examples
>>> import mindspore as ms >>> import mindspore.ops as ops >>> import numpy as np >>> x = ms.Tensor(np.arange(8).reshape((2, 2, 2))) >>> output = ops.flip(x, (0, 2)) >>> print(output) [[[5. 4.] [7. 6.]] [[1. 0.] [3. 2.]]]