Taxonomy of generative models - TUMTaxonomy of generative models Prof. Leal-Taixé and Prof....

88
Taxonomy of generative models Prof. Leal-Taixé and Prof. Niessner 1 Figure from Ian Goodfellow, Tutorial on Generative Adversarial /networks, 2017

Transcript of Taxonomy of generative models - TUMTaxonomy of generative models Prof. Leal-Taixé and Prof....

Page 1: Taxonomy of generative models - TUMTaxonomy of generative models Prof. Leal-Taixé and Prof. Niessner Figure from Ian Goodfellow, Tutorial on Generative Adversarial /networks, 2017

Taxonomy of generative models

Prof. Leal-Taixé and Prof. Niessner 1Figure from Ian Goodfellow, Tutorial on Generative Adversarial /networks, 2017

Page 2: Taxonomy of generative models - TUMTaxonomy of generative models Prof. Leal-Taixé and Prof. Niessner Figure from Ian Goodfellow, Tutorial on Generative Adversarial /networks, 2017

Taxonomy of generative models

Prof. Leal-Taixé and Prof. Niessner 2Figure from Ian Goodfellow, Tutorial on Generative Adversarial /networks, 2017

Page 3: Taxonomy of generative models - TUMTaxonomy of generative models Prof. Leal-Taixé and Prof. Niessner Figure from Ian Goodfellow, Tutorial on Generative Adversarial /networks, 2017

Generative Adversarial Networks

Prof. Leal-Taixé and Prof. Niessner 3

Page 4: Taxonomy of generative models - TUMTaxonomy of generative models Prof. Leal-Taixé and Prof. Niessner Figure from Ian Goodfellow, Tutorial on Generative Adversarial /networks, 2017

Generative Adversarial Networks (GANs)

Prof. Leal-Taixé and Prof. Niessner 4https://github.com/hindupuravinash/the-gan-zoo

Page 5: Taxonomy of generative models - TUMTaxonomy of generative models Prof. Leal-Taixé and Prof. Niessner Figure from Ian Goodfellow, Tutorial on Generative Adversarial /networks, 2017

Convolution and Deconvolution

Convolutionno padding, no stride

https://github.com/vdumoulin/conv_arithmetic

Transposed convolutionno padding, no stride

Input

Output

Input

Output

Page 6: Taxonomy of generative models - TUMTaxonomy of generative models Prof. Leal-Taixé and Prof. Niessner Figure from Ian Goodfellow, Tutorial on Generative Adversarial /networks, 2017

Autoencoder

Conv Deconv

Page 7: Taxonomy of generative models - TUMTaxonomy of generative models Prof. Leal-Taixé and Prof. Niessner Figure from Ian Goodfellow, Tutorial on Generative Adversarial /networks, 2017

Reconstruction: Autoencoder

Conv Deconv

Input Image Output Image

ReconstructionLoss (often L2)

Page 8: Taxonomy of generative models - TUMTaxonomy of generative models Prof. Leal-Taixé and Prof. Niessner Figure from Ian Goodfellow, Tutorial on Generative Adversarial /networks, 2017

Training Autoencoders

Latent space zdim (z) < dim (x)

Inp

ut

x

Reco

nst

ruct

ion x

Input images

Reconstructed images

Page 9: Taxonomy of generative models - TUMTaxonomy of generative models Prof. Leal-Taixé and Prof. Niessner Figure from Ian Goodfellow, Tutorial on Generative Adversarial /networks, 2017

Decoder as Generative Model

Latent space zdim (z) < dim (x)

“Test time”:-> reconstruction from

‘random’ vector

Output Image

ReconstructionLoss (often L2)

Page 10: Taxonomy of generative models - TUMTaxonomy of generative models Prof. Leal-Taixé and Prof. Niessner Figure from Ian Goodfellow, Tutorial on Generative Adversarial /networks, 2017

Decoder as Generative Model

Interpolation between two chair models

[Dosovitsky et al. 14] Learning to Generate Chairs

Page 11: Taxonomy of generative models - TUMTaxonomy of generative models Prof. Leal-Taixé and Prof. Niessner Figure from Ian Goodfellow, Tutorial on Generative Adversarial /networks, 2017

Decoder as Generative Model

[Dosovitsky et al. 14] Learning to Generate Chairs

Morphing betweenchair models

Page 12: Taxonomy of generative models - TUMTaxonomy of generative models Prof. Leal-Taixé and Prof. Niessner Figure from Ian Goodfellow, Tutorial on Generative Adversarial /networks, 2017

Decoder as Generative Model

Latent space zdim (z) < dim (x)

“Test time”:-> reconstruction from

‘random’ vector

