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 lessonStep by step
Not enough fraud examples
Real fraud is rare, so there are few examples to learn from. Leo wonders about generating realistic synthetic ones.
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?
Round 1: easy to catch
At first the generator makes static. The discriminator easily learns to spot it.
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.
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.
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?
- Tell real images from generated ones (correct)
- Generate new images
- Write the labels
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.