Getting started with Generative Adversarial Networks(GANs)
Deep learning algorithms have come a long way in the last few decades which is due to the powerful processors and abundance of data. Discriminative models have done remarkably well in all the AI tasks. Generative models on the other hand wasn't able to make a mark till the arrival of Generative Adversarial Networks. It was in 2014, when Ian Goodfellow published a paper named Generative Adversarial Networks, and since then there was no turning back. The Facebook's director of AI, Yann LeCun called GANs, “the most interesting idea in the last 10 years in ML.”
Discriminative vs Generative Algorithms
Discriminative algorithms learns the features of the input data and try to predict a class probability out of it. Given an image, the model will predict whether it is a dog or not. Mathematically, the label is termed as y, while the features are termed as x. We need to find out basically p(y|x), which is given x, the probability of y.
The discriminative algorithms basically tries to map the features to labels, which means it predict the labels. In contrary to this, generative algorithms tries to map labels to features which means given a label, it tries to predict the feature.
Given the image is of a dog, it finds out what features the image can have. So a discriminative algorithm tries to find p(x|y).
What is Generative Adversarial Networks?
Generative Adversarial Networks are generative networks, very good at synthesising new data which is very similar to the real data. It consists of two neural networks - one the generator and another is the discriminator. The generator synthesises new data and the discriminator finds out whether the data is fake or real.
The generator is intialized with a random distribution(noise) and it creates a synthetic data out of it. This data is fed into the discriminator along with a stream of real data. The discriminator compares both images and give out a prediction.
GANs can be both good and bad depending on the purpose you are using it for. The networks can easily learn any distribution and mimic it. They can be used in various domains including - video, audio, image. They can be used for image to image translations and video synthesis. Deepfake is an usecase in GANs which can be used as a exploitation tool.
The goal of generator is to create synthetic data in such a way that the discriminator is not able to figure out that it is fake. While the goal of the discriminator is to classify the data coming out of generator as fake. In the process, both become good at what they are doing.
To summarize, here are the steps it follows -
The generator creates synthetic data from a noise.
The data generator from the generator is fed into the discriminator along with real data(ground truth data).
The discriminator checks the real and the fake images and returns a probability.
Fact - GAN is so powerful that Christie’s sold a portrait that was being generated by GAN for a whopping $432,000.
Training process of GANs
Now, training GANs involves training both the generator and the discriminator. When the network starts training, generator creates fake data and the discriminator is able to easily detect that it is fake.
As the training continues the generator gets better at generating data which resembles real data to fool the discriminator.
Now, if your training goes well, the generator will be able to produce data which looks similar to real data and the discriminator is not able to figure that out.
So, you can see how GAN network synthesises data which is very similar to real data.
In the next section, we will do a hands on with Generative Adversarial Network where we will train a model and visualize the results. So, stay tuned for that.