oneflow.atleast_3d

oneflow.atleast_3d(*tensors)Tensor or List[Tensor]

Returns a 3-dimensional view of each input tensor with zero dimensions. Input tensors with three or more dimensions are returned as-is.

The interface is consistent with PyTorch.

The documentation is referenced from: https://pytorch.org/docs/1.10/generated/torch.atleast_3d.html.

Parameters

tensors (List[oneflow.Tensor] or oneflow.Tensor) – Tensor or list of tensors to be reshaped

Returns

A Tensor

For example:

>>> import oneflow as flow
>>> x = flow.tensor(0)
>>> flow.atleast_3d(x).shape
oneflow.Size([1, 1, 1])
>>> x = flow.randn(3)
>>> flow.atleast_3d(x).shape
oneflow.Size([1, 3, 1])
>>> x = flow.randn(3, 4)
>>> flow.atleast_3d(x).shape
oneflow.Size([3, 4, 1])
>>> x = flow.randn(3, 4, 5)
>>> flow.atleast_3d(x).shape
oneflow.Size([3, 4, 5])