1 of 70

Generative Adversarial Networks (GAN)

Prof. Seungchul Lee

Industrial AI Lab.

2 of 70

Supervised Learning

  • Discriminative model

2

https://www.slideshare.net/NaverEngineering/1-gangenerative-adversarial-network

3 of 70

Unsupervised Learning

  • Generative model

3

https://www.slideshare.net/NaverEngineering/1-gangenerative-adversarial-network

= Latent space

4 of 70

Model Distribution vs. Data Distribution

4

5 of 70

Probability Distribution

5

https://www.slideshare.net/NaverEngineering/1-gangenerative-adversarial-network

6 of 70

Probability Distribution

6

https://www.slideshare.net/NaverEngineering/1-gangenerative-adversarial-network

7 of 70

Probability Density Estimation Problem

  •  

7

https://www.slideshare.net/NaverEngineering/1-gangenerative-adversarial-network

8 of 70

Deterministic Transformation (by Network)

  • 1-dimensional example:

  • Remember
    • Network does not generate distribution, but
    • It maps known distribution to target distribution

8

Source: Prof. Roger Grosse at U of Toronto

9 of 70

Generative Models from Lower Dimension

  •  

9

Latent space =

Source: Prof. Roger Grosse at U of Toronto

10 of 70

Turing Test

  • One way to judge the quality of the model is to sample from it.
  • GANs are based on a very different idea:
    • Model to produce samples which are indistinguishable from the real data, as judged by a discriminator network whose job is to tell real from fake

10

11 of 70

Deterministic Transformation (by Network)

  • High dimensional example:

11

Source: Prof. Roger Grosse at U of Toronto

12 of 70

Generative Adversarial Networks (GAN)

  • The idea behind Generative Adversarial Networks (GANs): train two different networks
    • Generator network: try to produce realistic-looking samples
    • Discriminator network: try to distinguish between real and fake data

  • The generator network tries to fool the discriminator network

12

13 of 70

Autoencoder

  • Dimension reduction
  • Recover the input data
    • Learns an encoding of the inputs so as to recover the original input from the encodings as well as possible

13

14 of 70

Generative Adversarial Networks (GAN)

  • Analogous to Turing Test

14

Generated

Generator

Data Generator

15 of 70

Generative Adversarial Networks (GAN)

  • Analogous to Turing Test

15

Generated

Real

Real

Fake

Generator

Discriminator

16 of 70

Intuition for GAN

16

https://www.slideshare.net/NaverEngineering/1-gangenerative-adversarial-network

17 of 70

Discriminator Perspective (1/2)

17

https://www.slideshare.net/NaverEngineering/1-gangenerative-adversarial-network

18 of 70

Discriminator Perspective (2/2)

18

https://www.slideshare.net/NaverEngineering/1-gangenerative-adversarial-network

19 of 70

Generator Perspective

19

https://www.slideshare.net/NaverEngineering/1-gangenerative-adversarial-network

20 of 70

GAN Implementation in TensorFlow

20

21 of 70

TensorFlow Implementation

21

784

784

256

256

100

1

https://www.slideshare.net/NaverEngineering/1-gangenerative-adversarial-network

22 of 70

Generator

22

784

784

256

256

100

1

https://www.slideshare.net/NaverEngineering/1-gangenerative-adversarial-network

23 of 70

Discriminator

23

784

784

256

256

100

1

https://www.slideshare.net/NaverEngineering/1-gangenerative-adversarial-network

24 of 70

Combined

24

784

784

256

256

100

1

https://www.slideshare.net/NaverEngineering/1-gangenerative-adversarial-network

25 of 70

Training: Discriminator

25

784

784

256

256

100

1

https://www.slideshare.net/NaverEngineering/1-gangenerative-adversarial-network

26 of 70

Training: Generator

26

784

784

256

256

100

1

https://www.slideshare.net/NaverEngineering/1-gangenerative-adversarial-network

27 of 70

After Training

  • After training, use generator network to generate new data

27

https://www.slideshare.net/NaverEngineering/1-gangenerative-adversarial-network

28 of 70

Generated Images

28

29 of 70

DCGAN

29

30 of 70

DCGAN (Deep Convolutional GAN)

  • A DCGAN is a direct extension of the GAN, except that it explicitly uses convolutional and convolutional-transpose layers in the discriminator and generator, respectively
  • (For example) simplified architecture

30

Alec Radford, et al., "Unsupervised Representation Learning with Deep Convolutional Generative Adversarial Networks," ICLR 2016

31 of 70

Conditional GAN

31

32 of 70

Normal Distribution of MNIST

  • A standard normal distribution
  • This is how we would like points corresponding to MNIST digit images to be distributed in the latent space

32

33 of 70

Generator at GAN

33

Generator

Generator

34 of 70

Conditional GAN

  • In an unconditioned generative model, there is no control on modes of the data being generated.

  • In the Conditional GAN (CGAN), the generator learns to generate a fake sample with a specific condition or characteristics (such as a label associated with an image or more detailed tag) rather than a generic sample from unknown noise distribution.

34

