Rate this Page
★ ★ ★ ★ ★

TensorDictBase.stack_from_tensordict#

TensorDictBase.stack_from_tensordict(dim: int = 0, *, sorted: bool | List[NestedKey] | None = None, out: Tensor | None = None) → Tensor#

Stacks all entries of a tensordict in a single tensor.

Parameters:

dim (int, optional) – the dimension along which the entries should be stacked.

Keyword Arguments:
  • sorted (bool or list of NestedKeys) – if True, the entries will be stacked in alphabetical order. If False (default), the dict order will be used. Alternatively, a list of key names can be provided and the tensors will be stacked accordingly. This incurs some overhead as the list of keys will be checked against the list of leaf names in the tensordict.

  • out (Tensor, optional) – an optional destination tensor for the stack operation.

Every tensordict class and every tensorclass has this method. For the other methods, see Methods by task.