Lab 14-2 GANs · 2020. 12. 10. · • Your notebook should be named after “Lab14 -2_{student...

23
Lab 14-2 GANs Yu-Rong Zhang & DataLab Department of Computer Science, National Tsing Hua University, Taiwan

Transcript of Lab 14-2 GANs · 2020. 12. 10. · • Your notebook should be named after “Lab14 -2_{student...

Page 1: Lab 14-2 GANs · 2020. 12. 10. · • Your notebook should be named after “Lab14 -2_{student id}.ipynb”. • Deadline : 2020/12/15 23:59. Assignment • Assignment 2 • Read

Lab 14-2GANs

Yu-Rong Zhang & DataLab

Department of Computer Science,National Tsing Hua University, Taiwan

Page 2: Lab 14-2 GANs · 2020. 12. 10. · • Your notebook should be named after “Lab14 -2_{student id}.ipynb”. • Deadline : 2020/12/15 23:59. Assignment • Assignment 2 • Read

Outline

• Reviewing GAN Structure

• Loss Functions

• WGAN

• WGAN-GP (improved WGAN)

Page 3: Lab 14-2 GANs · 2020. 12. 10. · • Your notebook should be named after “Lab14 -2_{student id}.ipynb”. • Deadline : 2020/12/15 23:59. Assignment • Assignment 2 • Read

Outline

• Reviewing GAN Structure

• Loss Functions

• WGAN

• WGAN-GP (improved WGAN)

Page 4: Lab 14-2 GANs · 2020. 12. 10. · • Your notebook should be named after “Lab14 -2_{student id}.ipynb”. • Deadline : 2020/12/15 23:59. Assignment • Assignment 2 • Read

Review - GAN

Page 5: Lab 14-2 GANs · 2020. 12. 10. · • Your notebook should be named after “Lab14 -2_{student id}.ipynb”. • Deadline : 2020/12/15 23:59. Assignment • Assignment 2 • Read

Review - GAN

Page 6: Lab 14-2 GANs · 2020. 12. 10. · • Your notebook should be named after “Lab14 -2_{student id}.ipynb”. • Deadline : 2020/12/15 23:59. Assignment • Assignment 2 • Read

Review - GAN

Page 7: Lab 14-2 GANs · 2020. 12. 10. · • Your notebook should be named after “Lab14 -2_{student id}.ipynb”. • Deadline : 2020/12/15 23:59. Assignment • Assignment 2 • Read

Outline

• Reviewing GAN Structure

• Loss Functions

• WGAN

• WGAN-GP (improved WGAN)

Page 8: Lab 14-2 GANs · 2020. 12. 10. · • Your notebook should be named after “Lab14 -2_{student id}.ipynb”. • Deadline : 2020/12/15 23:59. Assignment • Assignment 2 • Read

Loss Functions

• Minimax Loss:• For D: maximize

• For G: minimize

• Wasserstein Loss:• For D: maximize

• For G: minimize

Page 9: Lab 14-2 GANs · 2020. 12. 10. · • Your notebook should be named after “Lab14 -2_{student id}.ipynb”. • Deadline : 2020/12/15 23:59. Assignment • Assignment 2 • Read

Loss Functions

• Minimax Loss:• For D: maximize

• For G: minimize

• Wasserstein Loss:• For D: maximize

• For G: minimize

𝑓𝑓𝑤𝑤 ∈ 𝐾𝐾 − 𝐿𝐿𝐿𝐿𝐿𝐿𝐿𝐿𝐿𝐿𝐿𝐿𝐿𝐿𝐿𝐿𝐿 𝑓𝑓𝑓𝑓𝑓𝑓𝐿𝐿𝐿𝐿𝐿𝐿𝑓𝑓𝑓𝑓𝐿𝐿 for some 𝐾𝐾

Page 10: Lab 14-2 GANs · 2020. 12. 10. · • Your notebook should be named after “Lab14 -2_{student id}.ipynb”. • Deadline : 2020/12/15 23:59. Assignment • Assignment 2 • Read

Loss Functions

• Lipschitz continuity: a function f : X → Y is called Lipschitz continuousif there exists a real constant K ≧ 0 such that, for all x1 and x2 in X

Page 11: Lab 14-2 GANs · 2020. 12. 10. · • Your notebook should be named after “Lab14 -2_{student id}.ipynb”. • Deadline : 2020/12/15 23:59. Assignment • Assignment 2 • Read

Loss Functions

• Lipschitz continuity: a function f : X → Y is called Lipschitz continuousif there exists a real constant K ≧ 0 such that, for all x1 and x2 in X

• How to make the discriminator Lipschitz continuous?

Page 12: Lab 14-2 GANs · 2020. 12. 10. · • Your notebook should be named after “Lab14 -2_{student id}.ipynb”. • Deadline : 2020/12/15 23:59. Assignment • Assignment 2 • Read

Loss Functions

• Lipschitz continuity: a function f : X → Y is called Lipschitz continuousif there exists a real constant K ≧ 0 such that, for all x1 and x2 in X

• How to make the discriminator Lipschitz continuous?

• Weight clipping – clip all weights in 𝑓𝑓𝑤𝑤 into a certain range.

Page 13: Lab 14-2 GANs · 2020. 12. 10. · • Your notebook should be named after “Lab14 -2_{student id}.ipynb”. • Deadline : 2020/12/15 23:59. Assignment • Assignment 2 • Read

Outline

• Reviewing GAN Structure

• Loss Functions

• WGAN

• WGAN-GP (improved WGAN)

Page 14: Lab 14-2 GANs · 2020. 12. 10. · • Your notebook should be named after “Lab14 -2_{student id}.ipynb”. • Deadline : 2020/12/15 23:59. Assignment • Assignment 2 • Read

WGAN

Make sure critic is 1-Lipchitz

Discriminator Training

Page 15: Lab 14-2 GANs · 2020. 12. 10. · • Your notebook should be named after “Lab14 -2_{student id}.ipynb”. • Deadline : 2020/12/15 23:59. Assignment • Assignment 2 • Read

Outline

• Reviewing GAN Structure

• Loss Functions

• WGAN

• WGAN-GP (improved WGAN)

Page 16: Lab 14-2 GANs · 2020. 12. 10. · • Your notebook should be named after “Lab14 -2_{student id}.ipynb”. • Deadline : 2020/12/15 23:59. Assignment • Assignment 2 • Read

WGAN-GP

• Instead of weight clipping, adding gradient penalty can also achieve Lipchitz continuity.

Gradient Penalty

Page 17: Lab 14-2 GANs · 2020. 12. 10. · • Your notebook should be named after “Lab14 -2_{student id}.ipynb”. • Deadline : 2020/12/15 23:59. Assignment • Assignment 2 • Read

WGAN-GP

• In comparison with WGAN

Page 18: Lab 14-2 GANs · 2020. 12. 10. · • Your notebook should be named after “Lab14 -2_{student id}.ipynb”. • Deadline : 2020/12/15 23:59. Assignment • Assignment 2 • Read

WGAN-GP

• In comparison with WGAN

WGAN

WGAN-GP

Page 19: Lab 14-2 GANs · 2020. 12. 10. · • Your notebook should be named after “Lab14 -2_{student id}.ipynb”. • Deadline : 2020/12/15 23:59. Assignment • Assignment 2 • Read

WGAN-GP

Page 20: Lab 14-2 GANs · 2020. 12. 10. · • Your notebook should be named after “Lab14 -2_{student id}.ipynb”. • Deadline : 2020/12/15 23:59. Assignment • Assignment 2 • Read

WGAN-GP

• Example

Page 21: Lab 14-2 GANs · 2020. 12. 10. · • Your notebook should be named after “Lab14 -2_{student id}.ipynb”. • Deadline : 2020/12/15 23:59. Assignment • Assignment 2 • Read

Assignment

• Assignment 1 requirements• Implementation of Improved WGAN (WGAN-GP) and train on CelebA.• Build dataset to read and resize image to 64 × 64 for training• Training loop(s) / routine(s) for GAN. Pre-trained models are not allowed.• Show at least 8 × 8 animated image of training and some best generated

samples.• Draw the curve of discriminator loss and generator loss during training

process in a single image.• Brief report about what you have done.

Page 22: Lab 14-2 GANs · 2020. 12. 10. · • Your notebook should be named after “Lab14 -2_{student id}.ipynb”. • Deadline : 2020/12/15 23:59. Assignment • Assignment 2 • Read

Assignment

• Assignment 1 submission• Upload notebook and attachments to google drive and submit the link to

iLMS.• Your notebook should be named after “Lab14-2_{student id}.ipynb”.• Deadline : 2020/12/15 23:59

Page 23: Lab 14-2 GANs · 2020. 12. 10. · • Your notebook should be named after “Lab14 -2_{student id}.ipynb”. • Deadline : 2020/12/15 23:59. Assignment • Assignment 2 • Read

Assignment

• Assignment 2• Read the Lab notebook of the autoencoder.