Gradient LabStart the lesson

Lessons › Chapter 12: Generative models

GANs

A GAN has two networks. The generator turns random noise into fake images. The discriminator looks at an image and judges: real or fake?

Watch it move. This lesson is interactive on Gradient Lab: every step is an animated scene you can replay.

Start the interactive lesson

Step by step

Story

Not enough fraud examples

Real fraud is rare, so there are few examples to learn from. Leo wonders about generating realistic synthetic ones.

Concept

Two players

A GAN has two networks. The generator turns random noise into fake images. The discriminator looks at an image and judges: real or fake?

Build

Round 1: easy to catch

At first the generator makes static. The discriminator easily learns to spot it.

Key idea

The generator adapts

The generator learns from the discriminator’s verdicts, adjusting until its fakes slip past. Then the discriminator sharpens up. Each one forces the other to improve.

Build

Fakes that look real

Eventually the fakes look so real that the discriminator can only guess, about 50/50. The generator has learned to produce convincing new images from random noise.

Real life

In real life: faces that don’t exist

GANs produced the first startlingly realistic AI-generated faces, and they’re also behind photo upscaling and synthetic training images. The same power enables deepfakes, which is why tools for detecting generated media matter too.

Quick check: What is the discriminator’s job?

It’s the critic; the generator is the forger trying to fool it.

Pseudocode

generator: random noise → a fake image
discriminator: an image → "real" or "fake"?
repeat:
    train the discriminator to catch the fakes
    train the generator to fool the discriminator
# they push each other to improve

Key terms

generator
In a GAN, the network that turns random noise into fake examples.
discriminator
In a GAN, the network that tries to tell real examples from generated ones.