The gan template does not seem to set properly the gradients of the discriminator to zero
In each iteration at the beginning of the discriminator training, the gradient is not set to zero. To investigate, just print the gradients of the discriminator after the line if optimizer_i == 1:.
The optimizer.zero_grad() for discriminator is then only called once all the gradients are accumulated, including the ones coming from the update of the generator.
By the way, it may be helpful to indicate somewhere that the script is performing simultaneous gradient descent instead of alternating updates.
I am wondering if someone succeeds in training a GAN with this script because this does not seem to be possible to me. Thanks in advance for the clarification.