practice: vae and gan - deep generative models

37
Practice: VAE and GAN Hao Dong Peking University 1

Upload: others

Post on 14-May-2022

3 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Practice: VAE and GAN - Deep Generative Models

Practice: VAE and GANHao Dong

Peking University

1

Page 2: Practice: VAE and GAN - Deep Generative Models

2

Practice: VAE + GAN

ā€¢ Hello World: MNIST Classification

ā€¢ Introduction of VAEā€¢ VAE Architectureā€¢ VAE Trainingā€¢ VAE Interpolationā€¢ Sampling

ā€¢ Introduction of DCGANā€¢ DCGAN Architectureā€¢ DCGAN Trainingā€¢ DCGAN Interpolation

Page 3: Practice: VAE and GAN - Deep Generative Models

3

ā€¢ Hello World: MNIST Classification

ā€¢ Introduction of VAEā€¢ VAE Architectureā€¢ VAE Trainingā€¢ VAE Interpolationā€¢ Sampling

ā€¢ Introduction of DCGANā€¢ DCGAN Architectureā€¢ DCGAN Trainingā€¢ DCGAN Interpolation

Page 4: Practice: VAE and GAN - Deep Generative Models

4

Hello World: MNIST Classification

28x28x1 = 784 binary values/image

28

28

MNIST dataset

ā€¢ Image X is a list of row vectors:>>> X_train, y_train, X_val, y_val, X_test, y_test = tl.files.load_mnist_dataset(shape=(-1, 784))>>> print(X_train.shape)ā€¦ (50000, 784)

ā€¢ Image X is a list of images:>>> X_train, y_train, X_val, y_val, X_test, y_test = tl.files.load_mnist_dataset(shape=(-1, 28, 28, 1))>>> print(X_train.shape)ā€¦ (50000, 28, 28, 1)

If RGB image, we will have 3 channels

(height, width, channels)

Page 5: Practice: VAE and GAN - Deep Generative Models

5

Hello World: MNIST Classification

ā€¢ Simple Iteration

Page 6: Practice: VAE and GAN - Deep Generative Models

6

Hello World: MNIST Classification

ā€¢ Dataset API

Page 7: Practice: VAE and GAN - Deep Generative Models

7

ā€¢ Hello World: MNIST Classification

ā€¢ Introduction of VAEā€¢ VAE Architectureā€¢ VAE Trainingā€¢ VAE Interpolationā€¢ Sampling

ā€¢ Introduction of DCGANā€¢ DCGAN Architectureā€¢ DCGAN Trainingā€¢ DCGAN Interpolation

Page 8: Practice: VAE and GAN - Deep Generative Models

8

Introduction of VAE

!š‘æ!š’X

L2

KLD

ā€¢ Two network architectures

ā€¢ Two loss functions

ā€¢ Reparameterization trick

Page 9: Practice: VAE and GAN - Deep Generative Models

9

ā€¢ Hello World: MNIST Classification

ā€¢ Introduction of VAEā€¢ VAE Architectureā€¢ VAE Trainingā€¢ VAE Interpolationā€¢ Sampling

ā€¢ Introduction of DCGANā€¢ DCGAN Architectureā€¢ DCGAN Trainingā€¢ DCGAN Interpolation

Page 10: Practice: VAE and GAN - Deep Generative Models

10

VAE Architecture

!š‘æ!š’X

L2

KLD

28

28

28x28x1 or 784

š‘„~š‘š‘‘š‘Žš‘”š‘Ž

Page 11: Practice: VAE and GAN - Deep Generative Models

11

VAE Architecture

!š‘æ!š’X

L2

KLD

ā€¢ Architecture of Encoder

Page 12: Practice: VAE and GAN - Deep Generative Models

12

VAE Architecture

!š‘æ!š’X

L2

KLD

ā€¢ Architecture of Decoder/Generator

Page 13: Practice: VAE and GAN - Deep Generative Models

13

ā€¢ Hello World: MNIST Classification

ā€¢ Introduction of VAEā€¢ VAE Architectureā€¢ VAE Trainingā€¢ VAE Interpolationā€¢ Sampling

ā€¢ Introduction of DCGANā€¢ DCGAN Architectureā€¢ DCGAN Trainingā€¢ DCGAN Interpolation

Page 14: Practice: VAE and GAN - Deep Generative Models

14

VAE Training

!š‘æ!š’X

L2

KLD

Reconstruction Loss

Page 15: Practice: VAE and GAN - Deep Generative Models

15

VAE Training

!š‘æ!š’X

L2

KLD

KL-Divergence loss

Page 16: Practice: VAE and GAN - Deep Generative Models

16

VAE Training

!š‘æ!š’X

L2

KLD

Training Pipeline

