generative adversarial networks (gans)

41
Generative Adversarial Networks (GANs) M2 Data Science and AI Yaohui WANG

Upload: others

Post on 13-Jun-2022

25 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Generative Adversarial Networks (GANs)

Generative Adversarial Networks (GANs)

M2 Data Science and AI

Yaohui WANG

Page 2: Generative Adversarial Networks (GANs)

2017.12 ~ Now, Ph.D Candidate in STARS team, Inria, FranceResearch Interest: GANs, Neural Network architecture, video understanding

1. GAN for video generation

2. Neural Architecture Search (NAS)

3. Activity Recognition

About Me

!2

Page 3: Generative Adversarial Networks (GANs)

• Introduction

• Conditional GAN

• Lab (DCGAN for manga face generation)

Outline

!3

Page 4: Generative Adversarial Networks (GANs)

Generative Adversarial Networks [NIPS 2014]

Ian Goodfellow

!4

Page 5: Generative Adversarial Networks (GANs)

!5

Page 6: Generative Adversarial Networks (GANs)

Basic idea of GAN

G0.1−0.1⋮0.7

−0.30.1⋮0.9

0.3−0.1⋮

−0.7in a specific range (Gaussian, …)

!6

Page 7: Generative Adversarial Networks (GANs)

Basic idea of GANz (vector)

Neural Network

G Image

0.1−3⋮2.40.9

GEach dimension of input vector

represents some characters

3−3⋮2.40.9

GLonger hair

0.12.1⋮5.40.9

Gblue hair

0.1−3⋮2.43.5

Gopen mouth

X = G(z)

Image

!7

Page 8: Generative Adversarial Networks (GANs)

Basic idea of GAN

Neural Network

y = D(X)Image D scalar higher value: more realistic

lower value: less realistic

D

D

D

D

1.0 1.0

0.1 0.1

!8

Page 9: Generative Adversarial Networks (GANs)

Basic idea of GANAdversarial Training (Generative Adversarial Networks)

G D

G

G

D

D

z

z

z

update

update

update

θG

θG

θG

update θD

update θD

update θD

epoch 0

!9

Page 10: Generative Adversarial Networks (GANs)

Basic idea of GANAdversarial Training (Generative Adversarial Networks)

Learning D

Learning G

!10

Page 11: Generative Adversarial Networks (GANs)

Basic idea of GAN

Generator: G is a network. It defines a probability distribution PG

Gas close as

possible

Pdata(x)

!

z ∼ N(0,1)PG(x)

x = G(z)

how to compute the divergence between two distributions ?

G* = argminG

Div(PG, Pdata)

!11

Page 12: Generative Adversarial Networks (GANs)

Basic idea of GAN

Discriminator G* = argminG

Div(PG, Pdata)

Although we do not know the distributions of and , we can still sample from themPG(x) Pdata(x)

real images

sampling from Pdata(x)

G!sample from

normal distributionsampling from PG(x)

!12

Page 13: Generative Adversarial Networks (GANs)

Basic idea of GAN

Discriminator G* = argminG

Div(PG, Pdata)

Objective function for D

V(G, D) = Ex∼Pdata[logD(x)] + Ex∼PG

[log(1 − D(x))]

D* = argmaxD

V(G, D)(G is fixed)

JS Divergence= binary classification

!13

Page 14: Generative Adversarial Networks (GANs)

Basic idea of GAN

Discriminator G* = argminG

Div(PG, Pdata)

Objective function for G

G* = argmG

in(Ex∼Pdata[logD(x)] + Ex∼PG

[log(1 − D(G(z)))])

(D is fixed)

!14

Ex∼PG[−log(D(G(z)))])

Page 15: Generative Adversarial Networks (GANs)

Basic idea of GAN

−"#$ % &

! "

!"# 1 − & '

Ex∼PG[−log(D(G(z)))])

Ex∼PG[log(D(1 − G(z)))])

slow at the beginning

real implementation

Page 16: Generative Adversarial Networks (GANs)

Basic idea of GAN

• WGAN

• WGAN-GP

• LSGAN

• …

Different GANs

!16

Page 17: Generative Adversarial Networks (GANs)

Basic idea of GAN

Training Steps:

•Initialize Generator and Discriminator

•In each training iteration:Step1: Fix Generator G, and update Discriminator DStep 2: Fix Discriminator D, and update Generator G

G* = argminG

mD

axV(G, D)

!17

V(G, D) = Ex∼Pdata[logD(x)] + Ez∼Pz

[log(1 − D(G(z)))]

Page 18: Generative Adversarial Networks (GANs)

GANs Architecture for Image Generation

!18

Page 19: Generative Adversarial Networks (GANs)

Vanilla GAN

X’ = G(z)X

D(X)

z

D

G

real image

fake image

!19

