Skip to content

Generative Adversarial Network

Two networks compete: a generator makes fakes, a discriminator tries to spot them. Each improves until the fakes are hard to tell from real data.

Also GAN · generator · discriminator

Fig. / How it works
GeneratorGeneratorDiscriminatorDiscriminatorSAMPLEREAL OR FAKE?EACH SIDE GETS BETTER BY BEATING THE OTHER
Domain 06
Generative AI
Role · kind
Models and algorithmsModel
Level
Advanced

Goodfellow et al., 2014

An art forger and a detective. The forger paints fakes, the detective tries to catch them. Every time the detective gets better, the forger has to get better too, until the paintings look real.

Where it fits

+All relationships as a list

See it on the full map

How it works

A GAN trains two neural networks against each other:

  • The generator takes random noise and turns it into a sample, such as an image.
  • The discriminator looks at an image and guesses: real (from the dataset) or fake (from the generator)?

They train in turns. The discriminator learns from its mistakes to spot fakes better. The generator is updated, through the discriminator, to produce images the discriminator would call real. Neither network ever sees a “correct” image to copy; the generator learns purely from the discriminator’s feedback.

When it works, the result is striking: GANs produced the first truly photorealistic synthetic faces. When it doesn’t, the two networks oscillate, or the generator finds one image that fools the discriminator and produces nothing else (mode collapse).

Since about 2021, diffusion models have taken over most image generation because they train more reliably and cover more variety, though GAN ideas live on in fast generators and upscalers.

The mathmin⁡Gmax⁡D  Ex∼pdata[log⁡D(x)]+Ez∼p(z)[log⁡(1−D(G(z)))]\min_G \max_D \; \mathbb{E}_{x \sim p_\text{data}}[\log D(x)] + \mathbb{E}_{z \sim p(z)}[\log(1 - D(G(z)))]

Everyday use cases

  • Case 01

    Faces of people who don't exist

    StyleGAN produced the famous photorealistic faces of nonexistent people.

  • Case 02

    Photo upscaling

    Super-resolution GANs sharpen low-resolution images.

Famous examples

Strengths, weaknesses and when to use it

Strengths

  • Very sharp, realistic samples.
  • Fast generation: one network pass per image.

Weaknesses

  • Unstable, finicky training.
  • Mode collapse, where the generator only produces a few kinds of output.
  • Largely overtaken by diffusion models for text-to-image.

When to use itWhen you need very fast, sharp generation in a narrow domain (faces, a single product type) and can afford careful tuning.

Compare with

Check yourself

  1. Q01

    What is the discriminator's job?

    Show answer

    B: Tell real samples from generated ones

  2. Q02

    What is mode collapse?

    Show answer

    A: The generator produces only a few kinds of output instead of the full variety

Go deeper

Learn first