Practice: VAE and GAN - Deep Generative Models
Transcript of Practice: VAE and GAN - Deep Generative Models
![Page 1: Practice: VAE and GAN - Deep Generative Models](https://reader034.fdocuments.in/reader034/viewer/2022051600/627f944bc00c4803562b5b00/html5/thumbnails/1.jpg)
Practice: VAE and GANHao Dong
Peking University
1
![Page 2: Practice: VAE and GAN - Deep Generative Models](https://reader034.fdocuments.in/reader034/viewer/2022051600/627f944bc00c4803562b5b00/html5/thumbnails/2.jpg)
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](https://reader034.fdocuments.in/reader034/viewer/2022051600/627f944bc00c4803562b5b00/html5/thumbnails/3.jpg)
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](https://reader034.fdocuments.in/reader034/viewer/2022051600/627f944bc00c4803562b5b00/html5/thumbnails/4.jpg)
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](https://reader034.fdocuments.in/reader034/viewer/2022051600/627f944bc00c4803562b5b00/html5/thumbnails/5.jpg)
5
Hello World: MNIST Classification
• Simple Iteration
![Page 6: Practice: VAE and GAN - Deep Generative Models](https://reader034.fdocuments.in/reader034/viewer/2022051600/627f944bc00c4803562b5b00/html5/thumbnails/6.jpg)
6
Hello World: MNIST Classification
• Dataset API
![Page 7: Practice: VAE and GAN - Deep Generative Models](https://reader034.fdocuments.in/reader034/viewer/2022051600/627f944bc00c4803562b5b00/html5/thumbnails/7.jpg)
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](https://reader034.fdocuments.in/reader034/viewer/2022051600/627f944bc00c4803562b5b00/html5/thumbnails/8.jpg)
8
Introduction of VAE
!𝑿!𝒁X
L2
KLD
• Two network architectures
• Two loss functions
• Reparameterization trick
![Page 9: Practice: VAE and GAN - Deep Generative Models](https://reader034.fdocuments.in/reader034/viewer/2022051600/627f944bc00c4803562b5b00/html5/thumbnails/9.jpg)
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](https://reader034.fdocuments.in/reader034/viewer/2022051600/627f944bc00c4803562b5b00/html5/thumbnails/10.jpg)
10
VAE Architecture
!𝑿!𝒁X
L2
KLD
28
28
28x28x1 or 784
𝑥~𝑝𝑑𝑎𝑡𝑎
![Page 11: Practice: VAE and GAN - Deep Generative Models](https://reader034.fdocuments.in/reader034/viewer/2022051600/627f944bc00c4803562b5b00/html5/thumbnails/11.jpg)
11
VAE Architecture
!𝑿!𝒁X
L2
KLD
• Architecture of Encoder
![Page 12: Practice: VAE and GAN - Deep Generative Models](https://reader034.fdocuments.in/reader034/viewer/2022051600/627f944bc00c4803562b5b00/html5/thumbnails/12.jpg)
12
VAE Architecture
!𝑿!𝒁X
L2
KLD
• Architecture of Decoder/Generator
![Page 13: Practice: VAE and GAN - Deep Generative Models](https://reader034.fdocuments.in/reader034/viewer/2022051600/627f944bc00c4803562b5b00/html5/thumbnails/13.jpg)
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](https://reader034.fdocuments.in/reader034/viewer/2022051600/627f944bc00c4803562b5b00/html5/thumbnails/14.jpg)
14
VAE Training
!𝑿!𝒁X
L2
KLD
Reconstruction Loss
![Page 15: Practice: VAE and GAN - Deep Generative Models](https://reader034.fdocuments.in/reader034/viewer/2022051600/627f944bc00c4803562b5b00/html5/thumbnails/15.jpg)
15
VAE Training
!𝑿!𝒁X
L2
KLD
KL-Divergence loss
![Page 16: Practice: VAE and GAN - Deep Generative Models](https://reader034.fdocuments.in/reader034/viewer/2022051600/627f944bc00c4803562b5b00/html5/thumbnails/16.jpg)
16
VAE Training
!𝑿!𝒁X
L2
KLD
Training Pipeline
![Page 17: Practice: VAE and GAN - Deep Generative Models](https://reader034.fdocuments.in/reader034/viewer/2022051600/627f944bc00c4803562b5b00/html5/thumbnails/17.jpg)
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](https://reader034.fdocuments.in/reader034/viewer/2022051600/627f944bc00c4803562b5b00/html5/thumbnails/18.jpg)
18
VAE Interpolation
![Page 19: Practice: VAE and GAN - Deep Generative Models](https://reader034.fdocuments.in/reader034/viewer/2022051600/627f944bc00c4803562b5b00/html5/thumbnails/19.jpg)
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](https://reader034.fdocuments.in/reader034/viewer/2022051600/627f944bc00c4803562b5b00/html5/thumbnails/20.jpg)
20
Sampling
!𝑿Z
![Page 21: Practice: VAE and GAN - Deep Generative Models](https://reader034.fdocuments.in/reader034/viewer/2022051600/627f944bc00c4803562b5b00/html5/thumbnails/21.jpg)
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](https://reader034.fdocuments.in/reader034/viewer/2022051600/627f944bc00c4803562b5b00/html5/thumbnails/22.jpg)
22
Introduction of DCGAN
• Two network architectures
• Two loss functions!𝑿
X
real
fakeZ
![Page 23: Practice: VAE and GAN - Deep Generative Models](https://reader034.fdocuments.in/reader034/viewer/2022051600/627f944bc00c4803562b5b00/html5/thumbnails/23.jpg)
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](https://reader034.fdocuments.in/reader034/viewer/2022051600/627f944bc00c4803562b5b00/html5/thumbnails/24.jpg)
24
DCGAN Architecture
!𝑿
X
real
fakeZ
28
28
28x28x1 or 784
𝑧~𝑁(0,1)
𝑥~𝑝𝑑𝑎𝑡𝑎
![Page 25: Practice: VAE and GAN - Deep Generative Models](https://reader034.fdocuments.in/reader034/viewer/2022051600/627f944bc00c4803562b5b00/html5/thumbnails/25.jpg)
25
DCGAN Architecture
!𝑿
X
real
fakeZ
Architecture of generator
![Page 26: Practice: VAE and GAN - Deep Generative Models](https://reader034.fdocuments.in/reader034/viewer/2022051600/627f944bc00c4803562b5b00/html5/thumbnails/26.jpg)
26
DCGAN Architecture
!𝑿
X
real
fakeZ
Architecture of discriminator
![Page 27: Practice: VAE and GAN - Deep Generative Models](https://reader034.fdocuments.in/reader034/viewer/2022051600/627f944bc00c4803562b5b00/html5/thumbnails/27.jpg)
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](https://reader034.fdocuments.in/reader034/viewer/2022051600/627f944bc00c4803562b5b00/html5/thumbnails/28.jpg)
28
DCGAN Training
!𝑿
X
fake
realZ
Loss of discriminator
![Page 29: Practice: VAE and GAN - Deep Generative Models](https://reader034.fdocuments.in/reader034/viewer/2022051600/627f944bc00c4803562b5b00/html5/thumbnails/29.jpg)
29
DCGAN Training
!𝑿 realZ
Loss of generator
![Page 30: Practice: VAE and GAN - Deep Generative Models](https://reader034.fdocuments.in/reader034/viewer/2022051600/627f944bc00c4803562b5b00/html5/thumbnails/30.jpg)
30
DCGAN Training
Training pipeline
!𝑿
X
real
fakeZ
![Page 31: Practice: VAE and GAN - Deep Generative Models](https://reader034.fdocuments.in/reader034/viewer/2022051600/627f944bc00c4803562b5b00/html5/thumbnails/31.jpg)
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](https://reader034.fdocuments.in/reader034/viewer/2022051600/627f944bc00c4803562b5b00/html5/thumbnails/32.jpg)
32
DCGAN Interpolation
!𝑿
Z1
Z2
(1-a) Z1+a Z2
![Page 33: Practice: VAE and GAN - Deep Generative Models](https://reader034.fdocuments.in/reader034/viewer/2022051600/627f944bc00c4803562b5b00/html5/thumbnails/33.jpg)
33
More
![Page 34: Practice: VAE and GAN - Deep Generative Models](https://reader034.fdocuments.in/reader034/viewer/2022051600/627f944bc00c4803562b5b00/html5/thumbnails/34.jpg)
34
Improved GANLSGANWGAN
WGAN-GPBiGAN
VAE-GAN…
with MNIST
![Page 35: Practice: VAE and GAN - Deep Generative Models](https://reader034.fdocuments.in/reader034/viewer/2022051600/627f944bc00c4803562b5b00/html5/thumbnails/35.jpg)
35
Pix2PixCycleGAN
SRGAN…
with other datasets
![Page 36: Practice: VAE and GAN - Deep Generative Models](https://reader034.fdocuments.in/reader034/viewer/2022051600/627f944bc00c4803562b5b00/html5/thumbnails/36.jpg)
36
Proposal Your Projects
![Page 37: Practice: VAE and GAN - Deep Generative Models](https://reader034.fdocuments.in/reader034/viewer/2022051600/627f944bc00c4803562b5b00/html5/thumbnails/37.jpg)
Thanks
37