← Lessons

quiz vs the machine

Platinum1730

Machine Learning

The Adversarial Generator And Discriminator

A generator and a critic locked in a game that produces realistic samples.

6 min read · advanced · beat Platinum to climb

A two player game

A generative adversarial network, or GAN, trains two networks against each other. The generator tries to produce fake samples that look real, while the discriminator tries to tell real data from fakes. Their competition drives both to improve.

How training works

The two networks update in alternation:

  • The discriminator sees a mix of real examples and generated fakes and learns to classify which is which
  • The generator takes random noise and learns to fool the discriminator, getting gradient signal from the critic mistakes
  • As the discriminator gets sharper, the generator is pushed to make more convincing samples

At the ideal equilibrium the fakes are indistinguishable from real data and the discriminator can only guess.

The hard parts

GANs can produce stunningly sharp images but are notoriously unstable to train:

  • Mode collapse happens when the generator produces only a few outputs that reliably fool the critic
  • Balancing the two networks is delicate, since one overpowering the other stalls learning
  • Many variants add tricks like a different loss to stabilize the game

Key idea

A GAN pits a generator that fabricates samples against a discriminator that detects fakes, and their adversarial game yields realistic outputs despite tricky, unstable training.

Check yourself

Answer to earn rating on the learn ladder.

1. What are the two networks in a GAN?

2. What is mode collapse?