generative adversarial networks...generative adversarial nets. neurips. longer version goodfellow,...

26
Generative adversarial networks Hakan Bilen Machine Learning Practical - MLP Lecture 13 23 January 2019 http://www.inf.ed.ac.uk/teaching/courses/mlp/ Slide credits: Ian Goodfellow

Upload: others

Post on 17-Jun-2020

22 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Generative adversarial networks...Generative adversarial nets. NeurIPS. Longer version Goodfellow, (2016). NIPS 2016 Tutorial: Generative Adversarial Networks. Extra Radford et al,

Generative adversarial networks

Hakan Bilen

Machine Learning Practical - MLP Lecture 1323 January 2019

http://www.inf.ed.ac.uk/teaching/courses/mlp/

Slide credits: Ian Goodfellow

Page 2: Generative adversarial networks...Generative adversarial nets. NeurIPS. Longer version Goodfellow, (2016). NIPS 2016 Tutorial: Generative Adversarial Networks. Extra Radford et al,

Generative modeling

โ— Density estimation

โ— Sample generation

2

Page 3: Generative adversarial networks...Generative adversarial nets. NeurIPS. Longer version Goodfellow, (2016). NIPS 2016 Tutorial: Generative Adversarial Networks. Extra Radford et al,

Why are generative models useful?

โ— Test of our intellectual ability to use high dimensional probability distributions

โ— Learn from simulated data and transfer it to real world

โ— Complete missing data (including multi-modal)

โ— Realistic generation tasks (image and speech)

3

Page 4: Generative adversarial networks...Generative adversarial nets. NeurIPS. Longer version Goodfellow, (2016). NIPS 2016 Tutorial: Generative Adversarial Networks. Extra Radford et al,

Next video frame prediction

Lotter et al 2016

4Lotter et al. Deep Predictive Coding Networks for Video Prediction and Unsupervised Learning, ICLRโ€™17

Page 5: Generative adversarial networks...Generative adversarial nets. NeurIPS. Longer version Goodfellow, (2016). NIPS 2016 Tutorial: Generative Adversarial Networks. Extra Radford et al,

Photo-realistic super-resolution

5Ledig et al. Photo-Realistic Single Image Super-Resolution Using a Generative Adversarial Network, CVPRโ€™17

Page 6: Generative adversarial networks...Generative adversarial nets. NeurIPS. Longer version Goodfellow, (2016). NIPS 2016 Tutorial: Generative Adversarial Networks. Extra Radford et al,

Image-to-image translation

6Isola et al. Image-to-Image Translation with Conditional Adversarial Nets, CVPRโ€™17

Page 7: Generative adversarial networks...Generative adversarial nets. NeurIPS. Longer version Goodfellow, (2016). NIPS 2016 Tutorial: Generative Adversarial Networks. Extra Radford et al,

Maximum likelihood

Assume that all generative models maximise the likelihood of the training data

โ— ๐‘ฅ: inputโ— ๐‘๐‘‘๐‘Ž๐‘ก๐‘Ž : probability density function

of input samplesโ— ๐‘๐‘š๐‘œ๐‘‘๐‘’๐‘™: estimate probability

function, parameterised by ๐œƒ

7

Page 8: Generative adversarial networks...Generative adversarial nets. NeurIPS. Longer version Goodfellow, (2016). NIPS 2016 Tutorial: Generative Adversarial Networks. Extra Radford et al,

Taxonomy of generative methods

8

Page 9: Generative adversarial networks...Generative adversarial nets. NeurIPS. Longer version Goodfellow, (2016). NIPS 2016 Tutorial: Generative Adversarial Networks. Extra Radford et al,

Generative adversarial networks

10

generator ๐บ(โ‹…; ๐œƒ๐บ)

(counterfeiter)

noise

real samples ยฃdiscriminator ๐ท(โ‹…; ๐œƒ๐ท)(police) 0

1

real

fake

๐บ(๐‘ง; ๐œƒ๐บ)

๐‘ฅ

