Interesting! My guess is that it must be something to do with how you are using “detach()” to avoid computing gradients on the generator. Did you perhaps apply detach also on the real images being fed to the discriminator? I tried a couple of experiments with that and could not reproduce the error trace that you show. What the error message is telling you is that it can’t find the gradients it needs on the discriminator loss in order to perform the back propagation.
Start by checking for the uses of detach in your code: it should be just on the fake images before they are fed to the discriminator.
Have you used pytorch before you started on the GANs specialization? Maybe you know some other pytorch mechanisms for avoiding propagating gradients.
One thing to try is not to detach the real predictions. The point is we only want to detach the fake predictions, because we don’t want to waste the cpu cycles to compute gradients on the generator. But we need the gradients for the discriminator, right? That’s because the point here is to train the discriminator.
I would also recommend that you try detaching the fake images before you pass them to the discriminator.