Lesson 8 of 11By Avijeet Biswal
Last updated on Mar 12, 20214549Deep Learning has found numerous applications in the industries. Neural networks are being widely used in almost every business sector, such as healthcare, finance, and e-commerce. These neural networks help solve business problems. In this article, we’ll learn about What GANs are.
In this article, we learn the following topics:
Generative Adversarial Networks (GANs) were introduced in 2014 by Ian J. Goodfellow and co-authors. GANs perform unsupervised learning tasks in machine learning. It consists of 2 models that automatically discover and learn the patterns in input data.
The two models are known as Generator and Discriminator.
They compete with each other to scrutinize, capture, and replicate the variations within a dataset. GANs can be used to generate new examples that plausibly could have been drawn from the original dataset.
Shown below is an example of a GAN. There is a database that has real 100 rupee notes. The generator neural network generates fake 100 rupee notes. The discriminator network will help identify the real and fake notes.
A Generator in GANs is a neural network that creates fake data to be trained on the discriminator. It learns to generate plausible data. The generated examples/instances become negative training examples for the discriminator. It takes a fixed-length random vector carrying noise as input and generates a sample.
The main aim of the Generator is to make the discriminator classify its output as real. The part of the GAN that trains the Generator includes:
The backpropagation method is used to adjust each weight in the right direction by calculating the weight's impact on the output. It is also used to obtain gradients and these gradients can help change the generator weights.
Let’s see the next topic in this article on what GANs are, i.e., a Discriminator.
The Discriminator is a neural network that identifies real data from the fake data created by the Generator. The discriminator's training data comes from different two sources:
While training the discriminator, it connects to two loss functions. During discriminator training, the discriminator ignores the generator loss and just uses the discriminator loss.
In the process of training the discriminator, the discriminator classifies both real data and fake data from the generator. The discriminator loss penalizes the discriminator for misclassifying a real data instance as fake or a fake data instance as real.
The discriminator updates its weights through backpropagation from the discriminator loss through the discriminator network.
Now, let’s learn how GANs work in this article on ‘What are GANs’.
GANs consists of two neural networks. There is a Generator G(x) and a Discriminator D(x). Both of them play an adversarial game. The generator's aim is to fool the discriminator by producing data that are similar to those in the training set. The discriminator will try not to be fooled by identifying fake data from real data. Both of them work simultaneously to learn and train complex data like audio, video, or image files.
The Generator network takes a sample and generates a fake sample of data. The Generator is trained to increase the Discriminator network's probability of making mistakes.
Below is an example of a GAN trying to identify if the 100 rupee notes are real or fake. So, first, a noise vector or the input vector is fed to the Generator network. The generator creates fake 100 rupee notes. The real images of 100 rupee notes stored in a database are passed to the discriminator along with the fake notes. The Discriminator then identifies the notes as classifying them as real or fake.
We train the model, calculate the loss function at the end of the discriminator network, and backpropagate the loss into both discriminator and generator models.
The mathematical equation for training a GAN can be represented as:
Here,
G = Generator
D = Discriminator
Pdata(x) = distribution of real data
p(z) = distribution of generator
x = sample from Pdata(x)
z = sample from P(z)
D(x) = Discriminator network
G(z) = Generator network
With this understanding, let’s learn the next topic on what are GANs, i.e. training a GAN.
Let us now look at the different types of GANs.
Vanilla GANs: Vanilla GANs have a min-max optimization formulation where the Discriminator is a binary classifier and uses sigmoid cross-entropy loss during optimization. The Generator and the Discriminator in Vanilla GANs are multi-layer perceptrons. The algorithm tries to optimize the mathematical equation using stochastic gradient descent.
Deep Convolutional GANs (DCGANs): DCGANs support convolution neural networks instead of vanilla neural networks at both Discriminator and Generator. They are more stable and generate better quality images. The Generator is a set of convolution layers with fractional-strided convolutions or transpose convolutions, so it up-samples the input image at every convolutional layer. The discriminator is a set of convolution layers with strided convolutions, so it down-samples the input image at every convolution layer.
Conditional GANs: Vanilla GANs can be extended into Conditional models by using extra-label information to generate better results. In CGAN, an additional parameter ‘y’ is added to the Generator for generating the corresponding data. Labels are fed as input to the Discriminator to help distinguish the real data from the fake generated data.
Super Resolution GANs: SRGANs use deep neural networks along with an adversarial network to produce higher resolution images. SRGANs generate a photorealistic high-resolution image when given a low-resolution image.
Now that we have understood what are GANs, let’s look at some of the important applications of GANs.
Below is an example of a text to image translation using GANs for a bird with a black head, yellow body, and a short break.
After reading this article, you would have learned the basics of GANs and how it works. You understood about generators and discriminators. You saw how GANs can help identify real and fake images. You looked at the training process of the Generative Adversarial Network and the applications of GANs.
Do you have questions related to this article on What are GANs? If you have, then please put them in the comments section of this article. Our team will help you solve your queries.
Avijeet is a Senior Research Analyst at Simplilearn. Passionate about Data Analytics, Machine Learning, and Deep Learning, Avijeet is also interested in politics, cricket, and football.
Everything You Need to Know About Microsoft Azure Virtual Network
Getting Started with Google Display Network: The Ultimate Beginner’s Guide
Launch a career in IT Hardware and Networking
What is Neural Network: Overview, Applications, and Advantages
Introduction To Docker Networking: Advantages and Working
Free eBook: Top 25 Interview Questions and Answers: Quality Management