Reconstruction Loss Often L2, i.e., sum of squared dist.-> L2 distributes error equally

-> mean is opt.-> res. Is blurry

Instead of L2, can we “learn”a loss function?

Page 13: Taxonomy of generative models - TUMTaxonomy of generative models Prof. Leal-Taixé and Prof. Niessner Figure from Ian Goodfellow, Tutorial on Generative Adversarial /networks, 2017

Generative Adversarial Networks (GANs)

[Goodfellow et al. 14] GANs (slide McGuinness)Prof. Leal-Taixé and Prof. Niessner 13

𝑧𝐺

𝐺(𝑧)

𝐷

𝐷(𝐺(𝑧))

Page 14: Taxonomy of generative models - TUMTaxonomy of generative models Prof. Leal-Taixé and Prof. Niessner Figure from Ian Goodfellow, Tutorial on Generative Adversarial /networks, 2017

Generative Adversarial Networks (GANs)

[Goodfellow et al. 14] GANs (slide McGuinness)Prof. Leal-Taixé and Prof. Niessner 14

𝑧𝐺

𝐺(𝑧)

𝐷

𝑥

𝐷(𝑥)

𝐷(𝐺(𝑧))

Page 15: Taxonomy of generative models - TUMTaxonomy of generative models Prof. Leal-Taixé and Prof. Niessner Figure from Ian Goodfellow, Tutorial on Generative Adversarial /networks, 2017

Generative Adversarial Networks (GANs)

[Goodfellow et al. 14/16] GANs

real data fake data

Page 16: Taxonomy of generative models - TUMTaxonomy of generative models Prof. Leal-Taixé and Prof. Niessner Figure from Ian Goodfellow, Tutorial on Generative Adversarial /networks, 2017

Discriminator loss

Generator loss binary cross entropy

GANs: Loss Functions

• Minimax Game:

– G minimizes probability that D is correct

– Equilibrium is saddle point of discriminator loss

[Goodfellow et al. 14/16] GANs

-> D provides supervision (i.e., gradients) for G

Page 17: Taxonomy of generative models - TUMTaxonomy of generative models Prof. Leal-Taixé and Prof. Niessner Figure from Ian Goodfellow, Tutorial on Generative Adversarial /networks, 2017

• Heuristic Method (often used in practice)

– G maximizes the log-probability of D being mistaken

– G can still learn even when D rejects all generator samples

Discriminator loss

GANs: Loss Functions

[Goodfellow et al. 14/16] GANs

Generator loss

Page 18: Taxonomy of generative models - TUMTaxonomy of generative models Prof. Leal-Taixé and Prof. Niessner Figure from Ian Goodfellow, Tutorial on Generative Adversarial /networks, 2017

Alternating Gradient Updates

• Step 1: Fix G, and perform gradient step to

• Step 2: Fix D, and perform gradient step to

Prof. Leal-Taixé and Prof. Niessner 18

Page 19: Taxonomy of generative models - TUMTaxonomy of generative models Prof. Leal-Taixé and Prof. Niessner Figure from Ian Goodfellow, Tutorial on Generative Adversarial /networks, 2017

Vanilla GAN

Prof. Leal-Taixé and Prof. Niessner 19https://papers.nips.cc/paper/5423-generative-adversarial-nets

Page 20: Taxonomy of generative models - TUMTaxonomy of generative models Prof. Leal-Taixé and Prof. Niessner Figure from Ian Goodfellow, Tutorial on Generative Adversarial /networks, 2017

Training a GAN

Prof. Leal-Taixé and Prof. Niessner 20

https://medium.com/ai-society/gans-from-scratch-1-a-deep-introduction-with-code-in-pytorch-and-tensorflow-cb03cdcdba0f

Page 21: Taxonomy of generative models - TUMTaxonomy of generative models Prof. Leal-Taixé and Prof. Niessner Figure from Ian Goodfellow, Tutorial on Generative Adversarial /networks, 2017

GANs: Loss Functions

[Goodfellow et al. 14/16] GANs

Minimax

Heuristic

Page 22: Taxonomy of generative models - TUMTaxonomy of generative models Prof. Leal-Taixé and Prof. Niessner Figure from Ian Goodfellow, Tutorial on Generative Adversarial /networks, 2017

DCGAN: Generator

DCGAN: https://github.com/carpedm20/DCGAN-tensorflow

Generator of Deep Convolutional GANs

Page 23: Taxonomy of generative models - TUMTaxonomy of generative models Prof. Leal-Taixé and Prof. Niessner Figure from Ian Goodfellow, Tutorial on Generative Adversarial /networks, 2017

DCGAN: Results

DCGAN: https://github.com/carpedm20/DCGAN-tensorflow

