mindspore.numpy.ravel

mindspore.numpy.ravel(x)[source]

Returns a contiguous flattened tensor.

A 1-D tensor, containing the elements of the input, is returned.

Parameters

x (Tensor) – A tensor to be flattened.

Returns

Flattened tensor, has the same data type as the original tensor x.

Raises

TypeError – If x is not tensor.

Supported Platforms:

Ascend GPU CPU

Examples

>>> import mindspore.numpy as np
>>> x = np.ones((2,3,4))
>>> output = np.ravel(x)
>>> print(output.shape)
(24,)