程序代写代做代考 game chain go Generative Adversarial Networks (GANs)

Generative Adversarial Networks (GANs)
Unsupervised Learning IV
Slides from lectures by Fei-Fei Li, Justin Johnson & Serena Yeung, Roger Grosse

Today
• Supervised vs Unsupervised Learning (recap) • Density Models
• Generative Adversarial Networks (GANs)
• Cycle-GANs

Supervised vs Unsupervised Learning Recap
Generative Adversarial Networks (GANs)

Supervised vs Unsupervised Learning
Supervised Learning Data: (x, y)
x is data, y is label
Goal: Learn a function to map x -> y
Examples: Classification, regression, object detection, semantic segmentation, image captioning, etc.
Fei-Fei Li & Justin Johnson & Serena Yeung Lecture 13 – 4 May 18, 2017

Supervised vs Unsupervised Learning
Supervised Learning Data: (x, y)
x is data, y is label
Goal: Learn a function to map x -> y
Examples: Classification, regression, object detection, semantic segmentation, image captioning, etc.
Cat
Classification
This image is CC0 public domain
Fei-Fei Li & Justin Johnson & Serena Yeung Lecture 13 – 5 May 18, 2017

Supervised vs Unsupervised Learning
Supervised Learning Data: (x, y)
x is data, y is label
Goal: Learn a function to map x -> y
Examples: Classification, regression, object detection, semantic segmentation, image captioning, etc.
DOG, DOG, CAT Object Detection
This image is CC0 public domain
Fei-Fei Li & Justin Johnson & Serena Yeung Lecture 13 – 6 May 18, 2017

Supervised vs Unsupervised Learning
Supervised Learning Data: (x, y)
x is data, y is label
Goal: Learn a function to map x -> y
Examples: Classification, regression, object detection, semantic segmentation, image captioning, etc.
GRASS, CAT, TREE, SKY
Semantic Segmentation
Fei-Fei Li & Justin Johnson & Serena Yeung Lecture 13 – 7 May 18, 2017

Supervised vs Unsupervised Learning
Unsupervised Learning Data: x
Just data, no labels!
Goal: Learn some underlying
hidden structure of the data
Examples: Clustering, dimensionality reduction, feature learning, density estimation, etc.
Fei-Fei Li & Justin Johnson & Serena Yeung
Lecture 13 – 9 May 18, 2017

Supervised vs Unsupervised Learning
Unsupervised Learning Data: x
Just data, no labels!
Goal: Learn some underlying
hidden structure of the data
Examples: Clustering, dimensionality reduction, feature learning, density estimation, etc.
K-means clustering
This image is CC0 public domain
Fei-Fei Li & Justin Johnson & Serena Yeung Lecture 13 – 10 May 18, 2017

Supervised vs Unsupervised Learning
Unsupervised Learning Data: x
Just data, no labels!
Goal: Learn some underlying
hidden structure of the data
Examples: Clustering, dimensionality reduction, feature learning, density estimation, etc.
3-d 2-d
Principal Component Analysis (Dimensionality reduction)
This image from Matthias Scholz is CC0 public domain
Fei-Fei Li & Justin Johnson & Serena Yeung Lecture 13 – 11 May 18, 2017

Supervised vs Unsupervised Learning
Unsupervised Learning Data: x
Just data, no labels!
Goal: Learn some underlying
hidden structure of the data
Examples: Clustering, dimensionality reduction, feature learning, density estimation, etc.
Figure copyright Ian Goodfellow, 2016. Reproduced with permission.
1-d density estimation
2-d density estimation
2-d density images left and right are CC0 public domain
Fei-Fei Li & Justin Johnson & Serena Yeung Lecture 13 – 13 May 18, 2017

Supervised vs Unsupervised Learning
Supervised Learning Data: (x, y)
x is data, y is label
Goal: Learn a function to map x -> y
Examples: Classification, regression, object detection, semantic segmentation, image captioning, etc.
Unsupervised Learning Data: x
Just data, no labels!
Goal: Learn some underlying
hidden structure of the data
Examples: Clustering, dimensionality reduction, feature learning, density estimation, etc.
Fei-Fei Li & Justin Johnson & Serena Yeung
Lecture 13 – 14 May 18, 2017

