Generative Modelling
Sudeshna Sarkar
Professor, Computer Science & Engineering
Professor, Centre of Excellence in Artificial Intelligence
Sudeshna Sarkar, IIT Kharagpur
20-10-2022
Slides source
Sudeshna Sarkar, IIT Kharagpur
20-10-2022
What is a generative model
Sudeshna Sarkar, IIT Kharagpur
20-10-2022
seed
Question: how do we generate the random seeds…
Sudeshna Sarkar, IIT Kharagpur
20-10-2022
Sudeshna Sarkar, IIT Kharagpur
20-10-2022
Generative Models
Training data ~ pdata(x)
Generated samples ~ pmodel(x)
Given training data, generate new samples from same distribution
Formulate as density estimation problems
pmodel(x)
learning
sampling
The distribution of data
Hypothesis: The data are distributed about a non-linear manifold in high dimensional space
Problems:
Sudeshna Sarkar, IIT Kharagpur
20-10-2022
Application of Generative Models
Sudeshna Sarkar, IIT Kharagpur
20-10-2022
Taxonomy of Generative Models
Sudeshna Sarkar, IIT Kharagpur
20-10-2022
Generative models
Explicit density
Implicit density
Direct
Tractable density
Approximate density
Markov Chain
Variational
Markov Chain
Fully Visible Belief Nets
Change of variables models (nonlinear ICA)
Variational Autoencoder
Boltzmann Machine
GSN
GAN
Figure copyright and adapted from Ian Goodfellow, Tutorial on Generative Adversarial Networks, 2017.
Slide Credit: Fei-Fei Li, Justin Johnson, Serena Yeung, CS 231n
Taxonomy of Generative Models
Sudeshna Sarkar, IIT Kharagpur
20-10-2022
Generative models
Explicit density
Implicit density
Direct
Tractable density
Approximate density
Markov Chain
Variational
Markov Chain
Fully Visible Belief Nets
Change of variables models (nonlinear ICA)
Variational Autoencoder
Boltzmann Machine
GSN
GAN
Figure copyright and adapted from Ian Goodfellow, Tutorial on Generative Adversarial Networks, 2017.
Slide Credit: Fei-Fei Li, Justin Johnson, Serena Yeung, CS 231n
Autoregressive generative models
Sudeshna Sarkar, IIT Kharagpur
20-10-2022
Main principle for training:
each of these is just a softmax
Using autoregressive generative models:
Deep Generative Models
We will introduce two representative deep generative models:
12
20-Oct-22
Latent Variable Models
Autoencoders and VAE
Generative Adversarial Networks
13
20-Oct-22
Latent Variables and VAE
Can we learn the true explanatory factors (latent variables) from observed data
14
20-Oct-22
Variational Auto Encoders
VAEs are a combination of the following ideas:
(C) Dhruv Batra
15
Autoencoder
A neural network that reconstructs its own input.
reproduces the input from a learned encoding.
Sudeshna Sarkar, IIT Kharagpur
20-10-2022
Basic idea:
1. Train a network that encodes the input into some hidden state
2. decodes that input as accurately as possible from that hidden state
Hidden state
this is what we use for downstream tasks
encoder
decoder
The autoencoder captures the underlying manifold of the data
Forcing structure in Autoencoder
Forcing structure: something about the design of the model, or in the data processing or regularization, must force the autoencoder to learn a structured representation
Sudeshna Sarkar, IIT Kharagpur
20-10-2022
Autoencoders
Slide Credit: Fei-Fei Li, Justin Johnson, Serena Yeung, CS 231n
Reconstructed data
Input data
Encoder: 4-layer conv
Decoder: 4-layer upconv
Encoder
Input data
Features
Decoder
Reconstructed input data
L2 Loss function:
Bottleneck autoencoder
Sudeshna Sarkar, IIT Kharagpur
20-10-2022
encoder
hidden
state
decoder
100 x 100 =
10,000 dimensions
128 dimensions
Sparse autoencoder
Sudeshna Sarkar, IIT Kharagpur
20-10-2022
Idea: can we describe the input with a small set of “attributes”?
This might be a more compressed and structured representation
Pixel (0,0): #FE057D
Pixel (0,1): #FD0263
Pixel (0,2): #E1065F
NOT structured
“dense”: most values non-zero
has_ears: 1
has_wings: 0
has_wheels: 0
very structured!
“sparse”: most values are zero
there are many possible “attributes,” and most images don’t have most of the attributes
Idea: “sparse” representations are going to be more structured!
Sparse autoencoder
Sudeshna Sarkar, IIT Kharagpur
20-10-2022
encoder
hidden state
decoder
sparsity loss
dimensionality might be very large, even larger than the input!
called overcomplete
“L1 regularization”
“L2 regularization”
Sparse Autoencoder
Sudeshna Sarkar, IIT Kharagpur
20-10-2022
Contractive Autoencoders
Sudeshna Sarkar, IIT Kharagpur
20-10-2022
Denoising autoencoder
Sudeshna Sarkar, IIT Kharagpur
20-10-2022
Idea: a good model that has learned meaningful structure should “fill in the blanks”
encoder
hidden state
decoder
There are many variants on this basic idea, and this is one of
the most widely used simple autoencoder designs
Can train an autoencoder to learn to denoise input by giving input corrupted instance ˜x and targeting uncorrupted instance x
Denoising Autoencoder
Sudeshna Sarkar, IIT Kharagpur
20-10-2022
The types of autoencoders: Forcing Structure
Sudeshna Sarkar, IIT Kharagpur
20-10-2022
1. Dimensionality: make the hidden state smaller than the input/output, so that the network must compress it
+ very simple to implement
- simply reducing dimensionality often does not provide the structure we want
2. Sparsity: force the hidden state to be sparse (most entries are 0), so that the network must compress input
+ principled approach that can provide a “disentangled” representation
3. Denoising: corrupt the input with noise, forcing the autoencoder to learn to distinguish noise from signal
+ very simple to implement
AE for generation
Sudeshna Sarkar, IIT Kharagpur
20-10-2022
Decoder
The problem with AEs
Sudeshna Sarkar, IIT Kharagpur
20-10-2022
Variational Autoencoders
Probabilistic spin on autoencoders - will let us sample from the model to generate data!
Image Credit: https://jaan.io/what-is-variational-autoencoder-vae-tutorial/
Impose distribution on z
20-10-2022
DECODER
Encoder output must be Gaussian
ENCODER
Generation
To generate novel values, sample z from prescribed distribution N(0,1)
20-10-2022
DECODER
How to train the model
Problem: How does one train an AE to ensure that the hidden representation z has a specific distribution e.g., N(0,1)
20-10-2022
Encoder output must be Gaussian
DECODER
ENCODER
How to train the model
Sudeshna Sarkar, IIT Kharagpur
20-10-2022
Encoder
Decoder
Training with statistical constraints
Sudeshna Sarkar, IIT Kharagpur
20-10-2022
Encoder
Decoder
Training with statistical constraints
Encoder
Decoder
This formulation does not adequately capture the variation in the data
The actual model
Sudeshna Sarkar, IIT Kharagpur
20-10-2022
The distribution of the data
Sudeshna Sarkar, IIT Kharagpur
20-10-2022
The distribution of the data
Sudeshna Sarkar, IIT Kharagpur
20-10-2022
The distribution of the data
Sudeshna Sarkar, IIT Kharagpur
20-10-2022
The distribution of the data
Sudeshna Sarkar, IIT Kharagpur
20-10-2022
The distribution of the data
Sudeshna Sarkar, IIT Kharagpur
20-10-2022
The variational autoencoder
Sudeshna Sarkar, IIT Kharagpur
20-10-2022
Encoder
Decoder
The variational autoencoder
Sudeshna Sarkar, IIT Kharagpur
20-10-2022
Encoder
Decoder
The variational autoencoder
Sudeshna Sarkar, IIT Kharagpur
20-10-2022
Encoder
Decoder
The variational autoencoder
Sudeshna Sarkar, IIT Kharagpur
20-10-2022
Encoder
Decoder
The variational autoencoder
Sudeshna Sarkar, IIT Kharagpur
20-10-2022
Encoder
Decoder
Sudeshna Sarkar, IIT Kharagpur
20-10-2022
The variational autoencoder
Sudeshna Sarkar, IIT Kharagpur
20-10-2022
Decoder
encoder
Training the encoder
Sudeshna Sarkar, IIT Kharagpur
20-10-2022
Training the encoder
Sudeshna Sarkar, IIT Kharagpur
20-10-2022
2
2
Training the encoder
Sudeshna Sarkar, IIT Kharagpur
20-10-2022
2
2
Training the encoder
20-10-2022
2
2
Sudeshna Sarkar, IIT Kharagpur
20-10-2022
VAE Computation Graph
Problem: Cannot backpropagate gradients through sampling layers
Reparametrizing the sampling layer
55
20-Oct-22
VAE network with and without the “reparameterization” trick
56
20-Oct-22
𝜙 representations the distribution the network is trying to learn.
The epsilon remains as a random variable (sampled from a standard normal distribution) with a very low value thereby not causing the network to shift away too much from the true distribution.
The distribution 𝜙 (parameterized by the mean and log-variance vectors) is still being learned by the network. This idea actually allowed a VAE to train in an end-to-end manner
Training the encoder
The variational autoencoder
Sudeshna Sarkar, IIT Kharagpur
20-10-2022
Decoder
encoder
Training the decoder
20-10-2022
The variational autoencoder
Sudeshna Sarkar, IIT Kharagpur
20-10-2022
Decoder
encoder
The constraint on P(z)
Sudeshna Sarkar, IIT Kharagpur
20-10-2022
The constraint on P(z)
20-10-2022
The complete training pipeline
Sudeshna Sarkar, IIT Kharagpur
20-10-2022
The VAE for generation
Sudeshna Sarkar, IIT Kharagpur
20-10-2022
VAE Takeaways
Sudeshna Sarkar, IIT Kharagpur
20-10-2022
Sample z
The Variational AutoEncoder
Sudeshna Sarkar, IIT Kharagpur
20-10-2022
VAE and latent spaces
20-10-2022
VAEs : Latent perturbation
69
20-Oct-22
VAEs : Latent perturbation
70
20-Oct-22
Sudeshna Sarkar, IIT Kharagpur
20-10-2022
Variational Autoencoders
Sudeshna Sarkar, IIT Kharagpur
20-10-2022
Variational Autoencoders�Latent Variables
Sudeshna Sarkar, IIT Kharagpur
20-10-2022
Variational �Autoencoders�Architecture
Sudeshna Sarkar, IIT Kharagpur
20-10-2022
Variational Autoencoders�Optimization
Sudeshna Sarkar, IIT Kharagpur
20-10-2022
Variational Autoencoders�Reparameterization Trick
Sudeshna Sarkar, IIT Kharagpur
20-10-2022
Variational Autoencoders�Example Generated Images: Random
Sudeshna Sarkar, IIT Kharagpur
20-10-2022
Variational Autoencoders�Example Generated Images: Manifold
Sudeshna Sarkar, IIT Kharagpur
20-10-2022