oneflow.reshape¶
-
oneflow.
reshape
(input, shape: Optional[Sequence[int]] = None)¶ This operator reshapes a Tensor.
We can set one dimension in shape as -1, the operator will infer the complete shape.
- Parameters
x – A Tensor.
shape – Shape of the output tensor.
- Returns
A Tensor has the same type as x.
For example:
>>> import numpy as np >>> import oneflow as flow >>> x = np.array( ... [[1, 2, 3, 4], [5, 6, 7, 8], [9, 10, 11, 12], [13, 14, 15, 16]] ... ).astype(np.float32) >>> input = flow.Tensor(x) >>> y = flow.reshape(input, shape=[2, 2, 2, -1]).shape >>> y oneflow.Size([2, 2, 2, 2])