Rate this Page
★ ★ ★ ★ ★

TensorDictBase.div#

TensorDictBase.div(other: TensorDictBase | Tensor, *, default: str | Tensor | TensorCollection | None = None) → Self#

Divides each element of the input self by the corresponding element of other.

\[\text{out}_i = \frac{\text{input}_i}{\text{other}_i}\]

Supports broadcasting, type promotion and integer, float, tensordict or tensor inputs. Always promotes integer types to the default scalar type.

Parameters:

other (TensorDict, Tensor or Number) – the divisor.

Keyword Arguments:

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 raises KeyError. 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.