๐‘ง โ€ข ๐ท tries to make ๐ท(๐‘ฅ) near 1 and ๐ท(๐บ ๐‘ง) near 0

โ€ข ๐บ tries to make ๐ท(๐บ ๐‘ง) near 1

Page 10: Generative adversarial networks...Generative adversarial nets. NeurIPS. Longer version Goodfellow, (2016). NIPS 2016 Tutorial: Generative Adversarial Networks. Extra Radford et al,

Minimax game

๐‘‰ ๐œƒ๐บ , ๐œƒ๐ท =1

2๐”ผ๐‘ฅ~๐‘๐‘‘๐‘Ž๐‘ก๐‘Ž๐‘™๐‘œ๐‘”๐ท ๐‘ฅ; ๐œƒ๐ท +

1

2๐”ผ๐‘ง~๐‘๐‘ง log 1 โˆ’ ๐ท ๐บ ๐‘ง; ๐œƒ๐บ

โ— min๐œƒ๐บ

m๐‘Ž๐‘ฅ๐œƒ๐ท

V ๐œƒ๐บ , ๐œƒ๐ท

โ— ๐ท wishes to maximise V(๐œƒ๐บ , ๐œƒ๐ท) and controls ๐œƒ๐ท

โ— ๐บ wishes to minimise V(๐œƒ๐บ , ๐œƒ๐ท) and controls ๐œƒ๐บ

โ— Solution to optimization at local minimum

โ— Game of two players with a solution at Nash equilibrium

11

Page 11: Generative adversarial networks...Generative adversarial nets. NeurIPS. Longer version Goodfellow, (2016). NIPS 2016 Tutorial: Generative Adversarial Networks. Extra Radford et al,

Non-saturating game

๐ฝ๐ท = โˆ’1

2๐”ผ๐‘ฅ~๐‘๐‘‘๐‘Ž๐‘ก๐‘Ž๐‘™๐‘œ๐‘”๐ท ๐‘ฅ; ๐œƒ๐ท โˆ’

1

2๐”ผ๐‘ง~๐‘๐‘ง log 1 โˆ’ ๐ท ๐บ ๐‘ง;๐œƒ๐บ

๐ฝ๐บ =1

2๐”ผ๐‘ง~๐‘๐‘ง log 1 โˆ’ ๐ท ๐บ ๐‘ง;๐œƒ๐บ

โ— Problem: when ๐ท successfully rejects generator samples, generatorโ€™s gradient vanishes

โ— Solution:

๐ฝ๐บ = โˆ’1

2๐”ผ๐‘ง~๐‘๐‘ง log ๐ท ๐บ ๐‘ง; ๐œƒ๐บ

12

Page 12: Generative adversarial networks...Generative adversarial nets. NeurIPS. Longer version Goodfellow, (2016). NIPS 2016 Tutorial: Generative Adversarial Networks. Extra Radford et al,

Training GANs

13

generator ๐บ(โ‹…; ๐œƒ๐บ)

noise

real samples ยฃdiscriminator ๐ท(โ‹…; ๐œƒ๐ท)

๐บ(๐‘ง; ๐œƒ๐บ)

๐‘ฅ

๐‘ง

๐œ•๐ฝ๐ท

๐œ•๐ท

๐œ•๐ฝ๐บ

๐œ•๐ท

๐œ•๐ฝ๐บ

๐œ•๐ท

๐œ•๐ท

๐œ•๐บ ๐ฝ๐บ = โˆ’1

2๐”ผ๐‘ง~๐‘๐‘ง log ๐ท ๐บ ๐‘ง; ๐œƒ๐บ

๐œ•๐ฝ๐ท

๐œ•๐ท

๐œ•๐ท

๐œ•๐œƒ๐ท

๐œ•๐ฝ๐บ

๐œ•๐ท

๐œ•๐ท

๐œ•๐บ

๐œ•๐บ

๐œ•๐œƒ๐บ

๐œ•๐ฝ๐บ

๐œ•๐ท

๐ฝ๐ท

๐ฝ๐บ

๐ฝ๐ท = โˆ’1

