nip.utils.tensordict.tensordict_scalar_multiply

nip.utils.tensordict.tensordict_scalar_multiply#

nip.utils.tensordict.tensordict_scalar_multiply(td: TensorDictBase, scalar: float | int, *, inplace=False) TensorDictBase[source]#

Multiply a tensordict by a scalar.

Parameters:
  • td (TensorDictBase) – The tensordict

  • scalar (float | int) – The scalar to multiply every tensor in the tensordict by

  • inplace (bool, default=False) – Whether to modify the tensordict in place. Otherwise the tensordict is cloned before multiplying by the scalar.

Returns:

td_scaled (TensorDictBase) – The scaled tensordict