Phase 0: Generative AI Foundations · ~75 minutes · Python
GANs — Generator vs Discriminator
Goodfellow's trick in 2014 was to skip density entirely. Two networks. One makes fakes. One catches them. They fight until the fakes are indistinguishable from real. It shouldn't work. It often doesn't. When it does, the samples are still the sharpest in the literature for narrow domains.
What you will learn
- Implement gans — generator vs discriminator from scratch
- Understand the math and intuition behind the algorithm
- Use production libraries for the same task
- Ship a reusable artifact
Introduction
- Type: Build
- Languages: Python
- Prerequisites: Multi-Layer Networks and Forward Pass (Deep Learning from Scratch), Weight Initialization and Training Stability (Deep Learning from Scratch), Autoencoders & Variational Autoencoders (VAE), Optimizers
- Time: ~75 minutes
The Problem
VAEs produce blurry samples because their MSE decoder loss is Bayes-optimal for the mean image — and the mean of many plausible digits is a fuzzy digit. You want a loss that rewards plausibility, not pixel-wise proximity to any one target. There is no closed-form for plausibility. You have to learn it.
Goodfellow's idea: train a classifier D(x) to distinguish real images from fakes. Train a generator G(z) to fool D. The loss signal for G is whatever D currently thinks makes something look real. This signal updates as G improves, chasing a moving target. If both networks converge, G has learned the data distribution without ever writing down log p(x).
This is adversarial training. The math is a minimax game:
min_G max_D E_real[log D(x)] + E_fake[log(1 - D(G(z)))]
In 2026 GANs are no longer the SOTA generator (diffusion and flow matching ate that crown). But StyleGAN 2/3 remain the sharpest face models ever shipped, GAN discriminators are used as perceptual losses in diffusion training, and adversarial training powers the fast 1-step distillations (SDXL-Turbo, SD3-Turbo, LCM) that let you ship real-time diffusion.
Unlock the full lesson
You've read the first 2 sections. The rest of this lesson covers The Concept, Build, Check Yourself, Check Yourself, Key Terms & Next — plus a hands-on lab, quiz, and project artifact.
Create a free account — the opening phases of 29 of 35 courses are free, no credit card.
Browse all courses · View pricing · DeVenture Academy