fn
atleast_3d
→Tensor | tuple[Tensor, ...]atleast_3d(tensors: Tensor = ())Promote each input to at least 3 dimensions.
Scalars become shape (1, 1, 1), 1-D tensors become (1, N, 1),
2-D tensors gain a trailing unit axis to become (M, N, 1);
tensors with 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:
Note the asymmetric padding: 1-D tensors get both a leading and a
trailing unit axis (so they live in the middle, image-like axis),
while 2-D tensors gain only a trailing channel axis. This matches
NumPy and is convenient for image-processing code that expects
(H, W, C) arrays.
Examples
>>> import lucid
>>> v = lucid.tensor([1.0, 2.0])
>>> lucid.atleast_3d(v).shape
(1, 2, 1)