Supervised vs Unsupervised Learning
Supervised Learning Data: (x, y)
x is data, y is label
Goal: Learn a function to map x -> y
Examples: Classification, regression, object detection, semantic segmentation, image captioning, etc.
Unsupervised Learning
Training data is cheap
Data: x
Just data, no labels!
Holy grail: Solve unsupervised learning => understand structure of the data
Goal: Learn some underlying hidden structure of the data
Examples: Clustering, dimensionality reduction, feature learning, density estimation, etc.
Fei-Fei Li & Justin Johnson & Serena Yeung Lecture 13 – 15 May 18, 2017

Generative Models
Given training data, generate new samples from same distribution
Training data ~ pdata(x) Generated samples ~ pmodel(x) Want to learn pmodel(x) similar to pdata(x)
Fei-Fei Li & Justin Johnson & Serena Yeung Lecture 13 – 16 May 18, 2017

Generative Models
Given training data, generate new samples from same distribution
Training data ~ pdata(x) Generated samples ~ pmodel(x) Want to learn pmodel(x) similar to pdata(x)
Addresses density estimation, a core problem in unsupervised learning
Several flavors:
– Explicit density estimation: explicitly define and solve for pmodel(x)
– Implicit density estimation: learn model that can sample from pmodel(x) w/o explicitly defining it
Fei-Fei Li & Justin Johnson & Serena Yeung Lecture 13 – 17 May 18, 2017

Why Generative Models?
– Realistic samples for artwork, super-resolution, colorization, etc.
– Generative models of time-series data can be used for simulation and planning (reinforcement learning applications!)
– Training generative models can also enable inference of latent representations that can be useful as general features
FIgures from L-R are copyright: (1) Alec Radford et al. 2016; (2) David Berthelot et al. 2017; Phillip Isola et al. 2017. Reproduced with authors permission.
Fei-Fei Li & Justin Johnson & Serena Yeung Lecture 13 – 18 May 18, 2017

Taxonomy of Generative Models
Direct
GAN
Explicit density Tractable density
Fully Visible Belief Nets
Generative models
Implicit density Approximate density
Markov Chain
GSN
Variational Markov Chain
Variational Autoencoder Boltzmann Machine
Figure copyright and adapted from Ian Goodfellow, Tutorial on Generative Adversarial Networks, 2017.
Fei-Fei Li & Justin Johnson & Serena Yeung Lecture 13 – 19 May 18, 2017

Generative Adversarial Networks
Generative Adversarial Networks (GANs)

Overview
Four modern approaches to generative modeling: Generative adversarial networks (today)
Reversible architectures (next lecture) Autoregressivemodels (L ecture7,andnextlecture) Variational autoencoders (CSC412)
All four approaches have different pros and cons.
Roger Grosse
CS C321 Lecture 19: Generative AdversarialNetworks

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)
ThegeneratornetworkcomputesadifferentiablefunctionG mapping ztoanxindataspace
Roger Grosse CS C321 Lecture 19: Generative AdversarialNetworks
Roger Grosse CSC321 Lecture 19: Generative Adversarial N etworks 4 / 25

Implicit Generative Models
A 1-dimensional example:
Roger Grosse CS C321 Lecture 19: Generative AdversarialNetworks
Roger Grosse CSC321 Lecture 19: Generative Adversarial N etworks 5 / 25

Implicit Generative Models
https://blog.openai.com/generative-models/
Roger Grosse CS C321 Lecture 19: Generative AdversarialNetworks
Roger Grosse CSC321 Lecture 19: Generative Adversarial N etworks 6 / 25

Implicit Generative Models
This sort of architecture sounded preposterous to many of us, but amazingly, it works.
Roger Grosse CS C321 Lecture 19: Generative AdversarialNetworks
Roger Grosse CSC321 Lecture 19: Generative Adversarial N etworks 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 CS C321 Lecture 19: Generative AdversarialNetworks
Roger Grosse CSC321 Lecture 19: Generative Adversarial N etworks 8 / 25

Generative Adversarial Networks
Roger Grosse CS C321 Lecture 19: Generative AdversarialNetworks
Roger Grosse CSC321 Lecture 19: Generative Adversarial N etworks 9 / 25

