easy framework

Stack Tensors

Stack a list of 1D tensors into a 2D tensor along a new first dimension.

Unlike concatenation, stacking creates a new dimension.

Input:

  • tensors: A list of 1D tensors, each of shape (n,)

Output: A 2D tensor of shape (len(tensors), n).

API Reference:

  • PyTorch: torch.stack(tensors, dim=0)
  • JAX: jnp.stack(tensors, axis=0)

Hints

stack torch.stack jnp.stack
Detecting runtime...