MnistModel.zero_grad#

MnistModel.zero_grad(set_to_none: bool = False) None#

Sets gradients of all model parameters to zero. See similar function under torch.optim.Optimizer for more context.

Args:
set_to_none (bool): instead of setting to zero, set the grads to None.

See torch.optim.Optimizer.zero_grad() for details.