Generative Adversarial Networks
LetD denotethediscriminator’spredictedprobabilityofbeingdata Discriminator’s cost function: cross-entropy loss for task of classifying real vs. fake images
JD =Ex~D[-logD(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:
maxminJ D GD
Roger Grosse CS C321 Lecture 19: Generative AdversarialNetworks
Roger Grosse CSC321 Lecture 19: Generative Adversarial N etworks 10 / 25

Generative Adversarial Networks
Updating the discriminator:
Roger Grosse CS C321 Lecture 19: Generative AdversarialNetworks
Roger Grosse CSC321 Lecture 19: Generative Adversarial N etworks 11 / 25

Generative Adversarial Networks
Updating the generator:
Roger Grosse CS C321 Lecture 19: Generative AdversarialNetworks
Roger Grosse CSC321 Lecture 19: Generative Adversarial N etworks 12 / 25

Generative Adversarial Networks
Alternating training of the generator and discriminator:
Roger Grosse CS C321 Lecture 19: Generative AdversarialNetworks
Roger Grosse CSC321 Lecture 19: Generative Adversarial N etworks 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. Recallfromourlectureonclassification:whenthepredictionisreally wrong,
“Logistic + squared error” gets a weak gradient signal “Logistic + cross- entropy” gets a strong gradient signal
Here,ifthegeneratedsampleisreallybad,thediscriminator’s predictionis close to 0, and the generator’s cost is flat.
Roger Grosse CS C321 Lecture 19: Generative AdversarialNetworks
Roger Grosse CSC321 Lecture 19: Generative Adversarial N etworks 14 / 25

A Better Cost Function
Original minimax cost:
JG =Ez[log(1- D(G (z)))]
Modified generator cost:
JG =Ez[-logD(G(z))]
This fixes the saturation problem.
Roger Grosse CS C321 Lecture 19: Generative AdversarialNetworks
Roger Grosse CSC321 Lecture 19: Generative Adversarial N etworks 15 / 25

Generative Adversarial Networks
Since GANs were introduced in 2014, there have been hundreds of papersintroducingvariousarchitecturesandtraining 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
Goodsourceofhorriblepuns(VEEGAN, CheckhovGAN, etc.)
Roger Grosse CS C321 Lecture 19: Generative AdversarialNetworks
Roger Grosse CSC321 Lecture 19: Generative Adversarial N etworks 16 / 25

GANs: Application to Image Generation
Generative Adversarial Networks (GANs)

Generative Adversarial Nets Generated samples
Ian Goodfellow et al., “Generative Adversarial Nets”, NIPS 2014
Nearest neighbor from training set
Figures copyright Ian Goodfellow et al., 2014. Reproduced with permission.
Fei-Fei Li & Justin Johnson & Serena Yeung
Lecture 13 – 11 May 18, 2017 6

Generative Adversarial Nets Generated samples (CIFAR-10)
Ian Goodfellow et al., “Generative Adversarial Nets”, NIPS 2014
Nearest neighbor from training set
Figures copyright Ian Goodfellow et al., 2014. Reproduced with permission.
Fei-Fei Li & Justin Johnson & Serena Yeung
Lecture 13 – 11 May 18, 2017 7

GAN Samples
Celebrities:
Karras et al., 2017. Progressive growing of GANs for improved quality, stability, and variation
Roger Grosse CS C321 Lecture 19: Generative AdversarialNetworks
Roger Grosse CSC321 Lecture 19: Generative Adversarial N etworks 17 / 25

GAN Samples
Bedrooms:
Karras et al., 2017. Progressive growing of GANs for improved quality, stability, and variation
Roger Grosse CS C321 Lecture 19: Generative AdversarialNetworks
Roger Grosse CSC321 Lecture 19: Generative Adversarial N etworks 18 / 25

GAN Samples
Objects:
Karras et al., 2017. Progressive growing of GANs for improved quality, stability, and variation
Roger Grosse CS C321 Lecture 19: Generative AdversarialNetworks
Roger Grosse CSC321 Lecture 19: Generative Adversarial N etworks 19 / 25

GAN Samples
GANsrevolutionizedgenerativemodelingbyproducingcrisp, high- resolution images.
The catch: we don’t know how well they’re modeling the distribution.
Can’tmeasurethelog-likelihoodtheyassigntoheld-outdata. Couldthey bememorizingtrainingexamples?(E.g., maybethey sometimesproduce 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 CS C321 Lecture 19: Generative AdversarialNetworks
Roger Grosse CSC321 Lecture 19: Generative Adversarial N etworks 20 / 25

Cycle GANs
Generative Adversarial Networks (GANs)

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 CS C321 Lecture 19: Generative AdversarialNetworks
Roger Grosse CSC321 Lecture 19: Generative Adversarial N etworks 21 / 25

CycleGAN
If we had paired data (same content in both styles), this would be a supervisedlearningproblem.But thisishardto 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 2are indistinguishable from real images by a discriminator net.
Make sure the generators are cycle-consistent: mapping from style 1 to style2andbackagainshouldgiveyoualmosttheoriginal image.
Roger Grosse CS C321 Lecture 19: Generative AdversarialNetworks
Roger Grosse CSC321 Lecture 19: Generative Adversarial N etworks 22 / 25

CycleGAN
Roger Grosse CS C321 Lecture 19: Generative AdversarialNetworks
Roger Grosse CSC321 Lecture 19: Generative Adversarial N etworks 23 / 25

CycleGAN
Style transfer between aerial photos and maps:
Roger Grosse CS C321 Lecture 19: Generative AdversarialNetworks
Roger Grosse CSC321 Lecture 19: Generative Adversarial N etworks 24 / 25

CycleGAN
Style transfer between road scenes and semantic segmentations (labels of every pixel in an image by object category):
Roger Grosse CS C321 Lecture 19: Generative AdversarialNetworks
Roger Grosse CSC321 Lecture 19: Generative Adversarial N etworks 25 / 25

GANs: Convolutional Architectures
Generative Adversarial Networks (GANs)

Generative Adversarial Nets: Convolutional Architectures
Generator is an upsampling network with fractionally-strided convolutions Discriminator is a convolutional network
Radford et al, “Unsupervised Representation Learning with Deep Convolutional Generative Adversarial Networks”, ICLR 2016
Fei-Fei Li & Justin Johnson & Serena Yeung Lecture 13 – 11 May 18, 2017 8

Generative Adversarial Nets: Convolutional Architectures
Generator
Radford et al, “Unsupervised Representation Learning with Deep Convolutional Generative Adversarial Networks”, ICLR 2016
Fei-Fei Li & Justin Johnson & Serena Yeung Lecture 13 – 11 May 18, 2017 9

Generative Adversarial Nets: Convolutional Architectures
Samples from the model look amazing!
Radford et al, ICLR 2016
Fei-Fei Li & Justin Johnson & Serena Yeung Lecture 13 – 12 May 18, 2017 0

Generative Adversarial Nets: Convolutional Architectures
Interpolating between random
points in latent space
Radford et al, ICLR 2016
Fei-Fei Li & Justin Johnson & Serena Yeung Lecture 13 – 12 May 18, 2017 1

Generative Adversarial Nets: Interpretable Vector Math
Smiling woman Neutral woman Neutral man
Samples from the model
Radford et al, ICLR 2016
Fei-Fei Li & Justin Johnson & Serena Yeung Lecture 13 – 12 May 18, 2017 2

Generative Adversarial Nets: Interpretable Vector Math
Smiling woman
Samples from the model
Average Z vectors, do arithmetic
Neutral woman
Neutral man
Radford et al, ICLR 2016
Fei-Fei Li & Justin Johnson & Serena Yeung Lecture 13 – 12 May 18, 2017 3

Generative Adversarial Nets: Interpretable Vector Math
Smiling woman
Samples from the model
Average Z vectors, do arithmetic
Neutral woman
Neutral man
Radford et al, ICLR 2016
Smiling Man
Fei-Fei Li & Justin Johnson & Serena Yeung Lecture 13 – 12 May 18, 2017 4

Generative Adversarial Nets: Interpretable Vector Math Glasses man No glasses man No glasses woman
Radford et al, ICLR 2016
Fei-Fei Li & Justin Johnson & Serena Yeung Lecture 13 – 12 May 18, 2017 5

Generative Adversarial Nets: Interpretable Vector Math
Glasses man No glasses man No glasses woman
Woman with glasses
Radford et al, ICLR 2016
Fei-Fei Li & Justin Johnson & Serena Yeung Lecture 13 – 12 May 18, 2017 6

2017: Year of the GAN
Text -> Image Synthesis
Better training and generation
Source->Target domain transfer
LSGAN. Mao et al. 2017.
Reed et al. 2017.
Many GAN applications
Pix2pix. Isola 2017. Many examples at https://phillipi.github.io/pix2pix/
BEGAN. Bertholet et al. 2017.
CycleGAN. Zhu et al. 2017.
Fei-Fei Li & Justin Johnson & Serena Yeung Lecture 13 – 12 May 18, 2017 7