CoursesAIMathCodePhysicsAbout and FAQ

TwiddleLab / Artificial Intelligence / Generative AI: Making New Things

GANs: Forger vs Detective

Lesson 4 of 11 · 7 min · Free, no account needed

What you will learn

  • A GAN trains two networks against each other: a generator (forger) and a discriminator (detective).
  • The forger learns only from the detective's verdicts on its fakes. If the detective is too sure, the forger gets no hint and stalls.
  • When training works, fakes match the real data and the detective is right only 50% of the time, like a coin flip.
  • Mode collapse: the forger finds one fake that works and makes only that.

Start the lesson

How the lesson goes

  1. A forger and a detective train each other. Who wins in the end?

    The forger makes fake critters. The detective tries to tell real from fake.

  2. You are the detective: sort today's batch into real and fake.

    The forger is new at this. Compare with the real critters at the top.

  3. Let them train. Watch how often the detective is right.

    Orange: the fakes' ear lengths. Violet: the real ones. Dashes: where the detective says real.

  4. This detective is too strong and the forger is stuck. Find a balance.

    Change the detective's strength. Goal: the fakes reach the real critters within 10 rounds.

  5. Forger and detective together make a GAN.

    A generative adversarial network: two networks that learn by competing.

  6. Put one GAN training round in order.

    Drag each block into a numbered slot.

    Each round the forger makes a batch, the detective is trained on real and fake examples, and then the forger is updated using the detective's verdicts on its fakes.

  7. One forger has mode collapse: it found one fake that works and makes only that. Which?

    Tap a forger, then Check.

    In mode collapse the generator keeps making the one kind of output that fools the discriminator. Each fake looks fine, but there is no variety.

  8. Math: half the cards are real, half fake. A detective just flips a coin. How often is it right?

    For every card the coin matches the truth with probability 1/2, so the detective is right 50% of the time. A perfect forger pushes the best detective down to exactly this.

  9. Which GAN trained well?

    Each chart shows how often its detective was right. Tap one, then Check.

    In a GAN that works, the fakes become as good as the real data, so the detective falls to 50%. Staying near 100% means the forger is stuck; swinging means the two never settle.

  10. Now you are the forger. Fool the detective 3 rounds in a row.

    Shape your fake with the sliders and submit it. After every round the detective gets stricter.

Previous lesson: Latent Space Walks · Next lesson: Add Noise, Learn to Undo · Part of the course: Generative AI: Making New Things

Lessons are interactive and need JavaScript. Turn it on to play them.

Loading TwiddleLab