Results on MNIST

Prof. Leal-Taixé and Prof. Niessner 23

Page 24: Taxonomy of generative models - TUMTaxonomy of generative models Prof. Leal-Taixé and Prof. Niessner Figure from Ian Goodfellow, Tutorial on Generative Adversarial /networks, 2017

DCGAN: Results

Results on CelebA (200k relatively well aligned portrait photos)

DCGAN: https://github.com/carpedm20/DCGAN-tensorflow

Page 25: Taxonomy of generative models - TUMTaxonomy of generative models Prof. Leal-Taixé and Prof. Niessner Figure from Ian Goodfellow, Tutorial on Generative Adversarial /networks, 2017

DCGAN: Results

DCGAN: https://github.com/carpedm20/DCGAN-tensorflow

Asian face dataset

Prof. Leal-Taixé and Prof. Niessner 25

Page 26: Taxonomy of generative models - TUMTaxonomy of generative models Prof. Leal-Taixé and Prof. Niessner Figure from Ian Goodfellow, Tutorial on Generative Adversarial /networks, 2017

DCGAN: Results

DCGAN: https://github.com/carpedm20/DCGAN-tensorflowProf. Leal-Taixé and Prof. Niessner 26

Page 27: Taxonomy of generative models - TUMTaxonomy of generative models Prof. Leal-Taixé and Prof. Niessner Figure from Ian Goodfellow, Tutorial on Generative Adversarial /networks, 2017

DCGAN: Results

DCGAN: https://github.com/carpedm20/DCGAN-tensorflowProf. Leal-Taixé and Prof. Niessner 27

Loss of D and G on custom dataset

Page 28: Taxonomy of generative models - TUMTaxonomy of generative models Prof. Leal-Taixé and Prof. Niessner Figure from Ian Goodfellow, Tutorial on Generative Adversarial /networks, 2017

“Bad” Training Curves

Prof. Leal-Taixé and Prof. Niessner 28

https://stackoverflow.com/questions/44313306/dcgans-discriminator-getting-too-strong-too-quickly-to-allow-generator-to-learn

Page 29: Taxonomy of generative models - TUMTaxonomy of generative models Prof. Leal-Taixé and Prof. Niessner Figure from Ian Goodfellow, Tutorial on Generative Adversarial /networks, 2017

“Good” Training Curves

Prof. Leal-Taixé and Prof. Niessner 29https://medium.com/ai-society/gans-from-scratch-1-a-deep-introduction-with-code-in-pytorch-and-tensorflow-cb03cdcdba0f

Page 30: Taxonomy of generative models - TUMTaxonomy of generative models Prof. Leal-Taixé and Prof. Niessner Figure from Ian Goodfellow, Tutorial on Generative Adversarial /networks, 2017

“Good” Training Curves

Prof. Leal-Taixé and Prof. Niessner 30https://stackoverflow.com/questions/42690721/how-to-interpret-the-discriminators-loss-and-the-generators-loss-in-generative

Page 31: Taxonomy of generative models - TUMTaxonomy of generative models Prof. Leal-Taixé and Prof. Niessner Figure from Ian Goodfellow, Tutorial on Generative Adversarial /networks, 2017

Training Schedules

• Adaptive schedules

• For instance:

while loss_discriminator > t_d:

train discriminator

while loss_generator > t_g:

train generator

Prof. Leal-Taixé and Prof. Niessner 31

Page 32: Taxonomy of generative models - TUMTaxonomy of generative models Prof. Leal-Taixé and Prof. Niessner Figure from Ian Goodfellow, Tutorial on Generative Adversarial /networks, 2017

Weak vs Strong Discriminator

Need balance

• Discriminator too weak?

– No good gradients (cannot get better than teacher…)

• Generator too weak?

– Discriminator will always be right

Prof. Leal-Taixé and Prof. Niessner 32

Page 33: Taxonomy of generative models - TUMTaxonomy of generative models Prof. Leal-Taixé and Prof. Niessner Figure from Ian Goodfellow, Tutorial on Generative Adversarial /networks, 2017

Mode Collapse

• min𝐺

max𝐷

𝑉 𝐺, 𝐷 ≠ max𝐷

min𝐺

𝑉(𝐺, 𝐷)

• 𝐷 in inner loop -> convergence to correct dist.

• 𝐺 in inner loop -> easy to convergence to one sample

Prof. Leal-Taixé and Prof. Niessner 33[Metz et al. 16]

Page 34: Taxonomy of generative models - TUMTaxonomy of generative models Prof. Leal-Taixé and Prof. Niessner Figure from Ian Goodfellow, Tutorial on Generative Adversarial /networks, 2017