2๐”ผ๐‘ฅ~๐‘๐‘‘๐‘Ž๐‘ก๐‘Ž๐‘™๐‘œ๐‘”๐ท ๐‘ฅ; ๐œƒ๐ท โˆ’

1

2๐”ผ๐‘ง~๐‘๐‘ง log 1โˆ’ ๐ท ๐บ ๐‘ง; ๐œƒ๐บ

Page 13: Generative adversarial networks...Generative adversarial nets. NeurIPS. Longer version Goodfellow, (2016). NIPS 2016 Tutorial: Generative Adversarial Networks. Extra Radford et al,

Transpose convolution

Stride=1

Review: Transposed convolution (deconv)

Convolution

Stride=1

14Dumoulin and Vision (2016), A guide to convolution arithmetic for deep learning, arXiv

Page 14: Generative adversarial networks...Generative adversarial nets. NeurIPS. Longer version Goodfellow, (2016). NIPS 2016 Tutorial: Generative Adversarial Networks. Extra Radford et al,

Transpose convolution

Stride=2

Review: Transposed convolution (deconv)

Convolution

Stride=2

15Dumoulin and Vision (2016), A guide to convolution arithmetic for deep learning, arXiv

Page 15: Generative adversarial networks...Generative adversarial nets. NeurIPS. Longer version Goodfellow, (2016). NIPS 2016 Tutorial: Generative Adversarial Networks. Extra Radford et al,

DCGAN (generator) architecture

โ— Deconv weights are learned (unlike Zeiler & Fergus, see lecture 12)โ— Deconvs are batch normalizedโ— No fully connected layerโ— Adam optimiser

16Radford et al, (2015). Unsupervised representation learning with deep convolutional generative adversarial networks.

Page 16: Generative adversarial networks...Generative adversarial nets. NeurIPS. Longer version Goodfellow, (2016). NIPS 2016 Tutorial: Generative Adversarial Networks. Extra Radford et al,

DCGAN for LSUN bedrooms

High quality images on restricted domain

17Radford et al (2015). Unsupervised representation learning with deep convolutional generative adversarial networks.

Page 17: Generative adversarial networks...Generative adversarial nets. NeurIPS. Longer version Goodfellow, (2016). NIPS 2016 Tutorial: Generative Adversarial Networks. Extra Radford et al,

Vector arithmetic on face samples

Semantically meaningful latent space

18Radford et al (2015). Unsupervised representation learning with deep convolutional generative adversarial networks.

Page 18: Generative adversarial networks...Generative adversarial nets. NeurIPS. Longer version Goodfellow, (2016). NIPS 2016 Tutorial: Generative Adversarial Networks. Extra Radford et al,

Problems with counting and global structure

19Salimans et al, S. (2016). Improved Techniques for Training GANs. NeurIPS.

Page 19: Generative adversarial networks...Generative adversarial nets. NeurIPS. Longer version Goodfellow, (2016). NIPS 2016 Tutorial: Generative Adversarial Networks. Extra Radford et al,

Mode collapse

- Another failure mode is for the generator to collapse to a single mode- If the generator learns to render only one realistic object, this can be

enough to fool the discriminator

20Salimans et al, S. (2016). Improved Techniques for Training GANs. NeurIPS.

Page 20: Generative adversarial networks...Generative adversarial nets. NeurIPS. Longer version Goodfellow, (2016). NIPS 2016 Tutorial: Generative Adversarial Networks. Extra Radford et al,

Measuring GAN performance

Ask humans to distinguish between generated data and real dataโ— Subjective, requires training to spot flaws

Automating the evaluation (Inception score):1. Image quality: images should contain meaningful objects (few dominant objects)

- Feed images to Inception Net to obtain conditional label distribution ๐‘ ๐‘ฆ ๐‘ฅ- For each generated image, entropy over classes ฯƒ๐‘ฆ ๐‘ ๐‘ฆ ๐‘ฅ ๐‘™๐‘œ๐‘” ๐‘ ๐‘ฆ ๐‘ฅ should be low

