fn
dstack
→Tensordstack(tensors: Sequence[Tensor])Stack tensors along the third (depth) axis.
Reshapes lower-rank inputs to give them a depth dimension, then
concatenates along axis 2. 0-D scalars become (1, 1, 1), 1-D
vectors of length N become (1, N, 1), and 2-D matrices of
shape (H, W) become (H, W, 1).
Parameters
tensorsSequence[Tensor]Tensors to stack. 0-, 1-, and 2-D inputs are auto-promoted to
3-D as described above; 3-D inputs pass through unchanged.
Returns
Tensor3-D tensor formed by concatenating the (possibly promoted) inputs along axis 2.
Notes
The promotion rules ensure the result is always at least 3-D, which
is useful for stacking colour channels of images: dstack([R, G, B])
produces an (H, W, 3) tensor from three (H, W) planes.
Examples
>>> import lucid
>>> a = lucid.tensor([[1., 2.], [3., 4.]])
>>> b = lucid.tensor([[5., 6.], [7., 8.]])
>>> lucid.dstack([a, b]).shape
(2, 2, 2)