Mode Collapse

• Data dim. Fixed (512)

• Performance correlates with# of modes

Prof. Leal-Taixé and Prof. Niessner 34Slide credit Ming-Yu Liu

-> More modes, smaller recovery rate!-> part of the reason, why we often see GAN-results on specific domains (e.g., faces)

Page 35: Taxonomy of generative models - TUMTaxonomy of generative models Prof. Leal-Taixé and Prof. Niessner Figure from Ian Goodfellow, Tutorial on Generative Adversarial /networks, 2017

Mode Collapse

• Performancecorrelates with dim of manifold

Prof. Leal-Taixé and Prof. Niessner 35Slide credit Ming-Yu Liu

-> Larger latent space,more mode collapse

Page 36: Taxonomy of generative models - TUMTaxonomy of generative models Prof. Leal-Taixé and Prof. Niessner Figure from Ian Goodfellow, Tutorial on Generative Adversarial /networks, 2017

Problems with Global Structure

Prof. Leal-Taixé and Prof. Niessner 36

Page 37: Taxonomy of generative models - TUMTaxonomy of generative models Prof. Leal-Taixé and Prof. Niessner Figure from Ian Goodfellow, Tutorial on Generative Adversarial /networks, 2017

Problems with Counting

Prof. Leal-Taixé and Prof. Niessner 37

Page 38: Taxonomy of generative models - TUMTaxonomy of generative models Prof. Leal-Taixé and Prof. Niessner Figure from Ian Goodfellow, Tutorial on Generative Adversarial /networks, 2017

Evaluation of GAN Performance

Prof. Leal-Taixé and Prof. Niessner 38

Page 39: Taxonomy of generative models - TUMTaxonomy of generative models Prof. Leal-Taixé and Prof. Niessner Figure from Ian Goodfellow, Tutorial on Generative Adversarial /networks, 2017

Evaluation of GAN Performance

• Main difficulty of GANs: we don’t know how good they are

• People cherry pick results in papers -> some of them will always look good, but how to quantify?

• Do we only memorize or do we generalize?

• GANs are difficult to evaluate! [This et al., ICLR 2016]

Prof. Leal-Taixé and Prof. Niessner 39

Page 40: Taxonomy of generative models - TUMTaxonomy of generative models Prof. Leal-Taixé and Prof. Niessner Figure from Ian Goodfellow, Tutorial on Generative Adversarial /networks, 2017

Evaluation of GAN Performance

Human evaluation:

- Every n updates, show a series of predictions

- Check train curves

- What does ‘look good’ mean at the beginning?

- Need variety!

- But don’t have ‘realistic’ predictions yet…

- If it doesn’t look good? Go back, try different hyperparameters…

Prof. Leal-Taixé and Prof. Niessner 40

Page 41: Taxonomy of generative models - TUMTaxonomy of generative models Prof. Leal-Taixé and Prof. Niessner Figure from Ian Goodfellow, Tutorial on Generative Adversarial /networks, 2017

Evaluation of GAN Performance

Inception Score (IS)

- Measures saliency and diversity

- Train an accurate classifier

- Train a image generation model (conditional)

- Check how accurate the classifier can recognize the generated images

- Makes some assumptions about data distributions…

Prof. Leal-Taixé and Prof. Niessner 41

Page 42: Taxonomy of generative models - TUMTaxonomy of generative models Prof. Leal-Taixé and Prof. Niessner Figure from Ian Goodfellow, Tutorial on Generative Adversarial /networks, 2017

Evaluation of GAN Performance

Inception Score (IS)

- Saliency: check whether the generated images can be classified with high confidence (i.e., high scores only on a single class)

- Diversity: check whether we obtain samples from all classes

Prof. Leal-Taixé and Prof. Niessner 42

What if we only have one good image per class?

Page 43: Taxonomy of generative models - TUMTaxonomy of generative models Prof. Leal-Taixé and Prof. Niessner Figure from Ian Goodfellow, Tutorial on Generative Adversarial /networks, 2017

Evaluation of GAN Performance

• Could also look at discriminator

– If we end up with a strong discriminator, then generator must also be good

– Use D features, for classification network

– Only fine-tune last layer

– If high class accuracy -> we have a good D and G

Prof. Leal-Taixé and Prof. Niessner 43Caveat: not sure if people do this... Couldn’t find paper

Page 44: Taxonomy of generative models - TUMTaxonomy of generative models Prof. Leal-Taixé and Prof. Niessner Figure from Ian Goodfellow, Tutorial on Generative Adversarial /networks, 2017

Next: Making GANs Work in Practice

• Training / Hyperparameters (most important)

• Choice of loss function

• Choice of architecture