2. Diversity: the model should generate varied images (balanced over classes)- Entropy over generated images ๐‘ ๐‘ฆ ๐‘ฅ = ๐บ ๐‘ง ๐‘‘๐‘ง should be high

โ— Combining two requirements (โ€œhow different is the score distribution for a generated image from the overall class balance?โ€)

๐ธ๐‘ฅ๐พ๐ฟ(๐‘(๐‘ฆ|๐‘ฅ)||๐‘(๐‘ฆ))

21Salimans et al, S. (2016). Improved Techniques for Training GANs. NeurIPS.

Page 21: Generative adversarial networks...Generative adversarial nets. NeurIPS. Longer version Goodfellow, (2016). NIPS 2016 Tutorial: Generative Adversarial Networks. Extra Radford et al,

Class-conditional GANs

โ— Add class information in latent code ๐‘งโ— It is not unsupervised anymore

22Mirza and Osindero (2014). Conditional Generative Adversarial Nets. arXiv.

generator ๐บ(โ‹…; ๐œƒ๐บ)

noise

0

1

0

One-hot class label

Page 22: Generative adversarial networks...Generative adversarial nets. NeurIPS. Longer version Goodfellow, (2016). NIPS 2016 Tutorial: Generative Adversarial Networks. Extra Radford et al,

Spectral normalization

โ— GAN training can be unstableโ— Culprit: Gradient updates for G are

unboundedโ— Observation: First layer weights of G

are ill-behaved when the training is unstable

โ— Solution: Apply spectral norm

โ— Spectral norm is the square root of the maximum eigenvalue of ๐‘Š๐‘‡๐‘Š

โ—‹ ๐œŽ ๐‘Š = ๐‘š๐‘Ž๐‘ฅ๐‘Šโ„Ž 2

โ„Ž 2โ†’ ๐‘Š/๐œŽ(๐‘Š)

23Miyato et al. (2018). Spectral Normalization for GANs. ICLR.

Baseline

Page 23: Generative adversarial networks...Generative adversarial nets. NeurIPS. Longer version Goodfellow, (2016). NIPS 2016 Tutorial: Generative Adversarial Networks. Extra Radford et al,

Scaling up GANs

Brock et al show thatโ— bigger batch sizesโ— more number of filter channels

(~50% more)โ— larger dataset (292 million

images with 8.5k images, 512 TPU cores!)

improves state-of-the-art around 35% in Inception Score

24Brock et al. (2019). Large Scale GAN Training for High Fidelity Natural Image Synthesis. ICLR.

Page 24: Generative adversarial networks...Generative adversarial nets. NeurIPS. Longer version Goodfellow, (2016). NIPS 2016 Tutorial: Generative Adversarial Networks. Extra Radford et al,

2014 to 2019

25Brock et al. (2019).

Goodfellow et al. (2014).

Page 25: Generative adversarial networks...Generative adversarial nets. NeurIPS. Longer version Goodfellow, (2016). NIPS 2016 Tutorial: Generative Adversarial Networks. Extra Radford et al,

Summary

โ€ข Generative models

โ€ข Training GANs

โ€ข DCGAN Architecture

โ€ข (Open) challenges

โ€ข Improvements

26

Page 26: Generative adversarial networks...Generative adversarial nets. NeurIPS. Longer version Goodfellow, (2016). NIPS 2016 Tutorial: Generative Adversarial Networks. Extra Radford et al,

Reading material

Recommendedโ— Goodfellow et al, (2014). Generative adversarial nets. NeurIPS. โ— Longer version Goodfellow, (2016). NIPS 2016 Tutorial: Generative Adversarial Networks.

Extraโ— Radford et al, S. (2015). Unsupervised representation learning with deep convolutional

generative adversarial networks. โ— Salimans et al, S. (2016). Improved Techniques for Training GANs. NeurIPS.โ— Miyato et al. (2018). Spectral Normalization for GANs. ICLR.โ— Brock et al. (2019). Large Scale GAN Training for High Fidelity Natural Image Synthesis. ICLR.

27