Introduction to GANs (Generative Adversarial Networks)

Beneath Analytics
4 min readJan 13, 2021

What are Generative Adversarial Networks (GANs)?

Generative Adversarial Networks (GANs) are a powerful class of machine learning frameworks that use two types of competing neural networks in adversarial environment. The neural networks are generative and discriminative model that both run in competition with each other during the training phase. It was developed and introduced by Ian J. Goodfellow in 2014. GANs were developed as a solution against the disadvantage of misclassification by traditional neural networks upon the introduction of noise in the dataset.

Generative Vs. Discriminative Model

The entire GAN structure is built on these two types of neural network models: The generative Model and the Discriminative Model. In layman’s terms, we can say that Generative models learn everything in depth while Discriminative models learn differences between things as it is evident from the figure description below.

Generative Vs Discriminative Model representation (©Beneath Analytics)

Generative Model

As the name suggests, Generative models can generate new data instances. They can work with missing data values and often need fewer data to train as they are more biased because of their strong assumptions. Generative models have more applications besides classification, unlike the Discriminative Model. It learns the joint probability distribution p(x,y) and predicts the conditional probability with the help of the Bayes Theorem. Naïve Bayes, Bayesian Networks, and Hidden Markov models are commonly used, generative models.

Discriminative Model

These models discriminate between different kinds of data instances. It can peculiarly identify how a label can be associated with the instance by modeling the decision boundary between the classes. Discriminative Model learns the conditional probability distribution p(y|x). It requires more training data when compared to its counterpart model, the generative model. It is widely used for classification purposes only. Logistic Regression, Support Vector Machine, and Conditional Random Fields are popular discriminative models.

GAN Structure

Now, that we are aware of the basics of the Generator and Discriminator Model, we can look forward to the GAN Structure. A GAN has two players: a generator and a discriminator. A generator generates new instances of an object while the discriminator determines whether the new instance belongs to the actual dataset and penalizes the generator for producing improbable results. Let’s consider for example you have a dataset containing images of apples and would like to generate ‘fake’ apple data points. The role of the generator would be to generate the new apples while the discriminator’s goal is to determine images coming from the generator as fake apples.

As we can see from the conceptual GAN flow in the figure, the generator output is connected directly to the discriminator input. Training of the Generative Adversarial Networks occur in two phases: the Generator training and the Discriminator training. Both the models are kept constant while the other part is being trained, for instance Generator is kept constant (training set to false) when the Discriminator is in its training phase. It is also important to note that GAN convergence is hard to identify.

Graphical representation of GAN (©Beneath Analytics)

Generator produces the output from sampled random noise. Gradually, it learns to create fake data by incorporating feedback from the discriminator by backpropagation to obtain the gradients. These gradients are used to change the generator weights. It learns to make the discriminator classify its output as real. The discriminator’s training data comes from two sources: Real and fake data instances. It tries to distinguish real data from the data created by the generator. During the training process, weights and biases are adjusted through backpropagation until the discriminator learns to distinguish real images from fake images. During training, the discriminator just uses the discriminator loss and not the generator loss.

Application of GAN

There are many applications of Generative Adversarial Networks but are not limited to Predicting next frame in video, Increasing resolution of an image, Text-to-image generation using Stack GAN, Image-to-Image generation: generating real images from sketches, Generate realistic photographs of human faces, 3D Object generation and Clothing translation.

This blog was originally written by Riya Thakore. She is working as a Machine Learning Intern at Beneath Analytics Pvt Ltd. She is having expertise in building highly scalable and advanced level Machine learning models specifically GANs and Chatbots.

Be data-driven today! We are actively partnering with Marketing Agencies, IT/Non-IT Companies, and making their Analytics better day by day! Having a query where to start? Just send the brief of your analytics problem at info@beneath.co.in, also check our website at https://beneath.co.in and our expert will get in touch within 48 hours!

--

--

Beneath Analytics

An Artificial Intelligent company scaling businesses with help of Data Analytics and Machine Learning