Prof. Leal-Taixé and Prof. Niessner 44

Page 45: Taxonomy of generative models - TUMTaxonomy of generative models Prof. Leal-Taixé and Prof. Niessner Figure from Ian Goodfellow, Tutorial on Generative Adversarial /networks, 2017

GAN Hacks: Normalize Inputs

• Normalize the inputs between -1 and 1

• Tanh as the last layer of the generator output

• No-brainer

Prof. Leal-Taixé and Prof. Niessner 45https://github.com/soumith/ganhacks

Page 46: Taxonomy of generative models - TUMTaxonomy of generative models Prof. Leal-Taixé and Prof. Niessner Figure from Ian Goodfellow, Tutorial on Generative Adversarial /networks, 2017

GAN Hacks: Sampling

• Use a spherical z

• Don’t sample from a uniform distribution

• Sample from a Gaussian Distribution

Prof. Leal-Taixé and Prof. Niessner 46

• When doing interpolations, do the

interpolation via a great circle, rather than a

straight line from point A to point B

• Tom White's Sampling Generative

Networks ref

code https://github.com/dribnet/plat

has more details

Page 47: Taxonomy of generative models - TUMTaxonomy of generative models Prof. Leal-Taixé and Prof. Niessner Figure from Ian Goodfellow, Tutorial on Generative Adversarial /networks, 2017

GAN Hacks: BatchNorm

• Use Batch Norm

• Construct different mini-batches for real and fake, i.e. each mini-batch needs to contain only all real images or all generated images.

Prof. Leal-Taixé and Prof. Niessner 47

Page 48: Taxonomy of generative models - TUMTaxonomy of generative models Prof. Leal-Taixé and Prof. Niessner Figure from Ian Goodfellow, Tutorial on Generative Adversarial /networks, 2017

GAN Hacks: Use ADAM

• See Adam usage [Radford et al. 15]

• SGD for discriminator

• ADAM for generator

Prof. Leal-Taixé and Prof. Niessner 48

Page 49: Taxonomy of generative models - TUMTaxonomy of generative models Prof. Leal-Taixé and Prof. Niessner Figure from Ian Goodfellow, Tutorial on Generative Adversarial /networks, 2017

GAN Hacks: One-sided Label Smoothing

• Prevent discriminator from giving too large gradient signal to generator:

Prof. Leal-Taixé and Prof. Niessner 49Salimans et al. 17 “Improved Techniques for Training GANs”

Some value smaller than 1; e.g.,0.9

-> reduces confidence; i.e., makes disc. ‘weaker’-> encourages ‘extreme samples’ (prevents extrapolating)

𝝀

Page 50: Taxonomy of generative models - TUMTaxonomy of generative models Prof. Leal-Taixé and Prof. Niessner Figure from Ian Goodfellow, Tutorial on Generative Adversarial /networks, 2017

GAN Hacks: Historical Generator Batches

Prof. Leal-Taixé and Prof. Niessner 50Srivastava et al. 17 “Learning from Simulated and Unsupervised Images through Adversarial Training”

Help stabilize discriminator training in early stage

Page 51: Taxonomy of generative models - TUMTaxonomy of generative models Prof. Leal-Taixé and Prof. Niessner Figure from Ian Goodfellow, Tutorial on Generative Adversarial /networks, 2017

GAN Hacks: Avoid Sparse Gradients

• Stability of GAN game suffers if gradients are sparse

• LeakyReLU -> good in both G and D

• Downsample -> use average pool, conv+stride

• Upsample -> deconv+stride, PixelShuffle

Prof. Leal-Taixé and Prof. Niessner 51[Shi et al. 16] https://arxiv.org/pdf/1609.05158.pdf

Page 52: Taxonomy of generative models - TUMTaxonomy of generative models Prof. Leal-Taixé and Prof. Niessner Figure from Ian Goodfellow, Tutorial on Generative Adversarial /networks, 2017

Exponential Averaging of Weights

• Problem: discriminator is noisy due to SGD

• Rather than taking final result of a GAN, would be biased on last latest iterations (i.e., latest training samples),

-> exponential average of weights

-> keep second ‘vector’ of weights that are averaged

-> almost no cost, average of weights from last n itersProf. Leal-Taixé and Prof. Niessner 52

Page 53: Taxonomy of generative models - TUMTaxonomy of generative models Prof. Leal-Taixé and Prof. Niessner Figure from Ian Goodfellow, Tutorial on Generative Adversarial /networks, 2017

New Objective Functions

Prof. Leal-Taixé and Prof. Niessner 53

Page 54: Taxonomy of generative models - TUMTaxonomy of generative models Prof. Leal-Taixé and Prof. Niessner Figure from Ian Goodfellow, Tutorial on Generative Adversarial /networks, 2017

