What are GAN’s? An Introduction to Generative Adversarial Networks.

Original article was published on Artificial Intelligence on Medium

“Generative Adversarial Networks is the most interesting idea in the last ten years in machine learning”

-Yann LeCun, Director, Facebook A.I

Photo by Franck V. on Unsplash

Generative Adversarial Networks (GANs) are a class of AI algorithms used in unsupervised machine learning, implemented by a system of two neural networks contesting with each other in a zero-sum game framework. Generative modelling is an unsupervised learning task in machine learning that involves automatically discovering and learning the regularities or patterns in input data in such a way that the model can be used to generate or output new examples that plausibly could have been drawn from the original Dataset.

GANs are a clever way of training a generative model by framing the problem as a supervised learning problem with two sub-models: the generator model that we train to generate new examples, and the discriminator model that tries to classify examples as either real (from the domain) or fake (generated). The two models are trained together in a zero-sum game, adversarial, until the discriminator model is fooled about half the time, meaning the generator model is generating plausible examples.

The 2 neural network models are known as the Generator and the Discriminator models.

• The generator model generates samples by taking noise as input.

• The discriminator model receives samples from both the training data and the generator and has to be able to differentiate between the two sources.

In GANs, there is a generator and a discriminator. The Generator generates fake samples of data (be it an image, audio, etc.) and tries to fool the Discriminator. The Discriminator, on the other hand, tries to distinguish between the real and fake samples. The Generator and the Discriminator are both Neural Networks and they both run in competition with each other in the training phase. The steps are repeated several times and in this, the Generator and Discriminator get better and better in their respective jobs after each repetition.

The generator, generates new data instances, while the other, the discriminator, evaluates them for authenticity; i.e. the discriminator decides whether each instance of data that it reviews belongs to the actual training datasets or not.

So, basically, training a GAN has two parts:

Part 1: The Discriminator is trained while the Generator is idle. Discriminator is trained on real data and see if it can correctly predict them as real. Also, in this phase, the Discriminator is also trained on the fake generated data from the Generator and see if it can correctly predict them as fake.

Part 2: The Generator is trained while the Discriminator is idle. After the Discriminator is trained by the generated fake data of the Generator, we can get its predictions and use the results for training the Generator and get better from the previous state to try and fool the Discriminator.

This GAN algorithms are based on the principle for Artificial intelligence of MIN-MAX algorithms where discriminator tries to minimize the reward and the generator is trying to minimize the discriminator’s reward or tries to maximize its loss.

Steps for a GAN: –

1)Define the problem– Do you want to generate fake images or fake text. Collect data here.

2)Define architecture of GAN– defines the architecture for the GAN which may include which type of neural network are we going to use.

3)Train the discriminator– Get the data you want to generate fake on and train the discriminator to correctly predict them as real. Here value n can be any natural number between 1 and infinity.

4) Generate fake inputs for generator and train discriminator on fake data. Get generated data and let the discriminator correctly predict them as fake.

5) Train generator with the output of discriminator. Now when the discriminator is trained, you can get its predictions and use it as an objective for training the generator. Train the generator to fool the discriminator.

6) Repeat step 3 to step 5 for a few epochs.

7) Check if the fake data manually if it seems legit. If it seems appropriate, stop training, else go to step 3. This is a bit of a manual task, as hand evaluating the data is the best way to check the fakeness. When this step is over, you can evaluate whether the GAN is performing well enough.

A Typical Model for Generative Adversarial Network.

Applications of GAN:-

1) Text to image

2) Image to image generation

3) Photos to emojis

4) Image generation

5) Photo in painting

Research Papers you must read if you want to know more:-

  1. Generative Adversarial Network by Ian Goodfellow et al
a) MNIST b) TFD c) CIFAR-10 (fully connected model) d) CIFAR-10 (convolutional discriminator and “deconvolutional” generator) from Goodfellow et al.

2. BigGAN — Brock et al. (2019)

sComparing classes of Generated Dog images in the paper BigGan by Brock et al.

3. Style GAN by Tero Karras et al

Two set of images and the amalgamation of the images in the matrix from the paper Style GAN

4. Unpaired Image-to-Image Translation using Cycle-Consistent Adversarial Networks by Jun-Yan Zhu et al

Automatically “translate” an image from one into the other and vice versa from Jun Yan Zhu et al

5. Face Ageing with GAN by Grigory Antipov et al

Origianl Image Vs reconstructed Image from Face Ageing with GAN from Grigory Antipov et al

6. UNSUPERVISED CROSS-DOMAIN IMAGE GENERATION by Yaniv Taigman et al

Even columns contains input while odd columns contains output for the Generated Images using GANs in the paper UNSUPERVISED CROSS-DOMAIN IMAGE GENERATION by Yaniv Taigman et al

7. Generative Adversarial Text to Image Synthesis by Scott Reed et al

from Generative Adversarial Text to Image Synthesis by Scott Reed et al proposed Text to image synthesis

8. Towards the Automatic Anime Characters Creation with Generative Adversarial Networks by Yanghua Jin et al.

Sample images generated form the proposed method Yanghua Jin et al

9.Image-to-Image Translation with Conditional Adversarial Networks by Phillip Isola et al.

Image Translation from input image to corresponding image, from,Image-to-Image Translation with Conditional Adversarial Networks by Phillip Isola et al .

10. Learning a Probabilistic Latent Space of Object Shapes via 3D Generative-Adversarial Modeling by Jiajun Wu et al.

Source:- Learning a Probabilistic Latent Space of Object Shapes via 3D Generative-Adversarial Modeling. by Jiajun Wu et al.