16
Machine Learning (CSE 446): Generative Adversarial Networks (GANs) Sham M Kakade c 2019 University of Washington [email protected] 0 / 14

Machine Learning (CSE 446): Generative Adversarial Networks … · Machine Learning (CSE 446): Generative Adversarial Networks (GANs) Sham M Kakade c 2019 University of Washington

  • Upload
    others

  • View
    34

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Machine Learning (CSE 446): Generative Adversarial Networks … · Machine Learning (CSE 446): Generative Adversarial Networks (GANs) Sham M Kakade c 2019 University of Washington

Machine Learning (CSE 446):Generative Adversarial Networks (GANs)

Sham M Kakade

c� 2019

University of [email protected]

0 / 14

Page 2: Machine Learning (CSE 446): Generative Adversarial Networks … · Machine Learning (CSE 446): Generative Adversarial Networks (GANs) Sham M Kakade c 2019 University of Washington

Announcements

I Weds is the final.

I One page of notes.

I List of topics posted tomorrow.

0 / 14

Page 3: Machine Learning (CSE 446): Generative Adversarial Networks … · Machine Learning (CSE 446): Generative Adversarial Networks (GANs) Sham M Kakade c 2019 University of Washington

Class results with random Fourier features, HW3, Q7

1 / 14

AnimalSarah

Page 4: Machine Learning (CSE 446): Generative Adversarial Networks … · Machine Learning (CSE 446): Generative Adversarial Networks (GANs) Sham M Kakade c 2019 University of Washington

Image Generation

These are computer generated images from the “bigGAN”.

2 / 14

Page 5: Machine Learning (CSE 446): Generative Adversarial Networks … · Machine Learning (CSE 446): Generative Adversarial Networks (GANs) Sham M Kakade c 2019 University of Washington

Classification

I SPAM detection.

I x is an email.

I Suppose Q(x) is the distribution over true emails.

I Suppose G(x) is spammer’s generative distribution over emails.

I usual supervised learning: make a dataset of (x, y) pairs, say with 50% labeled

true and 50% spam.

I suppose Pr✓(Y = 1|X) = D✓(X) is our model’s probably of that Y = 1, trueemail.

3 / 14

T between O and F

Page 6: Machine Learning (CSE 446): Generative Adversarial Networks … · Machine Learning (CSE 446): Generative Adversarial Networks (GANs) Sham M Kakade c 2019 University of Washington

Building Our Classifier

I Maximum likelihood is:

min✓

E log Pr✓(Y = 1|X)

I every ✓ corresponds to some model D.

I If our data is equally split, where all the Y = 1’s come from Q and and all the

Y = 0’s come from G, then:

max✓

E log Pr✓(Y = 1|X) =

maxD

✓Ex⇠Q[

1

2logD(x)] +

1

2Ex⇠G[log(1�D(x))]

I Likelihood function:

L(D,G) =

4 / 14

Dad PpfYAX

datadistI

DG.gl k HQ yet

fk K Egeo

whenY Ewhen4 0

I Exno I lyDaa t zExellegapas

Page 7: Machine Learning (CSE 446): Generative Adversarial Networks … · Machine Learning (CSE 446): Generative Adversarial Networks (GANs) Sham M Kakade c 2019 University of Washington

The Spammer’s Job

I If the spam detector D was fixed, then our spammer wants to:

minG

L(G,D)

I The spammer wants to make the discriminator D’s likelihood large.

5 / 14

O3small

Page 8: Machine Learning (CSE 446): Generative Adversarial Networks … · Machine Learning (CSE 446): Generative Adversarial Networks (GANs) Sham M Kakade c 2019 University of Washington

We have a game:

I Let’s think more abstractly: D is procedure to spot fake images, G is a procedure

to generate images.

I The game can be viewed as:

minG

maxD

L(G,D) =

minG

maxD

✓Ex⇠Q[

1

2logD(x)] +

1

2Ex⇠G[log(1�D(x))]

I Is this a powerful idea?

Remember AD:

6 / 14

if we can get gradientseasily the let's try to play game

Page 9: Machine Learning (CSE 446): Generative Adversarial Networks … · Machine Learning (CSE 446): Generative Adversarial Networks (GANs) Sham M Kakade c 2019 University of Washington

the Discriminator

I just binary image classification “fake or not”

I we know how to do supervised learning

I for a given G and samples from the truth Q, we can learn D.

7 / 14

r learning

easy

create a labeled datasetand do binary classification

Page 10: Machine Learning (CSE 446): Generative Adversarial Networks … · Machine Learning (CSE 446): Generative Adversarial Networks (GANs) Sham M Kakade c 2019 University of Washington

the Generator

I what is a model for generating images?

and how do we update G the model?

I let say z ⇠ N(0, I) where I is a d⇥ d matrix.

I a network:

8 / 14

G Rd X GCEimage space z Source of

randomness

randy d

GCE image

Page 11: Machine Learning (CSE 446): Generative Adversarial Networks … · Machine Learning (CSE 446): Generative Adversarial Networks (GANs) Sham M Kakade c 2019 University of Washington

the Generator network

9 / 14

2 2256O O O O Oinput we

Z O O O O O

convolutional 0 O O O O G G O Oout

Wd256 2356 256imageoutput 7 o o o o

256 toooo o

Page 12: Machine Learning (CSE 446): Generative Adversarial Networks … · Machine Learning (CSE 446): Generative Adversarial Networks (GANs) Sham M Kakade c 2019 University of Washington

Learning

I Fix G, update D.

easy: just supervised learning.

I Now fix D. Recall:

L(G,D) =

✓Ex⇠Q[

1

2logD(x)] +

1

2Ex⇠G[log(1�D(x))]

=

✓Ex⇠Q[

1

2logD(x)] +

1

2Ez⇠Normal(0,I)[log(1�D(G(z)))]

I We can estimate this loss easily. Why?

I Update G: how?

10 / 14

for Gfix Dfeesy

Mis 6 D T nQ w

Sam Ie z'sworth SGD use AD to

gradients easily

Page 13: Machine Learning (CSE 446): Generative Adversarial Networks … · Machine Learning (CSE 446): Generative Adversarial Networks (GANs) Sham M Kakade c 2019 University of Washington

Convergence/Comments

I Does it converge?

Subtle: we are not ”hill climbing” on an on an objective.

I at best, we can get to an equilibrium.

I Comparison to EM and likelihood based approaches:

I Computing the the probability of x under G is di�cult.

di�culty for EM.

I “mode collapse” with GANs

sampling distribution not reflective of the truth.

I NLP generative methods do not use GANs!

(better results with direct training approaches)

11 / 14

Page 14: Machine Learning (CSE 446): Generative Adversarial Networks … · Machine Learning (CSE 446): Generative Adversarial Networks (GANs) Sham M Kakade c 2019 University of Washington

Whichfaceisreal.com

11 / 14

Page 15: Machine Learning (CSE 446): Generative Adversarial Networks … · Machine Learning (CSE 446): Generative Adversarial Networks (GANs) Sham M Kakade c 2019 University of Washington

We can get creativeStyle transfer. From the “cycleGAN”

11 / 14

Page 16: Machine Learning (CSE 446): Generative Adversarial Networks … · Machine Learning (CSE 446): Generative Adversarial Networks (GANs) Sham M Kakade c 2019 University of Washington

Thank you!!

Thank you for the hard work!

I Good luck on the final and have a great spring break.

I You have a good toolkit.

Please participate in the larger ML community!

14 / 14