Table of Contents
Shortcuts

# 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.

  See also

  `torch.cat()` concatenates the given sequence along an existing dimension.

  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.

## Docs

Access comprehensive developer documentation for PyTorch

View Docs

## Tutorials

Get in-depth tutorials for beginners and advanced developers

View Tutorials

## Resources

Find development resources and get your questions answered

View Resources

To analyze traffic and optimize your experience, we serve cookies on this site. By clicking or navigating, you agree to allow our usage of cookies. As the current maintainers of this site, Facebook’s Cookies Policy applies. Learn more, including about available controls: Cookies Policy.