mindspore.ops.ravel
- mindspore.ops.ravel(input)[source]
Expand the multidimensional Tensor into 1D along the 0 axis direction.
- Parameters
input (Tensor) – A tensor to be flattened.
- Returns
Tensor, a 1-D tensor, containing the same elements of the input.
- Raises
TypeError – If argument input is not Tensor.
- Supported Platforms:
Ascend
GPU
CPU
Examples
>>> import numpy as np >>> from mindspore import Tensor, ops >>> x = Tensor(np.array([[0, 1], [2, 1]]).astype(np.float32)) >>> output = ops.ravel(x) >>> print(output) [0. 1. 2. 1.] >>> print(output.shape) (4,)