Theoretically, the GAN is fairly straightforward. However, they are notoriously difficult to train.
- For example, to get DCGAN to train reliable, they had to use strided convolutions for upsampling and downsampling, use BatchNorm in both the generator and discriminator except in the last and first layers, use leaky ReLU in the discriminator, use Adam but with a lower momentum coefficient.
- This instability is unusual; many deep learning models are relatively robust to such choices.
A common failure mode is that the generator makes plausible samples, but only representing a subset of the data. This is known as mode dropping. An extreme version of this phenomenon can occur where the generator entirely or mostly ignores the latent variable and collapses all samples to one or a few points; this is known as mode collapse.

Loss function analysis
To understand why GANs are difficult to train, it’s necessary to understand what the loss function represents. Recall that we can write the GAN objective as two loss functions:
where the first loss function trains the discriminator and the second loss function trains the generator.
If we divide the two sums in the first line by the numbers of real and generated samples, then the loss function can be written in terms of expectations:
where is the probability distribution over the generated samples, and is the true probability distribution over the samples.
When , the optimal discriminator for an example of unknown origin is:
where on the right side, we evaluate against the generated distribution and the real distribution . Substituting this back into our loss functoin:
Disregarding additive and multiplicative constants, this is the Jensen-Shannon divergence between the synthesized distribution and the true distribution :
where is the KL divergence.
The first term indicates the distance will be small if, wherever the sample density is high, the mixture has high probability. In other words, it penalizes regions with samples but no real examples ; it enforces the quality of generated samples.
The second term says that the distance will be small if, wherever the true density is high, the mixture has high probability. In other words, it penalizes regions with real examples but no generated samples. This enforces coverage.
We can see that the second term does not depend on the generator parameters ; consequently, the generator doesn’t care much about coverage, though it is still implicitly included through . It is happy to generate a subset of possible examples accurately. This is the likely reason for mode dropping/collapse.
Vanishing gradients
We saw that when the discriminator is optimal, the loss function maximizes a measure of the distance between the generated and real samples. However, there’s a problem with using this distance between probability distributions as the criterion for optimizing GANs. If the probability distributions are completely disjoint, this distance is infinite, and any small change to the generator will not decrease the loss. The same phenomenon can be seen when we consider the original formulation; if the discriminator can perfectly separate the generated and real samples, no small change to the generated data will change classification score.

Unfortunately, the distributions may really be disjoint; the generated samples lie in a subspace that is the size of the latent variable , and the real examples also lie in a low-dimension al subspace due to the physical processes that created the data. There may be very little or no overlap between these two subspaces, and the result is very small or no gradients.
We can see an empirical version of this below. If the DCGAN generator is frozen and the discriminator is updated repeatedly so that its classification performance improves, the generator gradients decrease. In short, there is a very fine balance between the quality of the discriminator and the generator; if the discriminator becomes too good, the training updates of the generator are attenuated.

dl
Why are GANs hard to train?
?
- Training is a coupled, non-stationary game: updating either network changes the objective faced by the other.
- With an optimal discriminator, the original GAN objective corresponds to minimizing the Jensen–Shannon divergence between the real and generated distributions. If they have little or no overlap, the discriminator sigmoid can saturate, giving the generator vanishing gradients.

+++