torch.stack

torch.stack(tensors, dim=0, *, out=None) → Tensor

Concatenates a sequence of tensors along a new dimension.

All tensors need to be of the same size.

Parameters
  • tensors (sequence of Tensors) – sequence of tensors to concatenate
  • dim (int) – dimension to insert. Has to be between 0 and the number of dimensions of concatenated tensors (inclusive)
Keyword Arguments

out (Tensor, optional) – the output tensor.

© 2019 Torch Contributors
Licensed under the 3-clause BSD License.
https://pytorch.org/docs/1.8.0/generated/torch.stack.html