New Objective Functions

“heuristic is standard…”

EBGAN: “Energy-based Generative Adversarial Networks”

BEGAN: “Boundary Equilibrium GAN”

WGAN: “Wasserstein Generative Adversarial Networks”

LSGAN: “Least Squares Generative Adversarial Networks”

….

The loss function alone will not make it suddenly work!Prof. Leal-Taixé and Prof. Niessner 54

Page 55: Taxonomy of generative models - TUMTaxonomy of generative models Prof. Leal-Taixé and Prof. Niessner Figure from Ian Goodfellow, Tutorial on Generative Adversarial /networks, 2017

GAN Losses: EBGAN

• Discriminator is AE (Energy-based GAN)

• a good autoencoder: we want the reconstruction cost D(x) for real images to be low.

• a good critic: we want to penalize the discriminator if the reconstruction error for generated images drops below a value m.

Prof. Leal-Taixé and Prof. Niessner 55https://medium.com/@jonathan_hui/gan-energy-based-gan-ebgan-boundary-equilibrium-gan-began-4662cceb7824

Page 56: Taxonomy of generative models - TUMTaxonomy of generative models Prof. Leal-Taixé and Prof. Niessner Figure from Ian Goodfellow, Tutorial on Generative Adversarial /networks, 2017

GAN Losses: BEGAN

• Similar to EBGAN

• Instead of reconstruction loss, measure difference in data distribution of real and generated images

Prof. Leal-Taixé and Prof. Niessner 56https://medium.com/@jonathan_hui/gan-energy-based-gan-ebgan-boundary-equilibrium-gan-began-4662cceb7824

Page 57: Taxonomy of generative models - TUMTaxonomy of generative models Prof. Leal-Taixé and Prof. Niessner Figure from Ian Goodfellow, Tutorial on Generative Adversarial /networks, 2017

GAN Losses: WGAN

• Earth Mover Distance / Wasserstein Distance

Prof. Leal-Taixé and Prof. Niessner 57

Minimum amount of work to move earth from p(x) to q(x)

https://medium.com/@jonathan_hui/gan-wasserstein-gan-wgan-gp-6a1a2aa1b490

Page 58: Taxonomy of generative models - TUMTaxonomy of generative models Prof. Leal-Taixé and Prof. Niessner Figure from Ian Goodfellow, Tutorial on Generative Adversarial /networks, 2017

GAN Losses: WGAN

• Formulate EMD via it’s dual:

Prof. Leal-Taixé and Prof. Niessner 58

1-Lipschitz function: upper bound between densities

https://medium.com/@jonathan_hui/gan-wasserstein-gan-wgan-gp-6a1a2aa1b490

Page 59: Taxonomy of generative models - TUMTaxonomy of generative models Prof. Leal-Taixé and Prof. Niessner Figure from Ian Goodfellow, Tutorial on Generative Adversarial /networks, 2017

GAN Losses: WGAN

Prof. Leal-Taixé and Prof. Niessner 59

f is a critic function, defined by a neural network-> f needs to be 1-Lipschitz; WGAN restricts max weight value in f; weights of the discriminator must be within a certain range controlled byhyperparameters c

https://medium.com/@jonathan_hui/gan-wasserstein-gan-wgan-gp-6a1a2aa1b490

Page 60: Taxonomy of generative models - TUMTaxonomy of generative models Prof. Leal-Taixé and Prof. Niessner Figure from Ian Goodfellow, Tutorial on Generative Adversarial /networks, 2017

GAN Losses: WGAN

Prof. Leal-Taixé and Prof. Niessner 60https://medium.com/@jonathan_hui/gan-wasserstein-gan-wgan-gp-6a1a2aa1b490

Page 61: Taxonomy of generative models - TUMTaxonomy of generative models Prof. Leal-Taixé and Prof. Niessner Figure from Ian Goodfellow, Tutorial on Generative Adversarial /networks, 2017

GAN Losses: WGAN

Prof. Leal-Taixé and Prof. Niessner 61https://medium.com/@jonathan_hui/gan-wasserstein-gan-wgan-gp-6a1a2aa1b490

Page 62: Taxonomy of generative models - TUMTaxonomy of generative models Prof. Leal-Taixé and Prof. Niessner Figure from Ian Goodfellow, Tutorial on Generative Adversarial /networks, 2017

GAN Losses: WGAN

Prof. Leal-Taixé and Prof. Niessner 62https://medium.com/@jonathan_hui/gan-wasserstein-gan-wgan-gp-6a1a2aa1b490