Page 17: Practice: VAE and GAN - Deep Generative Models

17

ā€¢ Hello World: MNIST Classification

ā€¢ Introduction of VAEā€¢ VAE Architectureā€¢ VAE Trainingā€¢ VAE Interpolationā€¢ Sampling

ā€¢ Introduction of DCGANā€¢ DCGAN Architectureā€¢ DCGAN Trainingā€¢ DCGAN Interpolation

Page 18: Practice: VAE and GAN - Deep Generative Models

18

VAE Interpolation

Page 19: Practice: VAE and GAN - Deep Generative Models

19

ā€¢ Hello World: MNIST Classification

ā€¢ Introduction of VAEā€¢ VAE Architectureā€¢ VAE Trainingā€¢ VAE Interpolationā€¢ Sampling

ā€¢ Introduction of DCGANā€¢ DCGAN Architectureā€¢ DCGAN Trainingā€¢ DCGAN Interpolation

Page 20: Practice: VAE and GAN - Deep Generative Models

20

Sampling

!š‘æZ

Page 21: Practice: VAE and GAN - Deep Generative Models

21

ā€¢ Hello World: MNIST Classification

ā€¢ Introduction of VAEā€¢ VAE Architectureā€¢ VAE Trainingā€¢ VAE Interpolationā€¢ Sampling

ā€¢ Introduction of DCGANā€¢ DCGAN Architectureā€¢ DCGAN Trainingā€¢ DCGAN Interpolation

Page 22: Practice: VAE and GAN - Deep Generative Models

22

Introduction of DCGAN

ā€¢ Two network architectures

ā€¢ Two loss functions!š‘æ

X

real

fakeZ

Page 23: Practice: VAE and GAN - Deep Generative Models

23

ā€¢ Hello World: MNIST Classification

ā€¢ Introduction of VAEā€¢ VAE Architectureā€¢ VAE Trainingā€¢ VAE Interpolationā€¢ Sampling

ā€¢ Introduction of DCGANā€¢ DCGAN Architectureā€¢ DCGAN Trainingā€¢ DCGAN Interpolation

Page 24: Practice: VAE and GAN - Deep Generative Models

24

DCGAN Architecture

!š‘æ

X

real

fakeZ

28

28

28x28x1 or 784

š‘§~š‘(0,1)

š‘„~š‘š‘‘š‘Žš‘”š‘Ž

Page 25: Practice: VAE and GAN - Deep Generative Models

25

DCGAN Architecture

!š‘æ

X

real

fakeZ

Architecture of generator

Page 26: Practice: VAE and GAN - Deep Generative Models

26

DCGAN Architecture

!š‘æ

X

real

fakeZ

Architecture of discriminator

Page 27: Practice: VAE and GAN - Deep Generative Models

27

ā€¢ Hello World: MNIST Classification

ā€¢ Introduction of VAEā€¢ VAE Architectureā€¢ VAE Trainingā€¢ VAE Interpolationā€¢ Sampling

ā€¢ Introduction of DCGANā€¢ DCGAN Architectureā€¢ DCGAN Trainingā€¢ DCGAN Interpolation

Page 28: Practice: VAE and GAN - Deep Generative Models

28

DCGAN Training

!š‘æ

X

fake

realZ

Loss of discriminator

Page 29: Practice: VAE and GAN - Deep Generative Models

29

DCGAN Training

!š‘æ realZ

Loss of generator

Page 30: Practice: VAE and GAN - Deep Generative Models

30

DCGAN Training

Training pipeline

!š‘æ

X

real

fakeZ

Page 31: Practice: VAE and GAN - Deep Generative Models

31

ā€¢ Hello World: MNIST Classification

ā€¢ Introduction of VAEā€¢ VAE Architectureā€¢ VAE Trainingā€¢ VAE Interpolationā€¢ Sampling

ā€¢ Introduction of DCGANā€¢ DCGAN Architectureā€¢ DCGAN Trainingā€¢ DCGAN Interpolation

Page 32: Practice: VAE and GAN - Deep Generative Models

32

DCGAN Interpolation

!š‘æ

Z1

Z2

(1-a) Z1+a Z2

Page 33: Practice: VAE and GAN - Deep Generative Models

33

More

Page 34: Practice: VAE and GAN - Deep Generative Models

34

Improved GANLSGANWGAN

WGAN-GPBiGAN

VAE-GANā€¦

with MNIST

Page 35: Practice: VAE and GAN - Deep Generative Models

35

Pix2PixCycleGAN

SRGANā€¦

with other datasets

Page 36: Practice: VAE and GAN - Deep Generative Models

36

Proposal Your Projects

Page 37: Practice: VAE and GAN - Deep Generative Models

Thanks

37