A GAN (generative adversarial network) is a generative AI model made of two neural networks trained against each other: a generator that creates fake samples, and a discriminator that tries to tell fake samples from real ones. As the discriminator gets better at spotting fakes, the generator is pushed to produce ever more realistic output. GANs were introduced by Ian Goodfellow and colleagues in 2014.
Key takeaways
- A GAN is a two-player game between a generator and a discriminator.
- The generator never sees real data directly; it learns from the discriminator’s feedback.
- GANs produced the first strikingly realistic AI-generated faces.
- Training is notoriously unstable, and GANs can suffer from “mode collapse”.
- Diffusion models have largely overtaken GANs for image generation, but GANs remain fast and useful for some tasks.
A GAN explained in simple terms
Picture a counterfeiter and a detective. The counterfeiter prints fake banknotes. The detective examines notes and says “real” or “fake”. Each time the detective catches a fake, the counterfeiter learns what gave it away and improves. Each time a fake slips through, the detective learns to look more closely. After many rounds, the fakes are almost indistinguishable from real notes. In a GAN, the counterfeiter is the generator and the detective is the discriminator.
How a GAN works
- The generator takes random noise and produces a sample, for example an image.
- The discriminator receives a mix of real images and generated ones and outputs a probability that each is real.
- The discriminator is updated to classify real and fake more accurately.
- The generator is updated to make the discriminator label its outputs as real.
- Both repeat, in alternating steps, for many rounds.
Ideally, training reaches a balance where the discriminator can do no better than guessing, because generated samples look like real ones.
Worked example: generating faces
A GAN trained on tens of thousands of face photos starts by outputting random noise. Early on, the discriminator easily spots fakes. The generator learns rough blobs with face-like colours, then eyes and mouths in the right places, then realistic skin, hair and lighting. NVIDIA’s StyleGAN models (2018–2019) became famous for producing faces of people who do not exist, which viral websites showcased to the public.
Popular GAN variants
| Variant | Key idea | Use |
|---|---|---|
| DCGAN | Uses convolutional layers (CNNs) | Stable image generation baseline |
| Conditional GAN | Generates samples for a given label or input | “Generate a shoe”, image translation |
| Pix2Pix | Translates paired images | Sketch to photo, map to satellite |
| CycleGAN | Translates without paired examples | Horse to zebra, summer to winter |
| StyleGAN | Controls style at different levels of detail | High-quality faces and art |
| SRGAN / ESRGAN | Adds realistic detail to low-resolution images | Image upscaling |
| WGAN | Uses a different loss for more stable training | Improved training stability |
Common training problems
- Mode collapse: the generator finds a few outputs that fool the discriminator and keeps producing only those, losing variety.
- Instability: if one network gets too strong too fast, the other stops learning.
- Hard evaluation: there is no single loss that shows quality; teams use scores such as FID and human review.
GANs vs diffusion models
| Aspect | GANs | Diffusion models |
|---|---|---|
| Generation speed | Very fast, one pass | Slower, many denoising steps (though faster methods exist) |
| Training stability | Often unstable | More stable |
| Variety of outputs | Can suffer mode collapse | Better coverage and diversity |
| Text control | Limited | Strong prompt control in text-to-image |
This is why most modern text-to-image tools use diffusion. GANs still appear where speed matters, such as real-time upscaling, and sometimes as components inside other systems.
Risks
GANs made realistic fake faces and videos easy to produce, fuelling early deepfakes and fake social media profiles. This is a key reason for work on synthetic media detection, watermarking and content provenance.
Limitations
- Unstable, sensitive training.
- Mode collapse reduces diversity.
- Difficult to control precisely with text.
- Can reproduce biases and even near-copies of training data.
