Using custom optimizer in pytorch framework

optimizer.zero_grad iterated the parameters in each param_group and set’s the .grad attribute either to zero or to None (which was recently introduced for performance reasons).