Machine learning models · Phase 5 · Lesson 43

Generative adversarial networks

Understand the generator-discriminator game and why GAN training can be powerful but unstable.

This is one focused step in the 60-lesson course. Use the retrieval check before moving on.

Lesson goal

Understand the generator-discriminator game and why GAN training can be powerful but unstable.

The core idea

A generator makes samples. A discriminator tries to distinguish real from generated samples. Each improves in response to the other.

Mental model

Picture it this way. A generator makes samples. A discriminator tries to distinguish real from generated samples. Each improves in response to the other. The important question is what assumption this picture makes, and whether that assumption fits the data.

Mathematical core

The original GAN objective is a minimax game between discriminator D and generator G. In practice, variants alter losses, architectures and regularisation to improve gradient behaviour.

Worked example

A generator can learn to produce plausible faces from random vectors, but it may collapse to a few styles if the discriminator gives unhelpful feedback.

When to use it

It earns a place when

  • Use GANs when sharp samples and adversarial distribution matching are useful and you can monitor training carefully.
  • You can evaluate it against a credible baseline.
  • Its output fits the decision and data constraints.

Do not make it the default when

  • Do not use sample realism as the only measure, or assume the generator covers the full data distribution.
  • A simpler model has not been tested.
  • The data or target definition is still unclear.

Failure modes

Watch for this. Mode collapse, oscillation, unstable losses and memorisation are common. Discriminator accuracy alone is not a generator quality metric.

When a result looks surprisingly good, inspect the split, target timing, error slices and data-generating process before celebrating.

Practice

Use this as a small experiment rather than a recipe to copy blindly. Change one thing, record the result and explain the change.

Do this. Train a tiny GAN on a simple one-dimensional or image distribution. Plot generated samples over training and record whether diversity changes.

Retrieval check

Answer from memory first. The buttons reveal feedback, but the durable step is explaining why.

1. What does the discriminator do?

2. What is mode collapse?

3. Why is discriminator accuracy insufficient?

Transfer prompt. Describe one real problem where this model or idea would be a sensible candidate. Name the target, the main risk and the metric you would inspect.

Primary source

Generative Adversarial Nets. Use the source for the deeper treatment after you can explain the lesson's core idea without looking.