Generative Adversarial Networks (GANs)
One network creates fakes, another tries to catch them. The competition makes both brilliant.
By the end of this lesson you will be able to
- name the two parts of a GAN and what each one does
- explain how competition makes both parts improve
- list where GANs are used, and why they are hard to train
One person makes fake currency. Another is a police officer checking notes. Every time the officer catches a fake, the counterfeiter learns and improves. Every time a fake slips through, the officer gets sharper. Both keep improving because they compete. That is how a GAN works.
GAN = āOne AI creates fake things, another AI checks if they look real.ā Both improve by competing.
The two parts of a GAN
1. Generator: the faker šØ
Job: create fake data that looks real: a face, a voice, an image, handwriting.
It starts from random noise, so at first its output is terrible: blurry faces, weird shapes, nonsense.
2. Discriminator: the judge š
Job: decide whether data is real or fake.
It sees real images from the dataset and fake images from the generator, and says āthis is realā or āthis is fakeā.
How training happens: a game
Step 1
The generator creates a fake image, for example a fake cat.
Step 2
The discriminator compares it with real cat images and says: āThis looks fake.ā
Step 3
The generator learns from the mistake and improves its next fake.
Step 4
The discriminator also gets smarter and detects better fakes.
| Generator gets⦠| Discriminator gets⦠|
|---|---|
| Better at making fakes | Better at detecting fakes |
| Learns realism | Learns to spot errors |
This competition repeats thousands or millions of times. Eventually the fakes become so realistic that the discriminator can no longer tell the difference, which means the generator has become very good.
A student forges a teacher's signature. The teacher says āFake.ā The student improves; the teacher becomes more careful. After many tries, the signature is almost identical. That learning competition is a GAN.
Example: faces that never existed
Train a GAN on thousands of real human faces. The generator learns eye placement, skin texture, nose shapes, lighting and hair patterns. After training it can generate completely new faces of people who have never existed.
The generator does not memorise exact images. It learns the patterns of real data: how eyes are placed, how shadows fall, how textures look.
Where GANs are used
Image generation
Realistic synthetic photos.
AI art
Creative image synthesis.
Face ageing
Young ā old face conversion.
Super-resolution
Sharpen blurry, low-resolution images.
Medical imaging
Generate extra training samples where real data is scarce.
Deepfakes
Fake videos and voices, a serious misuse risk.
The same technology that restores old photos can produce deepfakes used for fraud and misinformation. Always consider consent and disclose AI-generated media.
The main weakness: GANs are hard to train
- Unstable training: the two networks can oscillate instead of improving together.
- Mode collapse: the generator finds one kind of fake that fools the judge and keeps producing only that.
- Weird outputs such as distorted hands or backgrounds.
- An overpowered discriminator rejects everything, so the generator gets no useful feedback.
Getting a GAN to train properly is hard even for experienced ML engineers. That's one reason many modern image generators use diffusion models instead.
A simple technical view
Generator's goal
Minimise how fake its output looks to the discriminator.
Discriminator's goal
Maximise how correctly it detects fakes.
Mathematically they are opponents, which is why it's called a Generative Adversarial Network. āAdversarialā means competing or opposing.
Key takeaways
- A GAN has a generator (the faker) and a discriminator (the judge).
- They improve by competing, until fakes become indistinguishable from real data.
- GANs produce sharp, realistic images but are notoriously hard to train.
Check your understanding
1. What does the generator start from?
The generator transforms random noise into data; it never copies real images directly.
2. When is a GAN's training considered successful?
If the judge is reduced to guessing, the generator's fakes are realistic.
3. What is āmode collapseā?
It's a classic GAN failure: variety disappears because one trick keeps working.