CSC321 Lecture 19: Generative Adversarial Networks
Roger Grosse
Roger Grosse CSC321 Lecture 19: Generative Adversarial Networks 1 / 25
Overview
In generative modeling, we’d like to train a network that models a
distribution, such as a distribution over images.
One way to judge the quality of the model is to sample from it.
This field has seen rapid progress:
2009 2015
2018
Roger Grosse CSC321 Lecture 19: Generative Adversarial Networks 2 / 25
Overview
Four modern approaches to generative modeling:
Generative adversarial networks (today)
Reversible architectures (next lecture)
Autoregressive models (Lecture 7, and next lecture)
Variational autoencoders (CSC412)
All four approaches have different pros and cons.
Roger Grosse CSC321 Lecture 19: Generative Adversarial Networks 3 / 25
Implicit Generative Models
Implicit generative models implicitly define a probability distribution
Start by sampling the code vector z from a fixed, simple distribution
(e.g. spherical Gaussian)
The generator network computes a differentiable function G mapping
z to an x in data space
Roger Grosse CSC321 Lecture 19: Generative Adversarial Networks 4 / 25
Implicit Generative Models
A 1-dimensional example:
Roger Grosse CSC321 Lecture 19: Generative Adversarial Networks 5 / 25
Implicit Generative Models
https://blog.openai.com/generative-models/
Roger Grosse CSC321 Lecture 19: Generative Adversarial Networks 6 / 25
Implicit Generative Models
This sort of architecture sounded preposterous to many of us, but
amazingly, it works.
Roger Grosse CSC321 Lecture 19: Generative Adversarial Networks 7 / 25
Generative Adversarial Networks
The advantage of implicit generative models: if you have some
criterion for evaluating the quality of samples, then you can compute
its gradient with respect to the network parameters, and update the
network’s parameters to make the sample a little better
The idea behind Generative Adversarial Networks (GANs): train two
different networks
The generator network tries to produce realistic-looking samples
The discriminator network tries to figure out whether an image came
from the training set or the generator network
The generator network tries to fool the discriminator network
Roger Grosse CSC321 Lecture 19: Generative Adversarial Networks 8 / 25
Generative Adversarial Networks
Roger Grosse CSC321 Lecture 19: Generative Adversarial Networks 9 / 25
Generative Adversarial Networks
Let D denote the discriminator’s predicted probability of being data
Discriminator’s cost function: cross-entropy loss for task of classifying
real vs. fake images
JD = Ex∼D[− log D(x)] + Ez[− log(1 − D(G(z)))]
One possible cost function for the generator: the opposite of the
discriminator’s
JG = −JD
= const + Ez[log(1 − D(G(z)))]
This is called the minimax formulation, since the generator and
discriminator are playing a zero-sum game against each other:
max
G
min
D
JD
Roger Grosse CSC321 Lecture 19: Generative Adversarial Networks 10 / 25
Generative Adversarial Networks
Updating the discriminator:
Roger Grosse CSC321 Lecture 19: Generative Adversarial Networks 11 / 25
Generative Adversarial Networks
Updating the generator:
Roger Grosse CSC321 Lecture 19: Generative Adversarial Networks 12 / 25
Generative Adversarial Networks
Alternating training of the generator and discriminator:
Roger Grosse CSC321 Lecture 19: Generative Adversarial Networks 13 / 25
A Better Cost Function
We introduced the minimax cost function for the generator:
JG = Ez[log(1 − D(G(z)))]
One problem with this is saturation.
Recall from our lecture on classification: when the prediction is really
wrong,
“Logistic + squared error” gets a weak gradient signal
“Logistic + cross-entropy” gets a strong gradient signal
Here, if the generated sample is really bad, the discriminator’s
prediction is close to 0, and the generator’s cost is flat.
Roger Grosse CSC321 Lecture 19: Generative Adversarial Networks 14 / 25
A Better Cost Function
Original minimax cost:
JG = Ez[log(1 − D(G(z)))]
Modified generator cost:
JG = Ez[− log D(G(z))]
This fixes the saturation problem.
Roger Grosse CSC321 Lecture 19: Generative Adversarial Networks 15 / 25
Generative Adversarial Networks
Since GANs were introduced in 2014, there have been hundreds of
papers introducing various architectures and training methods.
Most modern architectures are based on the Deep Convolutional GAN
(DC-GAN), where the generator and discriminator are both conv nets.
GAN Zoo: https://github.com/hindupuravinash/the-gan-zoo
Good source of horrible puns (VEEGAN, Checkhov GAN, etc.)
Roger Grosse CSC321 Lecture 19: Generative Adversarial Networks 16 / 25
GAN Samples
Celebrities:
Karras et al., 2017. Progressive growing of GANs for improved quality, stability, and variation
Roger Grosse CSC321 Lecture 19: Generative Adversarial Networks 17 / 25
GAN Samples
Bedrooms:
Karras et al., 2017. Progressive growing of GANs for improved quality, stability, and variation
Roger Grosse CSC321 Lecture 19: Generative Adversarial Networks 18 / 25
GAN Samples
Objects:
Karras et al., 2017. Progressive growing of GANs for improved quality, stability, and variation
Roger Grosse CSC321 Lecture 19: Generative Adversarial Networks 19 / 25
GAN Samples
GANs revolutionized generative modeling by producing crisp,
high-resolution images.
The catch: we don’t know how well they’re modeling the distribution.
Can’t measure the log-likelihood they assign to held-out data.
Could they be memorizing training examples? (E.g., maybe they
sometimes produce photos of real celebrities?)
We have no way to tell if they are dropping important modes from the
distribution.
See Wu et al., “On the quantitative analysis of decoder-based
generative models” for partial answers to these questions.
Roger Grosse CSC321 Lecture 19: Generative Adversarial Networks 20 / 25
CycleGAN
Style transfer problem: change the style of an image while preserving the
content.
Data: Two unrelated collections of images, one for each style
Roger Grosse CSC321 Lecture 19: Generative Adversarial Networks 21 / 25
CycleGAN
If we had paired data (same content in both styles), this would be a
supervised learning problem. But this is hard to find.
The CycleGAN architecture learns to do it from unpaired data.
Train two different generator nets to go from style 1 to style 2, and
vice versa.
Make sure the generated samples of style 2 are indistinguishable from
real images by a discriminator net.
Make sure the generators are cycle-consistent: mapping from style 1 to
style 2 and back again should give you almost the original image.
Roger Grosse CSC321 Lecture 19: Generative Adversarial Networks 22 / 25
CycleGAN
Roger Grosse CSC321 Lecture 19: Generative Adversarial Networks 23 / 25
CycleGAN
Style transfer between aerial photos and maps:
Roger Grosse CSC321 Lecture 19: Generative Adversarial Networks 24 / 25
CycleGAN
Style transfer between road scenes and semantic segmentations (labels of
every pixel in an image by object category):
Roger Grosse CSC321 Lecture 19: Generative Adversarial Networks 25 / 25

