mindspore.mint.reshape
- mindspore.mint.reshape(input, shape)[source]
Reshape the input tensor based on the given shape.
Note
The -1 in the parameter shape indicates that the size of that dimension is inferred from the other dimensions and the total number of elements in input tensor.
- Parameters
- Returns
Tensor
- Supported Platforms:
Ascend
Examples
>>> import mindspore >>> input = mindspore.tensor([[-0.1, 0.3, 3.6], [0.4, 0.5, -3.2]], mindspore.float32) >>> # case1: Parameter `shape` does not contain -1. >>> output = mindspore.mint.reshape(input, (3, 2)) >>> print(output) [[-0.1 0.3] [ 3.6 0.4] [ 0.5 -3.2]] >>> # case2: Parameter `shape` contains -1. >>> output = mindspore.mint.reshape(input, (-1, 6)) >>> print(output) [[-0.1 0.3 3.6 0.4 0.5 -3.2]]