TensorDictBase.add#
- TensorDictBase.add(other: TensorCollection | Tensor, *, alpha: float | None = None, default: str | Tensor | TensorCollection | None = None) Self#
Adds
other, scaled byalpha, toself.\[\text{out}_i = \text{input}_i + \text{alpha} \times \text{other}_i\]- Parameters:
other (TensorDictBase or Tensor) – the tensor or TensorDict to add to
self.- Keyword Arguments:
alpha (Number, optional) – the multiplier for
other.default (Tensor or str, optional) – the value to use for an entry that only one of the two tensordicts has. If
None(default), the two tensordicts must have the same keys, and a missing key raisesKeyError. If"intersection", only the keys that both tensordicts have are computed, and the other keys are dropped. Any other value replaces the missing entries on both sides of the operation.
Every tensordict class and every tensorclass has this method. For the other methods, see Methods by task.