expand(input, *sizes) → Tensor¶
This operator expand the input tensor to a larger size.
Passing -1 as the size for a dimension means not changing the size of that dimension.
Tensor can be also expanded to a larger number of dimensions and the new ones will be appended at the front.
For the new dimensions, the size cannot be set to -1.
input (oneflow.Tensor) – the input Tensor.
*sizes (oneflow.Size or int) – The desired expanded size.
The result Tensor.
- Return type
>>> import oneflow as flow >>> import numpy as np >>> x = np.array([[[[0, 1]], ... [[2, 3]], ... [[4, 5]]]]).astype(np.int32) >>> input = flow.Tensor(x) >>> input.shape oneflow.Size([1, 3, 1, 2]) >>> out = input.expand(1, 3, 2, 2) >>> out.shape oneflow.Size([1, 3, 2, 2])