Rate this Page
★ ★ ★ ★ ★

TensorDictBase.add#

TensorDictBase.add_(other: TensorCollection | Tensor | float, *, alpha: float | None = None) → Self#

Adds other, scaled by alpha, to every leaf in place and returns self.

The in-place version of add(), called by td += other. It has no default: a tensordict other must have every key of the tensordict, and its other keys are ignored.

Parameters:

other (TensorDictBase, Tensor or Number) – the value to add, paired with the leaves as in add().

Keyword Arguments:

alpha (Number, optional) – the multiplier for other. Defaults to None, which adds other as it is.

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