fn
atleast_2d
→Tensor | tuple[Tensor, ...]atleast_2d(tensors: Tensor = ())Promote each input to at least 2 dimensions.
Scalars become shape (1, 1), 1-D tensors gain a leading unit axis
to become (1, N); tensors that already have rank
pass through unchanged.
Parameters
*tensorsTensorOne or more input tensors of arbitrary rank.
Returns
Tensor | tuple[Tensor, ...]A single tensor when called with one argument, otherwise a tuple of the promoted tensors in the same order as the inputs.
Notes
Promotion rule per input t with original shape :
The leading axis insertion (rather than trailing) matches NumPy's
np.atleast_2d convention.
Examples
>>> import lucid
>>> v = lucid.tensor([1.0, 2.0, 3.0])
>>> lucid.atleast_2d(v).shape
(1, 3)