The AI Handbook Open in the app →

Generative Adversarial Network

Models & Architectures · Advanced · 5 min read

What is it?

A GAN is a pair of neural networks — a generator that fakes data and a discriminator that judges it — trained against each other until the fakes look real.

Explain like I'm 5

A forger tries to paint convincing fakes while a detective tries to spot them. As each gets better, the forger's paintings become nearly indistinguishable from real ones.

Why was it created?

Before GANs, generating realistic images was hard. The adversarial setup gave a clever training signal: let a critic network teach the generator what 'realistic' means.

Where is it used?

  • Realistic image generation
  • Image-to-image translation
  • Super-resolution
  • Synthetic training data

Why should developers care?

GANs kicked off the modern wave of generative AI imagery and still matter for understanding how generative models are trained and evaluated.

How does it work?

The generator turns random noise into fake samples; the discriminator classifies samples as real or fake. Their losses oppose each other, so training is a minimax game — the generator improves to fool the discriminator, which improves to catch it, until the fakes are convincing.

Real-world example

A GAN generates photorealistic faces of people who don't exist, learning from a dataset of real portraits.

Common use cases

  • Photorealistic image synthesis
  • Style transfer and translation
  • Upscaling low-res images
  • Data augmentation

Advantages

  • Sharp, realistic samples
  • Fast generation (single pass)
  • Flexible across image tasks
  • No explicit likelihood needed

Disadvantages

  • Unstable, tricky training
  • Mode collapse (limited variety)
  • Hard to evaluate objectively
  • Largely overtaken by diffusion for many tasks

When should you use it?

When you need fast, realistic sample generation and can manage the finicky training.

When should you avoid it?

When training stability and diversity matter more — diffusion models are often the better modern choice.

Alternatives

Diffusion modelsVariational autoencoders (VAEs)Autoregressive generators

Related terms

Diffusion ModelNeural NetworkDeep LearningTraining

Interview questions

Beginner

  • What are the two networks in a GAN?
  • What is each network trying to do?

Intermediate

  • What is mode collapse?
  • Why is GAN training considered unstable?

Senior

  • How do GANs and diffusion models differ in training signal?
  • How would you evaluate GAN sample quality and diversity?

Common misconceptions

  • "The discriminator is used at generation time" — only the generator is needed once trained.
  • "GANs are the state of the art for all image generation" — diffusion models now lead many tasks.

Fun facts

  • GANs were famously described by their inventor as the coolest idea in deep learning in years.
  • 'This person does not exist' style demos were powered by GANs.

Timeline

  • 2014 — GANs introduced by Goodfellow et al.
  • 2018 — High-resolution photorealistic GANs (e.g. StyleGAN)

Learning resources

Quick summary

A GAN trains a generator and a discriminator against each other until the generator's fakes look real; it launched modern generative imagery.

Cheat sheet

  • Generator vs discriminator
  • Adversarial minimax training
  • Fast, sharp samples
  • Unstable; diffusion often preferred now

If you remember only one thing

A GAN pits a fake-maker against a fake-detector, and their arms race produces increasingly realistic generated data.