Rate this Page
★ ★ ★ ★ ★

TensorDictBase.sub#

TensorDictBase.sub_(other: TensorDictBase | Tensor | float, alpha: float | None = None)#

Subtracts other, scaled by alpha, from every leaf in place and returns self.

The in-place version of sub(), 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 subtract, paired with the leaves as in sub().

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

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