Vous êtes sur la page 1sur 15

Generative Adversarial Net(GAN)

Adarsh k
SC17M001
Machine learning And Computing
4/13/2018 1
 Main attraction :GANs are extremely good at
generating realistic, believable samples like
images.
 Why do we need to generate samples?
 Applications
 1)Reinforcement Learning-self driving car
 In dangerous and difficult situations we want
it to behave reliably. To learn from experience
we don't have much data. To simulate such
environments GANs could be used.
4/13/2018 2
 Image to Image Translation.

 NLP-Generate new content like article,videos


 Image Enhancement
 Generating Art
4/13/2018 3
Block Diagram

4/13/2018 4
 GANs consist of 2 neural networks(Generator
and Discriminator).
 Generator tries to fool the discriminator by
generating realistic images
 While discriminator tries to discriminate
between real and fake data

4/13/2018 5
 consider an image classifier D designed to identify a
series of images depicting various animals.
 Now consider an adversary (G) with the mission to
fool D using carefully crafted images that look almost
right but not quite.
 This is done by picking a legitimate sample randomly
from training set (latent space) and synthesizing a
new image by randomly altering its features (by
adding random noise).
 As an example, G can fetch the image of a cat and can
add an extra eye to the image converting it to a false
sample. The result is an image very similar to a normal
cat with the exception of the number of eye.
4/13/2018 6
 During training, D is presented with a random mix of
legitimate images from training data as well as fake
images generated by G. Its task is to identify correct
and fake inputs.
 Based on the outcome, both machines try to fine-tune
their parameters and become better in what they do. If
D makes the right prediction, G updates its parameters
in order to generate better fake samples to fool D.
 If D’s prediction is incorrect, it tries to learn from its
mistake to avoid similar mistakes in the future. The
reward for net D is the number of right predictions and
the reward for G is the number D’s errors.
 This process continues until an equilibrium is
established and D’s training is optimized.
4/13/2018 7
 We have 2 neural network should we use 2
cost functions? why/why not?
 Consider discriminator alone
 Classify an image as real or fake (binary
classification)
 The cost functions is

4/13/2018 8
Summing over all data points
N N
  t log[ f ( x)]   (1  ti ) log( 1  f ( xi )
i 1 i 1

In particular xi only come from 2 sources either xi ~ Pdata or


xi ~ G(Z) and we also want exactly half of these data
points to come from these 2 sources equally and to take
into account probabilistic nature of data points we replace
sum with expectations, which results in

4/13/2018 9
 So far we have specified the cost function for
only the discriminator. A complete
specification of the game requires that we
specify a cost function also for the generator.
 Aim of the generator is to generate realistic
samples to fool discriminator.
 The generator and discriminator are doing 2
opposite things, thus

4/13/2018 10
 In game theory this is called a zero sum game
because sum of all players cost is zero.
 The optimal solution is obtained at Nash
equilibrium. Thus combining both generator
and discriminators cost we get overall cost
function as

4/13/2018 11
.

Proof:
The training criterion for the discriminator D, given any
generator G, is to maximize the quantity V (G,D)

This is of the form A log(x) +B log(1-x),taking derivative


and equating to zero
4/13/2018 12
Once the generator is trained to be optimal,
Pg gets very close to Pr, when Pg=Pr . D*(x) = 0.5
The value of loss function at optimal point will be

4/13/2018 13
Allows us to compare 2 probability distributions
If 2 probability distributions are exactly same then
we get KL divergence to be zero p=q.
Jensen Shannon Divergence
It is a symmetrised and smooth version of KL ,

4/13/2018 14
Essentially the loss function of GAN quantifies the similarity
between the generative data distribution pg and the real sample
distribution pr by JS divergence when the discriminator is optimal.
The best G* that replicates the real data distribution leads to the
minimum L(G∗,D∗)=−2log2L(G∗,D∗)=−2log2
4/13/2018 15

Vous aimerez peut-être aussi