Page 63: Taxonomy of generative models - TUMTaxonomy of generative models Prof. Leal-Taixé and Prof. Niessner Figure from Ian Goodfellow, Tutorial on Generative Adversarial /networks, 2017

GAN Losses: WGAN

Prof. Leal-Taixé and Prof. Niessner 63https://medium.com/@jonathan_hui/gan-wasserstein-gan-wgan-gp-6a1a2aa1b490

Page 64: Taxonomy of generative models - TUMTaxonomy of generative models Prof. Leal-Taixé and Prof. Niessner Figure from Ian Goodfellow, Tutorial on Generative Adversarial /networks, 2017

GAN Losses: WGAN

Prof. Leal-Taixé and Prof. Niessner 64https://medium.com/@jonathan_hui/gan-wasserstein-gan-wgan-gp-6a1a2aa1b490

Page 65: Taxonomy of generative models - TUMTaxonomy of generative models Prof. Leal-Taixé and Prof. Niessner Figure from Ian Goodfellow, Tutorial on Generative Adversarial /networks, 2017

GAN Losses: WGAN

+ mitigates mode collapse

+ generator still learns when critic performs well

+ actual convergence

- Enforcing Lipschitz constraint is difficult

- Weight clipping is “terrible”

-> too high: takes long time to reach limit limit; slow training-> too small: vanishing gradients when layersi s big

Prof. Leal-Taixé and Prof. Niessner 65

Page 66: Taxonomy of generative models - TUMTaxonomy of generative models Prof. Leal-Taixé and Prof. Niessner Figure from Ian Goodfellow, Tutorial on Generative Adversarial /networks, 2017

GAN Losses

• Many more variations!!!

• High-level understanding: “loss” is a meta loss to train the actual loss (i.e., D) to provide gradients for G

• Always start simple: if things don’t converge, don’t randomly shuffle loss around; always try easy things first (AE, VAE, ‘simple heuristic’ GAN)

Prof. Leal-Taixé and Prof. Niessner 66

Page 67: Taxonomy of generative models - TUMTaxonomy of generative models Prof. Leal-Taixé and Prof. Niessner Figure from Ian Goodfellow, Tutorial on Generative Adversarial /networks, 2017

GAN Architectures

Prof. Leal-Taixé and Prof. Niessner 67

Page 68: Taxonomy of generative models - TUMTaxonomy of generative models Prof. Leal-Taixé and Prof. Niessner Figure from Ian Goodfellow, Tutorial on Generative Adversarial /networks, 2017

Multiscale GANs

Credit: Li/Karpathy/JohnsonProf. Leal-Taixé and Prof. Niessner 68

Page 69: Taxonomy of generative models - TUMTaxonomy of generative models Prof. Leal-Taixé and Prof. Niessner Figure from Ian Goodfellow, Tutorial on Generative Adversarial /networks, 2017

Multiscale GANs

Credit: Li/Karpathy/JohnsonProf. Leal-Taixé and Prof. Niessner 69

Page 70: Taxonomy of generative models - TUMTaxonomy of generative models Prof. Leal-Taixé and Prof. Niessner Figure from Ian Goodfellow, Tutorial on Generative Adversarial /networks, 2017

Progressive Growing GANs

https://github.com/tkarras/progressive_growing_of_gans [Karras et al. 17]

Page 71: Taxonomy of generative models - TUMTaxonomy of generative models Prof. Leal-Taixé and Prof. Niessner Figure from Ian Goodfellow, Tutorial on Generative Adversarial /networks, 2017

71

64×

64

4

G

Latent

64×

64

4

D

Real or fakeGenerated image

Page 72: Taxonomy of generative models - TUMTaxonomy of generative models Prof. Leal-Taixé and Prof. Niessner Figure from Ian Goodfellow, Tutorial on Generative Adversarial /networks, 2017

72

64×

64

4

G

Latent

64×

64

4

D

Real or fakeGenerated image

Page 73: Taxonomy of generative models - TUMTaxonomy of generative models Prof. Leal-Taixé and Prof. Niessner Figure from Ian Goodfellow, Tutorial on Generative Adversarial /networks, 2017

73

Generated image4×

4

4

10

24×

10

24

10

24×

10

24

G D

Latent Real or fake

Page 74: Taxonomy of generative models - TUMTaxonomy of generative models Prof. Leal-Taixé and Prof. Niessner Figure from Ian Goodfellow, Tutorial on Generative Adversarial /networks, 2017

74

4

4

10

24×

10

24

10

24×

10

24

G D

Latent Real or fake

There’s waves

everywhere!But

where’s

the shore?

Page 75: Taxonomy of generative models - TUMTaxonomy of generative models Prof. Leal-Taixé and Prof. Niessner Figure from Ian Goodfellow, Tutorial on Generative Adversarial /networks, 2017

