This post is Grassroots, meaning a reader posted it directly. If you see an issue with it, contact an editor.
If you’d like to post a Grassroots post, click here!

0.1
April 30, 2020

Understanding and Building Generative Adversarial Networks (Gans) For the Website

For many years, machines have tried to identify and recognize the photos that they see. But the breakthrough finally came in 2013 when machines got to the ‘human level.’ Normally, systems of machine learning provide simple output from the more complex input which they get. But in the year 2014, Ian Goodfellow and some others were able to develop a new system for machine learning by using the game theory and turning the weakness of machine learning generally to machine learning advantage. The reason why this new machine learning is very important is that it is more advanced than the previous ones. Normally, what has been known for years is that, machine learning system takes from complex input to give simple output via their neural output. However, GAN, generative adversarial networks actually do the opposite of what the other machine learning systems do. It takes in simple input and releases complex output afterward.

Why were GANs created and what are they?

Generative adversarial networks are neural networks that are able to predict and classify things. The reason that they were created is to fulfill the goal of AI researchers who wanted to instill human nature into these neural networks and giving them the ability to create and produce things instead of just seeing and learning things. They finally achieved this goal when Ian Goodfellow was able to successfully invent this group of Deep Learning Modal that are able to do this.

How do GANs work?

There are two neural networks is the GAN networks. The “G” stands for Generator, while the “D” is Discriminator. How it works is that the generator generates the images, then the discriminator sees the images and then informs the generator about the level of realness the images generated are.

Generator

In the first phase, the generator models bring in input from random noise signals and from it generates a noisy and random image which is the output. But gradually, it works with the discriminator to start to generate a particular class of images that appears very real.

Discriminator

The discriminator is the generator’s opponent. It is the part that is fed with the images that are generated as well as another particular class of image too. This is how it is able to tell how real images look and then inform the generator about the level of the realness of the generated image.

At some point, the discriminator will not be able to tell if the image that was generated is a fake or real image. It is at this point that we see a particular class of images that did not exist before being generated by the generator. This class of image is the one that the discriminator was trained with.

Applications of GANs

  • To give super-resolution

  • To assist the artists

  • For element abstraction

    The Training Generative Model of Generative Adversarial Network

    If you are trying to generate the image of a dog with the GANs, it is possible to generate random vectors in a particular dimensional vector space following the probability distribution of the dog. We can make use of the transform method for modeling the transform function using a neural network.

    But then, we can also optimize the network in a way that expresses the appropriate transform function. And for this to happen, there are 2 training methods that can be used: the direct training method and the indirect training method.

    The direct training method compares both probability distributions that were generated and the true ones and backpropagating their error/difference through the network. That is the idea ruling the GMN (Generative Matching Networks).

    The indirect training method does not compare both generated and true distributions. The generative network is instead trained by allowing both the generated and true distributions to undergo a chosen downstream task such that when the generative network is optimized in comparison to the downstream task, this process will enforce the closeness of the distribution that’s generated to the true one. This is the idea behind GANs (Generative Adversarial Networks).

    Using samples to compare two probability distributions

    The thinking behind GMNs is for the generative network to be trained to directly compare the true distribution and the generated distribution. But we are unable to explicitly express the true probability distribution of the dog (we used in our example). We can as well claim that the distribution that was generated is very complex, even too complex for explicit expression. So, it is impossible for us to make comparisons on the basis of explicit expressions. Regardless, if we somehow are able to compare the distributions of probability on the basis of samples, it can be used in training the network.

    However, if we have a way to compare probability distributions based on samples, we can use it to train the network. Indeed, we have a sample of true data and we can, at each iteration of the training process, produce a sample of generated data.

    In theory, any similarity measure that can use samples to effectively compare two distributions should be mentioned, particularly the MMD approach (Maximum Mean Discrepancy). This approach defines the distance between that exists between two distributions of probability that can be estimated on the basis of these distribution samples.

    Backpropagating the matching error of the distribution

    The training process of a generative network can be defined in GMNs once it is possible for us to compare the distributions on the basis of samples. If the input is the uniform probability distribution, with a random variable, the probability distribution that we expect to be the output generated is the “probability distribution of the dog.” So, the idea behind GMNs is the optimization of the networks by repetition in carrying out the following steps:

    • Generate uniform inputs

    • Take the input through the network, then gather the outputs that it generates.

    • Compare the real probability distribution of the dog and the one that was generated on the basis of the available samples.

    • Make use of backpropagation to reduce the distance between the generated distributions and the true distributions.

Indirect Generative Adversarial Networks Training Methods

The direct training method made a direct comparison between the true distribution and the generated distribution to train the generative network. The ideas of GANs looks to replace direct comparison with an indirect comparison of the two distributions taking the form of the downstream task. So, training the generative network is such that it forces the distribution that was generated to be closer to the original distribution.

The GANs downstream task is a discrimination task between the generated and the true samples. It can also be called the non-discrimination task because the idea is so that any existing discrimination between them fails and falls as much as it can. So, there is a discriminator in the GAN architecture that takes both samples of both generated data and true data and classifies them as much as it can.

(A graph illustrating the concept of direct training method: https://towardsdatascience.com/understanding-generative-adversarial-networks-gans-cd6e4651a29 )

The ideal case: a discriminator and a perfect generator

With a simple 1D example, we can easily understand why we will get the same result when a generator is trained to deceive a discriminator, and also when the generator is trained directly to match the distribution target. We often forget that discriminator and generator are both represented and are considered abstract notions. Both of them are also supposedly “perfect” because they are not restricted by any model.

If there is a true distribution, and what we want is a generator sampling from the distribution of this probability. The direct training method will be to iteratively adjust the generator in order to correct the error or difference between the generated distribution and the true distribution.

We should also know that if the process of optimization is perfect, the distribution that is generated should exactly match with the true distribution.

For the indirect method, you have to consider a discriminator. This discriminator would know exactly what the generated distribution and the true distribution are and, on the basis of this information, can predict a generated or true class for any point as well. If the 2 distributions are very far apart, the classification of the discriminator is easier and there is also a higher degree of confidence. If we are looking to deceive the discriminator, the generated distribution has to be very close to the original distribution. This will give the discriminator a high difficulty in predicting the class that the distributions will have equal points. In this case, the chances for each point to be generated truly are equal and the discriminator does not have a choice but to be true to everyone in two cases averagely.

Conclusion

GANs are the next phase of machine learning. From giving simple output, machine learning has developed into taking in simple input and giving more complex output, thereby, opening a new world of possibilities.

Leave a Thoughtful Comment
X

Read 0 comments and reply

Top Contributors Latest

Dorothea Oppelland  |  Contribution: 120