More Related Content

PDF
Deep Generative Models - Kevin McGuinness - UPC Barcelona 2018
PDF
Generative Models and Adversarial Training (D2L3 Insight@DCU Machine Learning...
PDF
IRJET- Generating 3D Models Using 3D Generative Adversarial Network
PDF
DAOR - Bridging the Gap between Community and Node Representations: Graph Emb...
PDF
Deep Learning for Computer Vision: Generative models and adversarial training...
PDF
Adversarial examples in deep learning (Gregory Chatel)
PDF
Factorization Machines and Applications in Recommender Systems
PDF
Unpaired Image Translations Using GANs: A Review
Deep Generative Models - Kevin McGuinness - UPC Barcelona 2018
Generative Models and Adversarial Training (D2L3 Insight@DCU Machine Learning...
IRJET- Generating 3D Models Using 3D Generative Adversarial Network
DAOR - Bridging the Gap between Community and Node Representations: Graph Emb...
Deep Learning for Computer Vision: Generative models and adversarial training...
Adversarial examples in deep learning (Gregory Chatel)
Factorization Machines and Applications in Recommender Systems
Unpaired Image Translations Using GANs: A Review

Similar to lec19.pdf (20)

PDF
Generative Adversarial Networks GAN - Santiago Pascual - UPC Barcelona 2018
PDF
Generative Adversarial Networks GAN - Xavier Giro - UPC TelecomBCN Barcelona ...
PPTX
Generative Adversarial Networks (GAN)
PDF
What is a GAN Generative Adversarial Networks Guide.pdf
PPTX
gan-190318135433 (1).pptx
PDF
Tutorial on Theory and Application of Generative Adversarial Networks
PDF
MODELLING AND SYNTHESIZING OF 3D SHAPE WITH STACKED GENERATIVE ADVERSARIAL NE...
PDF
What is a GAN Generative Adversarial Networks Guide.pdf
PDF
What is a GAN Generative Adversarial Networks Guide.pdf
PDF
Volodymyr Lyubinets “Generative models for images”
PDF
Overlapping community detection in Large-Scale Networks using BigCLAM model b...
PDF
Alberto Massidda - Scenes from a memory - Codemotion Rome 2019
PDF
Deep Generative Models II (DLAI D10L1 2017 UPC Deep Learning for Artificial I...
PPTX
Module4_GAN.pptxgdgdijehejejjejejejhehjdd
PPT
Generation of Deepfake images using GAN and Least squares GAN.ppt
PDF
Safety Verification of Deep Neural Networks_.pdf
PDF
Generative modeling with Convolutional Neural Networks
PDF
IMAGE GENERATION FROM CAPTION
PDF
Image Generation from Caption
PDF
Vladislav Kolbasin “Introduction to Generative Adversarial Networks (GANs)”
Generative Adversarial Networks GAN - Santiago Pascual - UPC Barcelona 2018
Generative Adversarial Networks GAN - Xavier Giro - UPC TelecomBCN Barcelona ...
Generative Adversarial Networks (GAN)
What is a GAN Generative Adversarial Networks Guide.pdf
gan-190318135433 (1).pptx
Tutorial on Theory and Application of Generative Adversarial Networks
MODELLING AND SYNTHESIZING OF 3D SHAPE WITH STACKED GENERATIVE ADVERSARIAL NE...
What is a GAN Generative Adversarial Networks Guide.pdf
What is a GAN Generative Adversarial Networks Guide.pdf
Volodymyr Lyubinets “Generative models for images”
Overlapping community detection in Large-Scale Networks using BigCLAM model b...
Alberto Massidda - Scenes from a memory - Codemotion Rome 2019
Deep Generative Models II (DLAI D10L1 2017 UPC Deep Learning for Artificial I...
Module4_GAN.pptxgdgdijehejejjejejejhehjdd
Generation of Deepfake images using GAN and Least squares GAN.ppt
Safety Verification of Deep Neural Networks_.pdf
Generative modeling with Convolutional Neural Networks
IMAGE GENERATION FROM CAPTION
Image Generation from Caption
Vladislav Kolbasin “Introduction to Generative Adversarial Networks (GANs)”
Ad

Recently uploaded (20)

PDF
Unit1 - AIML Chapter 1 concept and ethics
PPTX
Micro1New.ppt.pptx the mai themes of micfrobiology
PDF
Beginners-Guide-to-Artificial-Intelligence.pdf
PPTX
ai_satellite_crop_management_20250815030350.pptx
PPTX
PRASUNET_20240614003_231416_0000[1].pptx
PDF
First part_B-Image Processing - 1 of 2).pdf
PPTX
Chapter 2 -Technology and Enginerring Materials + Composites.pptx
PPTX
Principal presentation for NAAC (1).pptx
PDF
Computer System Architecture 3rd Edition-M Morris Mano.pdf
PDF
Design of Material Handling Equipment Lecture Note
PDF
Accra-Kumasi Expressway - Prefeasibility Report Volume 1 of 7.11.2018.pdf
PDF
Cryptography and Network Security-Module-I.pdf
PPTX
CN_Unite_1 AI&DS ENGGERING SPPU PUNE UNIVERSITY
PDF
Java Basics-Introduction and program control
DOC
T Pandian CV Madurai pandi kokkaf illaya
PDF
Applications of Equal_Area_Criterion.pdf
PPTX
A Brief Introduction to IoT- Smart Objects: The "Things" in IoT
PPTX
Software Engineering and software moduleing
PDF
Computer organization and architecuture Digital Notes....pdf
PDF
UEFA_Embodied_Carbon_Emissions_Football_Infrastructure.pdf
Unit1 - AIML Chapter 1 concept and ethics
Micro1New.ppt.pptx the mai themes of micfrobiology
Beginners-Guide-to-Artificial-Intelligence.pdf
ai_satellite_crop_management_20250815030350.pptx
PRASUNET_20240614003_231416_0000[1].pptx
First part_B-Image Processing - 1 of 2).pdf
Chapter 2 -Technology and Enginerring Materials + Composites.pptx
Principal presentation for NAAC (1).pptx
Computer System Architecture 3rd Edition-M Morris Mano.pdf
Design of Material Handling Equipment Lecture Note
Accra-Kumasi Expressway - Prefeasibility Report Volume 1 of 7.11.2018.pdf
Cryptography and Network Security-Module-I.pdf
CN_Unite_1 AI&DS ENGGERING SPPU PUNE UNIVERSITY
Java Basics-Introduction and program control
T Pandian CV Madurai pandi kokkaf illaya
Applications of Equal_Area_Criterion.pdf
A Brief Introduction to IoT- Smart Objects: The "Things" in IoT
Software Engineering and software moduleing
Computer organization and architecuture Digital Notes....pdf
UEFA_Embodied_Carbon_Emissions_Football_Infrastructure.pdf
Ad

lec19.pdf

  • 1. CSC321 Lecture 19: Generative Adversarial Networks Roger Grosse Roger Grosse CSC321 Lecture 19: Generative Adversarial Networks 1 / 25
  • 2. Overview In generative modeling, we’d like to train a network that models a distribution, such as a distribution over images. One way to judge the quality of the model is to sample from it. This field has seen rapid progress: 2009 2015 2018 Roger Grosse CSC321 Lecture 19: Generative Adversarial Networks 2 / 25
  • 3. Overview Four modern approaches to generative modeling: Generative adversarial networks (today) Reversible architectures (next lecture) Autoregressive models (Lecture 7, and next lecture) Variational autoencoders (CSC412) All four approaches have different pros and cons. Roger Grosse CSC321 Lecture 19: Generative Adversarial Networks 3 / 25
  • 4. Implicit Generative Models Implicit generative models implicitly define a probability distribution Start by sampling the code vector z from a fixed, simple distribution (e.g. spherical Gaussian) The generator network computes a differentiable function G mapping z to an x in data space Roger Grosse CSC321 Lecture 19: Generative Adversarial Networks 4 / 25
  • 5. Implicit Generative Models A 1-dimensional example: Roger Grosse CSC321 Lecture 19: Generative Adversarial Networks 5 / 25
  • 7. Implicit Generative Models This sort of architecture sounded preposterous to many of us, but amazingly, it works. Roger Grosse CSC321 Lecture 19: Generative Adversarial Networks 7 / 25
  • 8. Generative Adversarial Networks The advantage of implicit generative models: if you have some criterion for evaluating the quality of samples, then you can compute its gradient with respect to the network parameters, and update the network’s parameters to make the sample a little better The idea behind Generative Adversarial Networks (GANs): train two different networks The generator network tries to produce realistic-looking samples The discriminator network tries to figure out whether an image came from the training set or the generator network The generator network tries to fool the discriminator network Roger Grosse CSC321 Lecture 19: Generative Adversarial Networks 8 / 25
  • 9. Generative Adversarial Networks Roger Grosse CSC321 Lecture 19: Generative Adversarial Networks 9 / 25
  • 10. Generative Adversarial Networks Let D denote the discriminator’s predicted probability of being data Discriminator’s cost function: cross-entropy loss for task of classifying real vs. fake images JD = Ex∼D[− log D(x)] + Ez[− log(1 − D(G(z)))] One possible cost function for the generator: the opposite of the discriminator’s JG = −JD = const + Ez[log(1 − D(G(z)))] This is called the minimax formulation, since the generator and discriminator are playing a zero-sum game against each other: max G min D JD Roger Grosse CSC321 Lecture 19: Generative Adversarial Networks 10 / 25
  • 11. Generative Adversarial Networks Updating the discriminator: Roger Grosse CSC321 Lecture 19: Generative Adversarial Networks 11 / 25
  • 12. Generative Adversarial Networks Updating the generator: Roger Grosse CSC321 Lecture 19: Generative Adversarial Networks 12 / 25
  • 13. Generative Adversarial Networks Alternating training of the generator and discriminator: Roger Grosse CSC321 Lecture 19: Generative Adversarial Networks 13 / 25
  • 14. A Better Cost Function We introduced the minimax cost function for the generator: JG = Ez[log(1 − D(G(z)))] One problem with this is saturation. Recall from our lecture on classification: when the prediction is really wrong, “Logistic + squared error” gets a weak gradient signal “Logistic + cross-entropy” gets a strong gradient signal Here, if the generated sample is really bad, the discriminator’s prediction is close to 0, and the generator’s cost is flat. Roger Grosse CSC321 Lecture 19: Generative Adversarial Networks 14 / 25
  • 15. A Better Cost Function Original minimax cost: JG = Ez[log(1 − D(G(z)))] Modified generator cost: JG = Ez[− log D(G(z))] This fixes the saturation problem. Roger Grosse CSC321 Lecture 19: Generative Adversarial Networks 15 / 25
  • 16. Generative Adversarial Networks Since GANs were introduced in 2014, there have been hundreds of papers introducing various architectures and training methods. Most modern architectures are based on the Deep Convolutional GAN (DC-GAN), where the generator and discriminator are both conv nets. GAN Zoo: https://github.com/hindupuravinash/the-gan-zoo Good source of horrible puns (VEEGAN, Checkhov GAN, etc.) Roger Grosse CSC321 Lecture 19: Generative Adversarial Networks 16 / 25
  • 17. GAN Samples Celebrities: Karras et al., 2017. Progressive growing of GANs for improved quality, stability, and variation Roger Grosse CSC321 Lecture 19: Generative Adversarial Networks 17 / 25
  • 18. GAN Samples Bedrooms: Karras et al., 2017. Progressive growing of GANs for improved quality, stability, and variation Roger Grosse CSC321 Lecture 19: Generative Adversarial Networks 18 / 25
  • 19. GAN Samples Objects: Karras et al., 2017. Progressive growing of GANs for improved quality, stability, and variation Roger Grosse CSC321 Lecture 19: Generative Adversarial Networks 19 / 25
  • 20. GAN Samples GANs revolutionized generative modeling by producing crisp, high-resolution images. The catch: we don’t know how well they’re modeling the distribution. Can’t measure the log-likelihood they assign to held-out data. Could they be memorizing training examples? (E.g., maybe they sometimes produce photos of real celebrities?) We have no way to tell if they are dropping important modes from the distribution. See Wu et al., “On the quantitative analysis of decoder-based generative models” for partial answers to these questions. Roger Grosse CSC321 Lecture 19: Generative Adversarial Networks 20 / 25
  • 21. CycleGAN Style transfer problem: change the style of an image while preserving the content. Data: Two unrelated collections of images, one for each style Roger Grosse CSC321 Lecture 19: Generative Adversarial Networks 21 / 25
  • 22. CycleGAN If we had paired data (same content in both styles), this would be a supervised learning problem. But this is hard to find. The CycleGAN architecture learns to do it from unpaired data. Train two different generator nets to go from style 1 to style 2, and vice versa. Make sure the generated samples of style 2 are indistinguishable from real images by a discriminator net. Make sure the generators are cycle-consistent: mapping from style 1 to style 2 and back again should give you almost the original image. Roger Grosse CSC321 Lecture 19: Generative Adversarial Networks 22 / 25
  • 23. CycleGAN Roger Grosse CSC321 Lecture 19: Generative Adversarial Networks 23 / 25
  • 24. CycleGAN Style transfer between aerial photos and maps: Roger Grosse CSC321 Lecture 19: Generative Adversarial Networks 24 / 25
  • 25. CycleGAN Style transfer between road scenes and semantic segmentations (labels of every pixel in an image by object category): Roger Grosse CSC321 Lecture 19: Generative Adversarial Networks 25 / 25