75

64×

64

4

G

Latent

64×

64

4

D

Real or fake

10

24×

10

24

10

24×

10

24

There it

is!

Page 76: Taxonomy of generative models - TUMTaxonomy of generative models Prof. Leal-Taixé and Prof. Niessner Figure from Ian Goodfellow, Tutorial on Generative Adversarial /networks, 2017

76

4

G

Latent

4

D

Real or fake

Page 77: Taxonomy of generative models - TUMTaxonomy of generative models Prof. Leal-Taixé and Prof. Niessner Figure from Ian Goodfellow, Tutorial on Generative Adversarial /networks, 2017

77

4

G

Latent

4

D

Real or fake

Page 78: Taxonomy of generative models - TUMTaxonomy of generative models Prof. Leal-Taixé and Prof. Niessner Figure from Ian Goodfellow, Tutorial on Generative Adversarial /networks, 2017

78

4

G

Latent

4

D

Real or fake

8

8

Page 79: Taxonomy of generative models - TUMTaxonomy of generative models Prof. Leal-Taixé and Prof. Niessner Figure from Ian Goodfellow, Tutorial on Generative Adversarial /networks, 2017

79

4

G

Latent

4

D

Real or fake

10

24×

10

24

10

24×

10

24

Page 80: Taxonomy of generative models - TUMTaxonomy of generative models Prof. Leal-Taixé and Prof. Niessner Figure from Ian Goodfellow, Tutorial on Generative Adversarial /networks, 2017

80

2x

8×8

8×8

2x

16×16

16×16

2x

32×3232×32

4×4

4×4

G

Nearest-neighbor upsampling

3×3 convolution

Replicated block

Page 81: Taxonomy of generative models - TUMTaxonomy of generative models Prof. Leal-Taixé and Prof. Niessner Figure from Ian Goodfellow, Tutorial on Generative Adversarial /networks, 2017

81

2x

16×16

16×16

2x

32×3232×32

2x

8×8

8×8

G

toRGB

1×1 convolution

4×4

4×4

Page 82: Taxonomy of generative models - TUMTaxonomy of generative models Prof. Leal-Taixé and Prof. Niessner Figure from Ian Goodfellow, Tutorial on Generative Adversarial /networks, 2017

82

toRGB

toRGB

2x

16×16

16×16

2x

32×3232×32

4×4

4×4

G

2x

8×8

8×8

Page 83: Taxonomy of generative models - TUMTaxonomy of generative models Prof. Leal-Taixé and Prof. Niessner Figure from Ian Goodfellow, Tutorial on Generative Adversarial /networks, 2017

83

toRGB

toRGB

2x

16×16

16×16

2x

32×3232×32

4×4

4×4

G

2x

8×8

8×8+

Linear crossfade

Page 84: Taxonomy of generative models - TUMTaxonomy of generative models Prof. Leal-Taixé and Prof. Niessner Figure from Ian Goodfellow, Tutorial on Generative Adversarial /networks, 2017

84

2x

16×16

16×16

2x

32×3232×32

2x

8×8

8×8

4×4

4×432×3232×32

0.5x

16×16

16×160.5x

8×8

4×4

fromRGB

8×80.5x

4×4

G D

toRGB

Page 85: Taxonomy of generative models - TUMTaxonomy of generative models Prof. Leal-Taixé and Prof. Niessner Figure from Ian Goodfellow, Tutorial on Generative Adversarial /networks, 2017

85

Page 86: Taxonomy of generative models - TUMTaxonomy of generative models Prof. Leal-Taixé and Prof. Niessner Figure from Ian Goodfellow, Tutorial on Generative Adversarial /networks, 2017

Progressive Growing GANs

https://github.com/tkarras/progressive_growing_of_gans [Karras et al. 17]

Page 87: Taxonomy of generative models - TUMTaxonomy of generative models Prof. Leal-Taixé and Prof. Niessner Figure from Ian Goodfellow, Tutorial on Generative Adversarial /networks, 2017

Lots of GAN Variations

• Hundreds of GAN papers in the last two years

– > Mostly with different losses

– > Extremely hard to train and evaluate

Page 88: Taxonomy of generative models - TUMTaxonomy of generative models Prof. Leal-Taixé and Prof. Niessner Figure from Ian Goodfellow, Tutorial on Generative Adversarial /networks, 2017

Next lectures

• Next Monday 17th, more on Generative models

– Conditional GANs (cGANs)!

• We are still working on feedback for presentations –will send around asap.

• Keep working on the projects!

Prof. Leal-Taixé and Prof. Niessner 88