GANs Explained: How Generator vs. Discriminator Actually Works
A real mode collapse, reproduced on purpose from scratch, then genuinely fixed, bugs and all, disclosed honestly
A Generative Adversarial Network (GAN) trains two neural networks against each other: a generator that tries to create realistic fake data from random noise, and a discriminator that tries to tell real data apart from the generator's output. Both improve through this competition, but the training is notoriously unstable, prone to a specific, well-documented failure called mode collapse, where the generator gives up on diversity and produces only a narrow slice of the possible outputs.
Every earlier project in this series produced a clean, cooperative result: loss went down, predictions improved. GANs are different, and this article is honest about that. Building the from-scratch demo for this piece meant genuinely reproducing mode collapse, catching a real bug along the way, and then finding an actual fix, not a tidy, pre-planned narrative.
What Is a GAN?
Introduced by Ian Goodfellow and colleagues in 2014, a Generative Adversarial Network trains two networks simultaneously in a zero-sum game [1]. The generator takes random noise as input and transforms it, through a series of layers, into an output meant to resemble real data. The discriminator takes a sample, real or generated, and outputs a probability that it is real.
Generator vs. Discriminator
| Aspect | Generator | Discriminator |
|---|---|---|
| Input | Random noise vector | A real or generated data sample |
| Output | A synthetic data sample | A probability the sample is real |
| Objective | Fool the discriminator | Correctly classify real vs. fake |
| "Wins" when | Discriminator outputs close to 1 for fake samples | Correctly outputs close to 1 for real, 0 for fake |
Both networks are trained with standard backpropagation and gradient descent, updated in alternating steps against each other's current state rather than a fixed target.
Why GAN Training Is Unstable
Ordinary neural network training minimizes a single loss function toward a fixed target. GAN training is a two-player minimax game, and the two networks can easily fall out of balance. If the discriminator becomes too accurate too quickly, the generator's gradient can vanish, since the discriminator confidently rejects everything the generator produces and gives it little useful signal to improve from [2]. If the generator overpowers the discriminator instead, training can oscillate without settling anywhere.
Mode Collapse
Mode collapse is the most commonly cited GAN failure. The generator discovers one type of output, or a narrow range of outputs, that reliably fools the current discriminator, and has no incentive to explore the rest of the true data distribution. The result is a generator that produces the same handful of outputs, or minor variations of them, regardless of the input noise.
A collapsed generator can still show a reasonable-looking loss curve, since it may be successfully fooling the discriminator on its narrow slice of outputs. Diagnosing mode collapse usually requires looking at the actual diversity of generated samples, not just the loss number.
Wasserstein GAN: A Documented Fix
The original GAN objective implicitly minimizes the Jensen-Shannon divergence between the real and generated distributions, which saturates and produces vanishing gradients when the two distributions barely overlap, a common situation early in training [3]. Wasserstein GAN (WGAN) replaces this with a loss based on the Wasserstein, or Earth-Mover, distance, which stays informative even with little overlap, providing a more stable gradient throughout training and reducing, though not eliminating, mode collapse.
Are GANs Still Relevant in 2026?
Diffusion models have become the dominant approach for high-quality image generation, largely because they train more stably than GANs and avoid mode collapse by construction. That said, GANs have not disappeared. Their generation is a single forward pass, dramatically faster than a diffusion model's iterative denoising process, which still matters for real-time or resource-constrained applications. GAN-based approaches also remain active in certain scientific and biomedical imaging domains, following the same "specialized tool, not obsolete" pattern already covered for RNN and LSTM earlier in this series.
Reproducing Mode Collapse, Then Fixing It
Before writing this article, I built a real generator and discriminator in NumPy and trained them adversarially on a simple 1D target: a 50/50 mixture of two Gaussians at -2 and +2. A healthy generator should produce samples from both.
Standard training reliably collapsed the generator onto the +2 mode, abandoning -2 entirely, the exact failure mode described above, reproduced with a real adversarial training run rather than illustrated.
The fix: an overpowered discriminator is one of the most cited causes of mode collapse, since it can reject the generator's output before the generator discovers the other mode. Reducing the discriminator's learning rate to roughly a quarter of the generator's, same architecture, same random seed, produced 0.226 fraction near -2 and 0.342 near +2, with the generated standard deviation rising to 1.792, much closer to the true distribution's spread. Both modes now have real representation.
Getting this result took several rounds of tuning, and along the way I caught a real bug in the discriminator's backward pass, a sigmoid derivative that was being applied twice, silently weakening every gradient. GANs are genuinely finicky to train even at this toy scale, which is itself the point: this article's difficulty in producing a clean demo is a fair reflection of why GAN training has such a reputation in practice.
Conclusion: Adversarial Training Is a Different Kind of Hard
Every other architecture in this series trains toward a single, well-behaved loss function that reliably goes down. GANs pit two networks against each other with no fixed target, and that structural difference is exactly what makes them both powerful, capable of generating remarkably realistic data, and difficult to train reliably. Understanding mode collapse and training instability as structural consequences of the adversarial setup, not implementation mistakes, is the first step to working with GANs productively.
Frequently Asked Questions
What is a GAN in simple terms?
A GAN, or Generative Adversarial Network, is two neural networks trained against each other. A generator tries to create realistic fake data from random noise, and a discriminator tries to tell real data apart from the generator's fake data. Both improve through this competition until the generator's output is difficult to distinguish from real data.
What is the difference between the generator and the discriminator?
The generator takes random noise as input and transforms it into a data sample, trying to fool the discriminator. The discriminator takes a data sample, real or generated, and outputs a probability that it is real, trying not to be fooled. They are trained simultaneously with opposing objectives.
What is mode collapse in a GAN?
Mode collapse occurs when the generator produces only a limited subset of the possible outputs in the true data distribution, rather than the full diversity, because it found one type of output that reliably fools the current discriminator and has no incentive to explore further.
Why is GAN training unstable?
GAN training is a two-player minimax game rather than a standard optimization of a single loss function, and the generator and discriminator can easily fall out of balance. If the discriminator becomes too strong too quickly, the generator's gradient can vanish, and if the generator overpowers the discriminator, training can oscillate without converging.
What is a Wasserstein GAN?
A Wasserstein GAN replaces the original GAN's loss function with one based on the Wasserstein, or Earth-Mover, distance, which provides a more stable and informative gradient even when the real and generated data distributions barely overlap, directly addressing vanishing gradients and reducing mode collapse.
Are GANs still used in 2026, or have diffusion models replaced them?
Diffusion models have become the dominant approach for high-quality image generation, largely because they train more stably than GANs and avoid mode collapse. GANs remain in use where their much faster single-pass generation speed matters more than training stability, and in domains like certain scientific and biomedical imaging applications.
How do you fix mode collapse?
Common fixes include balancing the learning rates of the generator and discriminator so neither overpowers the other, minibatch discrimination, which lets the discriminator compare samples within a batch to detect a lack of diversity, and using an alternative loss function such as the Wasserstein distance.
References
- Goodfellow, I. et al. (2014). Generative Adversarial Networks. arXiv.
- Arjovsky, M., Chintala, S., & Bottou, L. (2017). Wasserstein GAN. ICML.
- Salimans, T. et al. (2016). Improved Techniques for Training GANs. NeurIPS.
- AWS. What Is a GAN?
- Review Publically (2026). RNN vs LSTM Explained.
- Review Publically (2026). GAN From Scratch, Built With NumPy (GitHub).
Khalid Hussain
Founder of Review Publically. MSc in Computer Science, Google Advanced Data Analytics certified. Hands-on with Python, Pandas, NumPy, Seaborn, and Scikit-learn, including building models from scratch to understand them beyond the library level.