TensorDictBase.zero_grad#
- TensorDictBase.zero_grad(set_to_none: bool = True) Self#
Zeros all the gradients of the TensorDict recursively.
- Parameters:
set_to_none (bool, optional) – if
True, tensor.grad will beNone, otherwise0. Defaults toTrue.
Every tensordict class and every tensorclass has this method. For the other methods, see Methods by task.