mindspore.Tensor.ravel
- Tensor.ravel()[source]
Return a contiguous flattened tensor.
- Returns
Tensor, a 1-D tensor, containing the same elements of the input.
See also
mindspore.Tensor.reshape()
: Give a new shape to a tensor without changing its data.mindspore.Tensor.flatten()
: Return a copy of the tensor collapsed into one dimension.
- Supported Platforms:
Ascend
GPU
CPU
Examples
>>> import numpy as np >>> from mindspore import Tensor >>> x = Tensor(np.ones((2,3,4), dtype=np.float32)) >>> output = x.ravel() >>> print(output.shape) (24,)