GTC, May 2017. Greg Heinrich.
Photo Editing With Generative Adversarial Networks (GANs) GTC, May - - PowerPoint PPT Presentation
Photo Editing With Generative Adversarial Networks (GANs) GTC, May - - PowerPoint PPT Presentation
Photo Editing With Generative Adversarial Networks (GANs) GTC, May 2017. Greg Heinrich. PANDARUS: Alas, I think he shall be come approached and the day When little srain would be attain'd into being never fed, And who is but a chain and subjects
2 2
GAN: WHAT IS A GENERATIVE MODEL?
Learn from Shakespeare novels:
http://karpathy.github.io/2015/05/21/rnn- effectiveness/
Produce:
PANDARUS: Alas, I think he shall be come approached and the day When little srain would be attain'd into being never fed, And who is but a chain and subjects of his death, I should not sleep.
In Machine Learning A generative model learns to generate samples that have the same characteristics as the samples in the dataset.
PANDARUS: Alas, I think he shall be come approached and the day When little srain would be attain'd into being never fed, And who is but a chain and subjects of his death, I should not sleep.
3 3
BASIC REMINDER: BACKPROP
Output of each neuron π of layer π :
βπ
π = π π¨ π π = π π₯ππ π βπ πβ1 + π π π π
Gradient of E with respect to each weight:
ππΉ ππ₯ππ
π =
ππΉ ππ¨π
π
ππ¨π
π
ππ₯ππ
π =
ππΉ ππ¨π
π βπ
πβ1
Calculation of
ππΉ ππ¨π
π: ππΉ ππ¨π
π =
ππΉ ππ¨π
π+1
π ππ¨π
π+1
ππ¨π
π =
ππΉ ππ¨π
π+1
ππ¨π
π+1
πβπ
π
πβπ
π
ππ¨π
π
π
= ππΉ ππ¨π
π+1 π₯ ππ π+1πβ² π¨ π π π
= πβ² π¨
π π ππΉ
ππ¨π
π+1 π₯ ππ π+1 π
Calculating
ππΉ ππ₯ππ
π iteratively
Multivariate chain rule Chain rule
Chain rule
ππ¨π
π
ππ₯ππ
π only depends on βπ πβ1
Calculated during forward prop
4 4
GAN: PLAYING THE ADVERSARIAL GAME
Learning on a corpus of images Letβs play a game opposing two agents:
- The Generator, a little imp in the computer who paints images.
- The Discriminator: you are collectively responsible for playing the
Discriminator. The game master (me) randomly picks images from either the corpus or the Generator and shows them to the Discriminator. The goal of the Discriminator is to identify the source of the images: real (from the corpus) or fake (painted by the little imp). The goal of the Generator is to fool the Discriminator.
5 5
PLAYING THE ADVERSARIAL GAME
* veelhoek is the articulation
- f a ubiquitous item in the
language of a tiny country in Europe that is well known for the inferior quality of its cheese.
Is this a veelhoek* from our corpus?
Yes, this red square is a veelhoek!
Note: you donβt have to know what a veelhoek is, you will learn through examples!
6 6
No, those squiggly lines arenβt right!
PLAYING THE ADVERSARIAL GAME
Is this a veelhoek from our corpus?
7 7
PLAYING THE ADVERSARIAL GAME
Is this a veelhoek from our corpus?
Yes, even though itβs blue and tiny!
8 8
PLAYING THE ADVERSARIAL GAME
Is this a veelhoek from our corpus?
No, those rounded corners are a giveaway!
9 9
No, but itβs a very good fake!
PLAYING THE ADVERSARIAL GAME
Is this a veelhoek from our corpus?
10 10
No, itβs the same fake as before!
PLAYING THE ADVERSARIAL GAME
Is this a veelhoek from our corpus?
11 11
PLAYING THE ADVERSARIAL GAME
Is this a veelhoek from our corpus?
No, but itβs a very creative fake!
12 12
THE LATENT REPRESENTATION
From features to images
A veelhoek is characterized by three features:
- colour,
- size,
- number of faces
This set of features is known as the βLATENT REPRESENTATIONβ. We can generate many real-looking veelhoeks by randomly picking reasonable values
- f each feature:
13 13
THE LATENT REPRESENTATION
Arithmetic in latent space
We can perform operations in latent space, have them reflected in feature space:
1 2 πππ ππ π ππ 3 πππππ‘ + π‘ππππ ππ πππ 5 πππππ‘ = πππππ£π π§πππππ₯ 4 πππππ‘
Equivalently:
1 2 π ππ πππ ππ 3 πππππ‘ + ππ πππ π‘ππππ 5 πππππ‘ = +
14 14
THE GAN SET-UP
Connecting the Discriminator to the Generator and the Dataset
Random Latent vector
15 15
GAN: NETWORK TOPOLOGY
Radford (2015). Unsupervised Representation Learning with Deep Convolutional Generative Adversarial Networks. arXiv:1511.06434
Generator Discriminator
16 16
TRAINING A GAN ON CELEBRITY FACES*
* CelebFaces dataset
Generating new faces by picking random values of the latent vector
17 17 NVIDIA CONFIDENTIAL. DO NOT DISTRIBUTE.
ANALOGIES
man is to woman as king is to queen
Man Blond Hair Blue Eyes Smile Looking Left Pointy Nose Top Right
- +
+ +
Bottom Left
+ + +
- +
Subtract Top Left
+
- Bottom Right
+
- +
+
Reproduction of the famous βking + woman - man = queenβ analogy on faces:
18 18
MAPPING IMAGES TO LATENT VECTORS
Transfer learning: from Discriminator to Encoder
19 19
IMAGE RECONSTRUCTIONS
Visualizing π» πΉ πππππ
20 20
ATTRIBUTES
The encoder πΉ may be used to calculate the latent vector for each attribute. For each ππ’π’π in ππ’π’π πππ£π’ππ‘ : π½ππ’π’π
+
= ππ ππ’π’π and π½ππ’π’π
β
= ππ ππ’π’π are sets of images w/wo the attribute π¨ ππ’π’π =
1 π½ππ’π’π
+
πΉ(ππ)
ππ β π½ππ’π’π
+
β
1 π½ππ’π’π
β
πΉ(ππ)
ππ β π½ππ’π’π
β
It is then straightforward to add or remove attributes from an image:
Calculating attribute vectors
From left to right: original image (OI); OI + βyoungβ attribute; OI - βblond hairβ + βblack hairβ; OI - βsmileβ; OI + βmaleβ + βbaldβ.
21 21
PLAYING WITH ATTRIBUTES
22 22
EXTRACTING ATTRIBUTES
β¦from portraits of illustrious people
23 23
DEGENERATOR
Getting the essence of your dataset
After convergence, stop updating the discriminator:
24 24
DATASET VISUALIZATION
Projecting latent vectors on a sphere
25 25