Multimedia & Machine Learning Algorithms · Multimedia Algorithms
Generative Models: VAE and GAN
Explanation
What Are Generative Models?
A discriminative model learns — "what is the label?".
A generative model learns — "what do data look like?" — and can therefore generate new samples.
VAE — Variational Autoencoder
Idea: encode input into a latent distribution , then decode .
The ELBO (Evidence Lower BOund) — the objective to maximize:
In practice: .
KL Divergence between Gaussians:
For dimension : .
When : — the posterior perfectly matches the prior.
Reparameterization trick:
Sampling is not differentiable — backprop cannot flow through it.
Solution: where .
Now randomness is in (independent of parameters), and we can differentiate w.r.t. .
GAN — Generative Adversarial Network
Idea: two adversarial models:
- **Generator :** learns to produce samples from noise .
- **Discriminator :** learns to distinguish real data from samples of .
The minimax game:
- maximizes: wants for real data, for fakes.
- minimizes: wants to fool .
Nash equilibrium: when is perfect, for all (cannot distinguish).
Binary Cross-Entropy per step:
- loss on real:
- loss on fake:
- loss (non-saturating):
Comparison: VAE vs GAN
A discriminative model learns — "what is the label?".
A generative model learns — "what do data look like?" — and can therefore generate new samples.
VAE — Variational Autoencoder
Idea: encode input into a latent distribution , then decode .
The ELBO (Evidence Lower BOund) — the objective to maximize:
In practice: .
KL Divergence between Gaussians:
For dimension : .
When : — the posterior perfectly matches the prior.
Reparameterization trick:
Sampling is not differentiable — backprop cannot flow through it.
Solution: where .
Now randomness is in (independent of parameters), and we can differentiate w.r.t. .
GAN — Generative Adversarial Network
Idea: two adversarial models:
- **Generator :** learns to produce samples from noise .
- **Discriminator :** learns to distinguish real data from samples of .
The minimax game:
- maximizes: wants for real data, for fakes.
- minimizes: wants to fool .
Nash equilibrium: when is perfect, for all (cannot distinguish).
Binary Cross-Entropy per step:
- loss on real:
- loss on fake:
- loss (non-saturating):
Comparison: VAE vs GAN
| VAE | GAN | |
|---|---|---|
| Training | Fully optimizable (ELBO) | Unstable (mode collapse) |
| Quality | Blurry images (MSE) | Sharp images |
| Latent space | Structured, continuous | Less interpretable |
| Uses | Editing, interpolation | High-quality generation |
Interactive Visualization
Loading visualization
Worked Examples
Practice
Exercise 1 of 6
1
What problem does the Reparameterization Trick solve in a VAE?
★Quiz
Test your knowledge from this lesson
A mix of questions from the lesson — each attempt varies slightly
Answer at least 4 out of 5 questions correctly to pass (70%)