Answers.Body: <h3>What's the input to the Generator?</h3>
  <p>In the basic implementation of GANs, the Generator <strong>only</strong> takes in a vector of random variables. This might seem strange, but after training, the generator can transform this input noise into an image resembling those of the training set.</p>
  <h3>How does it work?</h3>
  <p>It is trained along with its counterpart the Discriminator, whose goal is to distinguish real images (i.e. the dataset's images) from fake ones (i.e. images produced by the Generator). The Generator's goal in training is to fool the Discriminator into thinking that its images are real.</p>
  <h3>Training process</h3>
  <p>In the beginning, where they are both untrained, they are both &quot;terrible&quot; at their respective tasks. The Generator can't produce anything resembling an image, but the Discriminator can't distinguish real from fake. As training progresses, the Discriminator starts identifying ways to distinguish the real images from the fake ones (i.e. patterns that appear in real images, but not in fake ones). The Generator, however, in its attempt to fool the Discriminator, starts producing those same patterns in its own images. After a while of both models becoming better at their respective tasks, we reach a point where the Generator can produce realistic images and the Discriminator is very good at distinguishing between real or fake.</p>
  <hr />
  <p>Edit as suggested from comment:</p>
  <p>A vector of random values is used as an input, so that the Generator can learn to generate <em>unique</em> outputs. In itself the Generator is deterministic, meaning that it has no internal sources of randomness. If we give it the same input vector twice, it will produce <strong>the same</strong> output both times. Thus, we feed the Generator with random values, so that it can learn to produce different outputs, depending on those values.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-01-17T18:05:27.800Z
Answers.Text: But you haven't explained how the generator works, as in the question. I.e. what kind of algorithm does the generator use to create a convincing dataset, and how does the "learning" work for that algorithm?
Answers.UserDisplayName: personjerry
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-01-18T01:12:22.923Z
Answers.Text: It's a neural network whose output has the same shape as the input. In a lot of cases it resembles an inverted discriminator (which is a typical binary classifier).
Answers.UserDisplayName: Djib2011
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-01-18T17:15:32.763Z
Answers.Text: @Djib2012 What do you mean by same shape? I will try to simplfy my question - if the fake image x* is this marix: [1,2,3], in the worse case it would take 10^3~ of iterations of generator-discriminator until I recieve the required x*. Since real images represented by larger matrix, it would be many many more than I described. Why wouldnt you insert as an input an example of real image x?
Answers.UserDisplayName: Shir K
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-01-18T17:17:42.633Z
Answers.Text: If your dataset has let's say RGB images (i.e. $3$ channels) with a resolution of $256 \times 256$, the Generator should take a vector of random numbers as its input and output a tensor of $256 \times 256 \times 3$ (its output should have the same shape as the input images).
Answers.UserDisplayName: Djib2011
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-01-18T17:19:41.627Z
Answers.Text: You  are thinking of it the wrong way. The generator doesn't search through all possible combinations of values so that it can produce an exact replica of the input images. It just tries to confuse the Discriminator. How does it do that? By mimicking the "patterns" that the Discriminator sees in real images when trying to distinguish them from fake ones.
Answers.UserDisplayName: Djib2011
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-12-10T01:46:05.970Z
Answers.Text: This answer does not really explain why the input to the generator should be a noise/random vector. It may be worth adding a few lines that attempt to address this from a theoretical point of view.
Answers.UserDisplayName: nbro
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-01-17T10:47:48.480Z
Answers.LastActivityDate: 2020-12-10T09:24:27.547Z
Answers.LastEditDate: 2020-12-10T09:24:27.547Z
Answers.UserDisplayName: Djib2011
Body: <p>After reading a lot of articles (for instance, this one - <a href="https://developers.google.com/machine-learning/gan/generator" rel="nofollow noreferrer">https://developers.google.com/machine-learning/gan/generator</a>), I've been wondering: how does the generator in GAN's work?</p>
  
  <p>What is the input to the generator? What is the meaning behind "input noise"?</p>
  
  <p>As I've read, the only input that the generator receives is a random noise, which is weird.</p>
  
  <p>If I would like to create a similar picture of <span class="math-container">$x$</span>, and put as an input a matrix of random numbers (noise) - it would take A LOT of training until I would get some sort of picture <span class="math-container">$x^*$</span>, that is similar to the source picture <span class="math-container">$x$</span>.</p>
  
  <p>The algorithm should receive some type of reference or a basic dataset (for instance, the set of <span class="math-container">$x$</span>'s) in order to start the generation of the fake image <span class="math-container">$x^*$</span>.</p>
  
Tags: <deep-learning><generative-adversarial-networks>
Title: How does the generator in GAN's work?
UserDisplayName: Shir K
ThreadText: # How does the generator in GAN's work?
  
  (Asked by: username_0 on 2020-01-17)
  
  After reading a lot of articles (for instance, this one - <https://developers.google.com/machine-learning/gan/generator>), I've been wondering: how does the generator in GAN's work?
  
  What is the input to the generator? What is the meaning behind "input noise"?
  
  As I've read, the only input that the generator receives is a random noise, which is weird.
  
  If I would like to create a similar picture of $x$, and put as an input a matrix of random numbers (noise) - it would take A LOT of training until I would get some sort of picture $x^\*$, that is similar to the source picture $x$.
  
  The algorithm should receive some type of reference or a basic dataset (for instance, the set of $x$'s) in order to start the generation of the fake image $x^\*$.
  
  **Tags:** deep-learning, generative-adversarial-networks
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2020-01-17. Score: 3 | Accepted answer
  
  ### What's the input to the Generator?
  
  In the basic implementation of GANs, the Generator **only** takes in a vector of random variables. This might seem strange, but after training, the generator can transform this input noise into an image resembling those of the training set.
  
  ### How does it work?
  
  It is trained along with its counterpart the Discriminator, whose goal is to distinguish real images (i.e. the dataset's images) from fake ones (i.e. images produced by the Generator). The Generator's goal in training is to fool the Discriminator into thinking that its images are real.
  
  ### Training process
  
  In the beginning, where they are both untrained, they are both "terrible" at their respective tasks. The Generator can't produce anything resembling an image, but the Discriminator can't distinguish real from fake. As training progresses, the Discriminator starts identifying ways to distinguish the real images from the fake ones (i.e. patterns that appear in real images, but not in fake ones). The Generator, however, in its attempt to fool the Discriminator, starts producing those same patterns in its own images. After a while of both models becoming better at their respective tasks, we reach a point where the Generator can produce realistic images and the Discriminator is very good at distinguishing between real or fake.
  
  ---
  
  Edit as suggested from comment:
  
  A vector of random values is used as an input, so that the Generator can learn to generate *unique* outputs. In itself the Generator is deterministic, meaning that it has no internal sources of randomness. If we give it the same input vector twice, it will produce **the same** output both times. Thus, we feed the Generator with random values, so that it can learn to produce different outputs, depending on those values.
  
  > **Comments:**
  > **username_2**: But you haven't explained how the generator works, as in the question. I.e. what kind of algorithm does the generator use to create a convincing dataset, and how does the "learning" work for that algorithm?  
  > **username_1**: It's a neural network whose output has the same shape as the input. In a lot of cases it resembles an inverted discriminator (which is a typical binary classifier).  
  > **username_0**: @Djib2012 What do you mean by same shape? I will try to simplfy my question - if the fake image x* is this marix: [1,2,3], in the worse case it would take 10^3~ of iterations of generator-discriminator until I recieve the required x*. Since real images represented by larger matrix, it would be many many more than I described. Why wouldnt you insert as an input an example of real image x?  
  > **username_1**: If your dataset has let's say RGB images (i.e. $3$ channels) with a resolution of $256 \times 256$, the Generator should take a vector of random numbers as its input and output a tensor of $256 \times 256 \times 3$ (its output should have the same shape as the input images).  
  > **username_1**: You  are thinking of it the wrong way. The generator doesn't search through all possible combinations of values so that it can produce an exact replica of the input images. It just tries to confuse the Discriminator. How does it do that? By mimicking the "patterns" that the Discriminator sees in real images when trying to distinguish them from fake ones.  
  > **username_3**: This answer does not really explain why the input to the generator should be a noise/random vector. It may be worth adding a few lines that attempt to address this from a theoretical point of view.  
  
  ---
  
  