10
$\begingroup$

So I am currently studying Generative Adversarial Network and I read the paper by Goodfellow a few times now Generative Adversarial Nets and a few other papers in this field (DCGAN, CycleGAN, pix2pix, and a few others).

But I have been struggling with Figure 1 in this paper and somehow it does not seem to fit in my head!

enter image description here

This is what I currently understand:

  • The green line is the distribution we are trying to match.
  • The black line is the current distribution of the training image

But I don't really understand the blue line! Why is it sinus-like-form in (a) and why is it a straight line in (d)?

$\endgroup$
16
$\begingroup$

Let me try to clear things up a bit if I can. First of all, GANs are not made specifically for generating images, but all kinds of data. In fact the first paper, which you get your figure from, isn't referring to images.

In the figure you gave 3 curves:

  • The black dots. These are your training samples $x$. If you connect the dots you can form a line (I will refer to this as the black line even if it isn't visible in the figures). This is the data-generating distribution $p_x$, which is the theoretical distribution from where your data is sampled.
  • The green line. This is the distribution that your generator has learned, $p_g$. When training your discriminator you need real and fake samples. The real ones are the black dots, while the fake ones are sampled from the green distribution.
  • The blue line. This is the output of the discriminator, i.e. the probability that an image will be classified as real or fake.

Also the black $x$ horizontal line shows the range from which we can draw $x$ samples, while the black $z$ horizontal line shows the same thing with the latent variable $z$. When drawn these will follow their respective distributions (black and green lines).

Now on to what each figure tells us:

  • The first figure (a) shows how the distributions look before training. The generator doesn't produce realistic samples (i.e. the green line is far away from the black line) and the discriminator doesn't know how to discriminate properly (i.e. the blue line has a lot of fluctuations).

  • The second figure (b) is at a point where $D$ has learned to discriminate between the two types of samples (i.e. real and fake). The blue line now resembles a sigmoid. This is needed so that $G$ can have accurate feedback on how its samples fair.

  • The third figure (c) is at a point where $G$ is beginning to learn how to generate realistic samples. Note how the green line is closer to the black line now. Even though $D$ is also good (the blue line aligns with half of the distance between the two distributions), its job is much harder now.

  • The fourth figure (d) is at the end of training. $G$ can now produce fully-realistic samples (i.e. the green and black lines are one). Because of this $D$ can't discriminate any more, so it predicts randomly if an image is real or fake (i.e. $P(D) = 1/2$ everywhere)

$\endgroup$
  • 1
    $\begingroup$ Thanks for your answer. That was very helpfulI. But I still have some questions. (1) does the blue line go from 1-0 and does it reflect probability? Or what exactly is it? (2) Why is a sigmoid form what we want in (b)? (3) Do I understand it correctly that the blue line is in the middle when the black and green line intersect? (4) does the blue line describe one specific instance, like one specific photo? $\endgroup$ – Kalle Nov 8 at 18:39
  • 1
    $\begingroup$ (1), (2) and (3) The output of $D$ is essentially a sigmoid. It represents the probability of a sample being real or fake. A successful $D$ should "align" the sigmoid so that it separates the two distributions (i.e. the sigmoid is in the middle in the middle distance between the two distributions, think of it as a decision boundary). (4) for an image-generating GAN a real photo would be a black dot, i.e. one sample. Likewise, a fake image would be a dot drawn somewhere on the green line (in this figure they have the arrows below to show the fake samples). $\endgroup$ – Djib2011 Nov 8 at 19:04
  • 1
    $\begingroup$ Does the following make sense? (a) yes the blue line fluctuates, but aint it between 0.7-1. 0, which means that it classifies the data as fake? And at the right, it also fluctuates between 0.0-0.3 which means it classifies it as real? So does it matter that it fluctuates when the probability is higher then 0.5? (b) it now has a sigmoid form, but goes from 0.2-0.8 and not 0-1? So most of the black dots are classified as fake and some of them as real? And most of the green are classified as real and some of them as fake? So not perfect right? (c) not as good as b. (d) All are classified as 0.5. $\endgroup$ – Kalle Nov 9 at 13:18
  • $\begingroup$ (a) the fluctuation kind of matters because when training $D$ you aren't concerned about how many correct predictions it makes but its certainty. Likewise, $G$ aims at increasing the uncertainty of $D$. (b) yes that makes sense. If it identified all fake samples with a probability of 0, $G$'s loss would be zero and it wouldn't be able to train further. (c) the $D$ is not as good as (b) because $G$ got better. (d) correct $\endgroup$ – Djib2011 Nov 9 at 17:50
  • 1
    $\begingroup$ Thanks @Djib2011 :) $\endgroup$ – Kalle Nov 9 at 17:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.