oneflow.atleast_1d¶
-
oneflow.
atleast_1d
(*tensors) → Tensor or List[Tensor]¶ Returns a 1-dimensional view of each input tensor with zero dimensions. Input tensors with one 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_1d.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.randn(1) >>> flow.atleast_1d(x).shape oneflow.Size([1]) >>> x = flow.tensor(0) >>> x.shape oneflow.Size([]) >>> flow.atleast_1d(x).shape oneflow.Size([1])