35 of 70

Conditional GAN

  • MNIST digits generated conditioned on their class label

35

Class,

Label,

Condition

Noise or code

36 of 70

Conditional GAN

  • Simple modification to the original GAN framework that conditions the model on additional information for better multi-modal learning

  • Many practical applications of GANs when we have explicit supervision available

36

37 of 70

Conditional GAN

  • Simple modification to the original GAN framework that conditions the model on additional information for better multi-modal learning

  • Many practical applications of GANs when we have explicit supervision available

37

38 of 70

Conditional GAN

  • Simple modification to the original GAN framework that conditions the model on additional information for better multi-modal learning

  • Many practical applications of GANs when we have explicit supervision available

38

39 of 70

Generator at GAN

39

Generator

Generator

40 of 70

Generator at Conditional GAN

  • Feed a random point in latent space and desired number.
  • Even if the same latent point is used for two different numbers, the process will work correctly since the latent space only encodes features such as stroke width or angle

40

Generator

Generator

41 of 70

Generator

41

42 of 70

Discriminator

42

43 of 70

Combined

43

44 of 70

CGAN Implementation

44

45 of 70

Fake MNIST Images Generated by CGAN

45

46 of 70

Adversarial Autoencoder

46

47 of 70

Autoencoder

  • Dimension reduction
  • Recover the input data
    • Learns an encoding of the inputs so as to recover the original input from the encodings as well as possible

47

Image from https://lilianweng.github.io/

48 of 70

Limitation of Autoencoder

  •  

48

49 of 70

Generator from Autoencoder

  • Dimension reduction
  • Recover the input data
    • Learns an encoding of the inputs so as to recover the original input from the encodings as well as possible

49

Image from https://lilianweng.github.io/

50 of 70

Variational Autoencoder

  • Encoder maps each point into a distribution within the latent space

50

1) Reconstruction loss

2) Regularization

51 of 70

Adversarial Autoencoder

51

52 of 70

Adversarial Autoencoder

52

53 of 70

Incorporating Label Information

53

Label Information

54 of 70

Disentangled Latent Representation

54

55 of 70

Disentangled Latent Representation

55

56 of 70

Disentangled Latent Representation

56

57 of 70

Disentangled Latent Representation

57

58 of 70

CycleGAN

58

59 of 70

Image-to-Image Translation

  • Change the style of image to another style
    • Monet to photos
    • Zebras to horses
    • Summer to winter

59

Unpaired Image-to-Image Translation using Cycle-Consistent Adversarial Networks,

Jun-Yan Zhu, Taesung Park, Phillip Isola, Alexei A. Efros, ICCV 2017

60 of 70

Paired vs. Unpaired Datasets

  • Limitation of paired datasets
    • Impossible to collect paired datasets in most of the cases.

60

61 of 70

Paired vs. Unpaired Datasets

  • Limitation of paired datasets
    • Impossible to collect paired datasets in most of the cases.

61

Change the styles of images

using only unpaired datasets

Cycle-consistent Generative

Adversarial Networks

(CycleGAN)

62 of 70

Start from GAN

  • Given an image X (Horse), transform it into the target image Y (Zebra)

62

Horse

Zebra

 

 

Adversarial Loss

(real or fake)

 

63 of 70

Start from GAN

  • Given an image X (Horse), transform it into the target image Y (Zebra)
  • Do not preserve the content of the input image
    • Discriminator only distinguishes whether it is a horse or a zebra, not the content itself.

63

Horse

Zebra

 

 

Adversarial Loss

(real or fake)

 

64 of 70

Start from GAN

  • Given an image X (Horse), transform it into the target image Y (Zebra)

64

 

 

 

 

Adversarial Loss

(real or fake)

 

65 of 70

CycleGAN

  •  

65

 

 

 

 

 

 

Adversarial Loss

(real or fake)

Cycle-consistency loss

 

66 of 70

Example of CycleGAN

66

67 of 70

Grain Boundary

  • Background
    • Grain boundaries play an important role in governing mechanical and physical properties of polycrystalline materials

  • Research objective
    • Propose an unsupervised learning-based grain boundary detection
    • Only requires virtual micrographs

67

Input

Deep Learning-based Grain Boundary Detection

Output

J. Na+, J. Lee+, et al., Label-free Grain Segmentation for Optical Microscopy Images via Unsupervised Image-to-Image Translation, Materials Characterization

68 of 70

Methodology

  • The appearance of real and virtual micrographs differs, but their underlying grain structure is semantically equivalent

  • How can we transfer appearance information from the virtual domain to the real domain?
    • Image-to-image translation

68

Virtual microstructure

Real microstructure

Not paired

69 of 70

CycleGAN

  • The target appearance is enforced by an adversarial loss, while the grain structure is preserved by a reconstruction loss

69

Real-to-Virtual Microstructure Translation

Real microstructure

 

 

 

Adversarial loss

Reconstruction loss

Virtual microstructure

70 of 70

Results: Low Carbon Steel and Magnesium

70

Magnesium

Low carbon steel

Input

Ground truth

Ours