mindspore.Tensor.view
- Tensor.view(*shape)[source]
Reshape the tensor according to the input shape. It's the same as
mindspore.Tensor.reshape()
, implemented by the underlying reshape operator.- Parameters
shape (Union[tuple(int), int]) – Dimension of the output tensor.
- Returns
Tensor, which dimension is the input shape's value.
Examples
>>> from mindspore import Tensor >>> import numpy as np >>> a = Tensor(np.array([[1, 2, 3], [2, 3, 4]], dtype=np.float32)) >>> output = a.view((3, 2)) >>> print(output) [[1. 2.] [3. 2.] [3. 4.]]