What are GANs?

Ankita Choudhury
Analytics Vidhya
Published in
3 min readJun 30, 2021

GAN stands for Generative Adversarial Networks.

In 2014, Jan J Goodfellow, Jean Pouget-Abadie, Mehdi Mirza, David Warde, Sherjil Ozair, Bing Xu, Yoshua Bengio, and Aaron Corville published Generative Adversarial Networks paper. Yann LeCun referred to it as the coolest idea in deep learning in the last 20 years.

GANs are generally used to generate images. Converting grayscale images to coloured images, generating realistic human faces, and many other applications are among the most popular.

Before digging deeper into GANs, let’s see the difference between the Discriminative model and the Generative model.

The discriminative model learns to classify data points into respective classes by learning the optimal decision boundary that separates the classes. While the generative model learns to classify data points by learning the characteristics of each of the classes.

Consider an image classification task where we have to predict whether a given image is a dog or a cat. As shown in the figure below, the discriminative model finds the optimal decision boundary to distinguish between dog and cat, while generative models learn to distinguish between them by learning their characteristics.

Generative models learn the joint probability distribution, whereas discriminative models predict the labels based on the input. Examples of discriminative models are logistic regression, SVM and so on. Markov random fields and naive Bayes are two examples of generative models.

Let’s take a closer look at GANs now.

GANs consist of two components — Generator and Discriminator.

The generator learns the distribution of images in a dataset and generates new images. The discriminator performs a classification task on the generated image to predict whether the image is real or fake. Let’s understand this by considering the following scenario.

A policeman and a counterfeiter play a two-player game where one tries to defeat the other. The role of the counterfeiter is to make false money and fool the police. The police’s task is to determine if the money is real or fake. GANs works similarly. The generator is analogous to the counterfeiter whereas the discriminator is analogous to the police.

The generator component of GAN is basically a generative model that learns the distribution of the class. And the discriminator component is basically a discriminative model that learns the decision boundary of a class.

As shown in the below figure, we feed a random noise to the generator first. Then, it learns different characteristics of the images present in the dataset. After that, it converts the random noise into a new image similar to one in the training set, but not exactly the same as images in the training set. The image generated by the generator is called a fake image, and the images in the training set are called real images. Then, the real and fake images are fed to the discriminator to perform the classification task. It will predict the probability of the fake image being a real one. It returns 0 if the image is fake and 1 if the image is real.

The GAN works properly if the discriminator returns 1.

--

--