Seyed Masoud Hosseini · Overview · Study log · Weekly summaries · Ideas · Search · Transcript · RSS feed

Deep Learning Systems · Lecture 17 of 25 · 38:05

Lecture 16: Generative Adversarial Networks

Lecture 16 - Generative Adversarial Networks on YouTube

Study guide

What this lecture covers

This lecture introduces generative modeling as a departure from the supervised classification tasks covered earlier in the course, then presents generative adversarial networks (GANs) as one approach to it. It builds the idea in two stages: first the general mechanism of adversarial training, then how a trained GAN can be treated as a reusable module inside larger deep learning pipelines.

After watching, you should be able to explain why generative modeling needs a learned discriminator rather than a fixed distance function, describe the minimax objective that alternates discriminator and generator updates, and explain how CycleGAN composes multiple GAN losses to learn image-to-image translation from unpaired data.

Key ideas

  • Generative vs. supervised modeling: instead of mapping labeled inputs to predictions, a generator maps a random vector to a sample and is trained, without labels, to make the whole collection of generated samples resemble a target data distribution.
  • The core difficulty: there's no obvious differentiable way to measure the distance between a generated distribution and a real distribution directly.
  • Oracle discriminator idea: if a perfect classifier could tell real from generated data, the generator could be trained to fool it; since no such oracle exists, GANs learn a discriminator alongside the generator.
  • Minimax objective: the discriminator is trained to classify real data as real and generated data as fake (minimizing a negative log-likelihood loss), while the generator is trained to make the discriminator classify its output as real.
  • Alternating updates: GAN training iterates between a discriminator update step and a generator update step, each using freshly sampled mini-batches of real and generated data.
  • Modularity of deep learning: because components like loss functions and backbones can be swapped independently, a trained adversarial mechanism can be treated as a loss-like module rather than hand-coded custom training logic.
  • DCGAN: deep convolutional GANs use transposed convolution (Conv2dTranspose, also called deconvolution) layers to map a small input vector up to a larger generated image.
  • CycleGAN: learns bidirectional image-to-image translation from unpaired data by combining two GAN losses (one per translation direction) with an L1 cycle-consistency loss that penalizes drift when mapping an image forward and back.

Walkthrough

From classifier to generator (0:42)

The lecture contrasts supervised classification, where each prediction can be evaluated against a single label, with generative modeling, where the goal is to make a whole collection of generated samples resemble a target distribution, using no labels at all.

Defining a distance between distributions and the oracle discriminator idea (5:21)

The lecture poses the central question: how do you define a differentiable measure of distance between two distributions? It introduces the thought experiment of an oracle classifier that can perfectly distinguish real from generated data, and shows that if such an oracle existed, the generator could be trained by backpropagating through it to fool it.

Learning the discriminator and the minimax game (10:35)

Since no oracle exists, the lecture proposes learning a discriminator neural network alongside the generator, trained on real data (labeled real) and generator output (labeled fake). Putting both pieces together produces the GAN minimax objective, with the discriminator minimizing a classification loss and the generator trying to maximize the discriminator's error on generated samples, updated in alternating steps.

Generative adversarial training in practice (14:48)

The training loop is described concretely: sample a mini-batch of generated and real data, update the discriminator to minimize its classification loss, then sample generated data again and update the generator to maximize the discriminator's error, effectively flipping the label used for the generated batch between the two update steps.

GANs as a modular loss and DCGAN (21:06)

The lecture reframes GAN training as a module that behaves like a loss function, composable with other deep learning building blocks, which is presented as central to why deep learning scales to complex architectures. DCGAN is introduced as a convolutional generator that uses transposed convolution layers to expand a small input vector into a full image.

CycleGAN (27:54)

CycleGAN tackles unpaired image-to-image translation (for example, photos to Monet-style paintings) by combining a forward GAN loss, a backward GAN loss, and a cycle-consistency loss that penalizes the difference between an original image and the result of translating it forward and then back. The lecture walks through how these four loss terms compose into a single trainable model, illustrating the value of treating GANs as reusable modules.

Before you watch

  • Review the course's earlier lectures on multilayer perceptrons and residual network architectures, which this lecture assumes as background.
  • Be comfortable with backpropagation and gradient-based optimization, since GAN training is described in terms of alternating gradient updates.

Check your understanding

  1. Why can't generative modeling use a simple fixed distance function the way supervised learning uses a label-based loss?
  2. What roles do the generator and discriminator each play in the minimax objective, and what does each try to maximize or minimize?
  3. Why does the lecture describe deep learning's modular nature as important to how GANs get used in practice?
  4. What problem does the cycle-consistency loss solve in CycleGAN, and why is it needed alongside the two GAN losses?

Vocabulary

generative modeling (noun)
Building a model that creates new data similar to a training set, instead of predicting labels.
Generative modeling is a departure from supervised classification.
supervised (adjective)
Trained using data that comes with correct labels.
Earlier lectures focused on supervised classification tasks.
discriminator (noun)
A network trained to tell real data apart from generated data.
The discriminator learns to spot fake samples.
generator (noun)
A network trained to produce new samples that look like real data.
The generator maps random noise to an image.
distribution (noun)
The overall pattern of how values or data points are spread out.
The generator should match the real data distribution.
oracle (noun)
An imagined perfect source of correct answers, used as a thought experiment.
An oracle discriminator could tell real from fake perfectly.
differentiable (adjective)
Able to have a derivative computed, so gradients can flow through it.
There's no obvious differentiable distance between two distributions.
minimax (noun)
A setup where one side tries to minimize a value while the other tries to maximize it.
GAN training uses a minimax objective.
negative log-likelihood (noun)
A loss that measures how unlikely the correct answer was under the model's prediction.
The discriminator minimizes a negative log-likelihood loss.
alternating (adjective)
Switching back and forth between two things in turn.
GAN training uses alternating updates.
fool (verb)
To trick something into making a wrong judgment.
The generator tries to fool the discriminator.
backbone (noun)
The main network structure that processes data before a task-specific head.
GANs can be combined with different backbones.
transposed convolution (noun)
An operation that increases the spatial size of data, roughly the reverse of a normal convolution.
DCGAN uses transposed convolution to build up an image.
deconvolution (noun)
Another name for a transposed convolution used to upsample data.
Deconvolution layers expand a small vector into a full image.
bidirectional (adjective)
Working in both directions.
CycleGAN learns a bidirectional image translation.
unpaired data (noun)
Training examples that are not matched one-to-one between two sets.
CycleGAN learns from unpaired photos and paintings.
cycle-consistency loss (noun)
A penalty that checks an image still looks the same after being translated forward and then back.
The cycle-consistency loss prevents drift in CycleGAN.
drift (noun)
A gradual, unwanted change away from the original value.
Cycle-consistency loss penalizes drift between translations.
compose (verb)
To combine smaller pieces into a larger system.
CycleGAN composes four loss terms into one model.
departure (noun)
A change away from a previous method or approach.
Generative modeling is a departure from classification.
modular (adjective)
Built from separate, swappable parts.
Deep learning's modular nature lets a GAN act like a loss.

Chapters

From the YouTube description

This lecture introduces generative modeling and specifically the particular class of generative adversarial network. We also cover how this kind of "GAN module" can be used to enable other capabilities, such as unpaired image translation.

← Lecture 15: Training Large Models · Lecture 17: Generative Adversarial Networks Implementation →