Rate this Page
★ ★ ★ ★ ★

TensorDictBase.cat_from_tensordict#

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

Concatenates all entries of a tensordict in a single tensor.

Parameters:

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

Keyword Arguments:
  • sorted (bool or list of NestedKeys) – if True, the entries will be concatenated 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 concatenated 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 cat operation.

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