[Ian Goodfellow, et al, NIPS 2014]

Page 20: Generative Adversarial Networks (GANs)

Conditional GAN

X’ = G(z)X

D(X)

z

D

G

real image

fake image

c

CGAN

!20

[M Mirza, et al, arXiv 2014]

Page 21: Generative Adversarial Networks (GANs)

X’ = G(z)X

D(X)

z

D

G

real image

Conditional GAN

c

fake image

c

ACGAN

!21

[August Odena, et al, ICML 2016]

Page 22: Generative Adversarial Networks (GANs)

male,withoutglasses

male,withglasses

female,withoutglasses

female,withglasses

Conditional GAN

Page 23: Generative Adversarial Networks (GANs)

withoutglasses,female,noblackhair,nosmiling,young

withoutglasses,female,blackhair, smiling,young

withglasses,female, no blackhair,smiling,old

withoutglasses,male,noblackhair, smiling,young

withglasses,male,blackhair,smiling,old

without glasses,male,noblackhair,nosmiling,old

withglasses,female,blackhair,nosmiling,old

withglasses,male,blackhair, nosmiling,young

Conditional GAN

Page 24: Generative Adversarial Networks (GANs)

Conditional GAN

Text-to-image Generation

!24

[Scott Reed, et al, ICML 2016]

Page 25: Generative Adversarial Networks (GANs)

Conditional GANImage-to-image translation

NN Image as close as possible

• Traditional method

Testing:

It is blurry, what is the problem here ?

L1 / L2 loss

!25

Page 26: Generative Adversarial Networks (GANs)

generated image target

as close as possible

Conditional GANImage-to-image translation

!26

Page 27: Generative Adversarial Networks (GANs)

Conditional GANImage-to-image translation

1 pixel error not realistic

1 pixel error not realistic

6 pixel error realistic

6 pixel error realistic

target

!27

Page 28: Generative Adversarial Networks (GANs)

Conditional GANImage-to-image translation

Reconstruction loss can not provide a sharp generation, what should be the solution ?

Since we can not find a good metric, we can use GAN to learn the metric !

!28

Page 29: Generative Adversarial Networks (GANs)

Conditional GANImage-to-image translation

G Image

as close as possible• GAN method (Pix2Pix)

Testing:

ZImage

D scalar

Input Reconstruct GAN GAN + Reconstruct!29

[Phillip Isola, et al, CVPR 2017]

Page 30: Generative Adversarial Networks (GANs)

• What about unpaired data (no ground truth of target image) ?

X: zebra Y: horse

X: summer Y: winter!30

Image-to-image translation

Page 31: Generative Adversarial Networks (GANs)

GX→Y

X

• CycleGAN

DX DY

GY→X

reconstruction

reconstruction

X → Y

Y

X′�

Y′�Y → X

belongs to domain Y ?

belongs to domain X ?

GX→YGY→X

!31

Image-to-image translation[Jun-yan Zhu, et al, ICCV 2017]

Page 32: Generative Adversarial Networks (GANs)

Conditional GANVideo Generation

• Everybody dance now

https://www.youtube.com/watch?v=PCBTZh41Ris

!32

[Carolin Chan, et al, ICCV 2019]

Page 33: Generative Adversarial Networks (GANs)

Conditional GANVideo-to-video translation

• Video-to-video synthesis

!33

[Ting-chun Wang, et al, NIPS 2018]https://github.com/NVIDIA/vid2vid

Page 34: Generative Adversarial Networks (GANs)

Modern Architectures

DCGAN

!34

[A Radford, et al, arXiv 2015]

https://github.com/vdumoulin/conv_arithmetic

Page 35: Generative Adversarial Networks (GANs)

Modern Architectures

StyleGAN (NVIDA)

!35

[T Karras, et al, CVPR 2019]

https://github.com/NVlabs/stylegan

Page 36: Generative Adversarial Networks (GANs)

Karras et al, A Style-Based Generator Architecture for Generative Adversarial Networks, CVPR 2019

Modern Architectures

StyleGAN

https://www.youtube.com/watch?v=kSLJriaOumA

!36

Page 37: Generative Adversarial Networks (GANs)

Modern Architectures

StyleGAN

Page 38: Generative Adversarial Networks (GANs)

Modern Architectures

BigGAN (DeepMind)

!38

[A Brock, et al, ICLR 2019]

https://github.com/ajbrock/BigGAN-PyTorch

Page 39: Generative Adversarial Networks (GANs)

Modern Architectures

BigGAN

!39

On 8xV100 with full-precision training (no Tensor cores), this script takes 15 days to train to 150k iterations.

Page 40: Generative Adversarial Networks (GANs)

-R.Feynman

WhatIcannotcreate,Idonotunderstand

!40

Page 41: Generative Adversarial Networks (GANs)

Thank You !