Python Programming (136 Blogs) Become a Certified Professional
AWS Global Infrastructure

Data Science

Topics Covered
  • Business Analytics with R (26 Blogs)
  • Data Science (20 Blogs)
  • Mastering Python (83 Blogs)
  • Decision Tree Modeling Using R (1 Blogs)
SEE MORE

What Are GANs? How and why you should use them!

Published on Feb 14,2020 2.6K Views

7 / 8 Blog from Unsupervised Learning

Generative Adversarial Networks or GANs are a generative modeling approach using Deep Learning to train the model in a clever manner to generate data by using the sub-model approach. In this article, we will try to understand “What Are GANs” in detail. The following topics are covered in this article:

What are Generative Models?

Generative models are nothing but those models that use an Unsupervised Learning approach. In a generative model, there are samples in the data i.e input variables X, but it lacks the output variable Y. We use only the input variables to train the generative model and it recognizes patterns from the input variables to generate an output that is unknown and based on the training data only.

In Supervised Learning, we are more aligned towards creating predictive models from the input variables, this type of modeling is known as discriminative modeling. In a classification problem, the model has to discriminate as to which class the example belongs to. On the other hand, unsupervised models are used to create or generate new examples in the input distribution.

To define generative models in layman’s terms we can say, generative models, are able to generate new examples from the sample that are not only similar to other examples but are indistinguishable as well.

The most common example of a generative model is a Naive Bayes Classifier which is more often used as a discriminative model. Other examples of generative models include Gaussian Mixture Model and a rather modern example that is General Adversarial Networks. Let us try to understand What Are GANs?

What Are Generative Adversarial Network?

Generative Adversarial Networks or GANs are a deep-learning-based generative model that is used for Unsupervised Learning. It is basically a system where two competing Neural Networks compete with each other to create or generate variations in the data.

It was first described in a paper in 2014 by Ian Goodfellow and a standardized and much stable model theory was proposed by Alec Radford in 2016 which is known as DCGAN (Deep Convolutional General Adversarial Networks). Most of the GANs today in existence use DCGAN architecture.

The GANs architecture consists of two sub-models known as the Generator model and the Discriminator Model. Let us try to understand how GANs actually work.

How Does It work?

To understand how GANs work, let’s break it down.

  • Generative – It means that the model follows the Unsupervised Learning approach and is a generative model.
  • Adversarial – The model is trained in an adversarial setting
  • Network – For the training of the model, uses the neural networks as Artificial intelligence algorithms.

In GANs, there is a Generator network that takes a sample and generates a sample of data, and after this, the Discriminator network decides whether the data is generated or taken from the real sample using a binary Classification problem with the help of a sigmoid function that gives the output in the range 0 to 1.

flowchart - what are gnas - edureka

The generative model analyzes the distribution of the data in such a way that after the training phase, the probability of the discriminator making a mistake maximizes. And the Discriminator, on the other hand, is based on a model that will estimate the probability that the sample is coming from the real data and not the generator.

The whole process can be formalized in a mathematical formula given below.

In the above formula:

G = Generator

D = Discriminator

Pdata(x) = Distribution of real data

Pdata(z) = Distributor of generator

x = sample from real data

z = sample from generator

D(x) = Discriminator Network

G(z) = Generator Network

Now comes the training part for a GAN, which can be further divided into 2 parts which are done sequentially.

How To Train A GAN?

Part 1:

Train the discriminator and freeze the generator, which means the training set for the generator is turned as False and the network will only do the forward pass and no back-propagation will be applied.

Basically the discriminator is trained with the real data and checks if it can predict them correctly, and the same with the fake data to identify them as fake.

phase 1 training - what are gans - edureka

Part 2: 

Train the generator and freeze the discriminator. In this phase, we get the results from the first phase and can use them to make better from the previous state to try and fool the discriminator better.

phase 2 training - what are gans - edureka

Steps For Training

  1. Define The Problem – define the problem and collect data.
  2. Choose Architecture Of GAN – Depending on your problem choose how your GAN should look like.
  3. Train Discriminator On Real Data – Train the discriminator with real data to predict them as real for n number of times.
  4. Generate Fake Inputs For Generator –  Generate fake samples from the generator
  5. Train Discriminator On Fake Data – Train the discriminator to predict the generated data as fake.
  6. Train Generator With The Output Of Discriminator – After getting the discriminator predictions, train the generator to fool the discriminator

Challenges Of Generative Adversarial Network

The concept of GANs is rather fascinating but there are a lot of setbacks that can cause a lot of hindrance in its path. Some of the major challenges faced by GANs are:

  1. Stability is required between the discriminator and the generator otherwise the whole network would just fall. In case, if the Discriminator is too powerful, the generator will fail to train altogether. And if the network is too lenient, any image would be generated making the network useless.
  2. GANs fail miserably in determining the positioning of the objects in terms of how many times the object should occur at that location.
  3. 3-D perspective troubles GANs as it is not able to understand perspective, it will often give a flat image for a 3-d object.
  4. GANs have a problem understanding the global objects. It cannot differentiate or understand a holistic structure.
  5. Newer types of GANs are more advanced and are expected to overcome these shortcomings altogether.

Generative Adversarial Network Applications

The following are a few applications of GANs.

Prediction Of Next Frame In A Video 

The prediction of future events in a video frame is made possible with the help of GANs. DVD-GAN or Dual Video Discriminator GAN can generate 256×256 videos of notable fidelity up to 48 frames in length. This can be used for various purposes including surveillance in which we can determine the activities in a frame that gets distorted due to other factors like rain, dust, smoke, etc.

gans applications - what are gans - edureka

Text to Image Generation

Object-driven attentive GAN(obj-GAN), performs the text-to-image synthesis in two steps. Generating the semantic layout is the initial step and then generating the image by synthesizing the image by using a de-convolutional image generator is the final step.

gans applications - what are gans - edureka

This could be used intensively to generate images by understanding the captions, layouts and refine details by synthesizing the words. There is another study about the storyGANs that can synthesize the whole storyboards from mere paragraphs.

Enhancing The Resolution of an Image

Super-resolution generative adversarial network or SRGAN is a GAN that can generate the super-resolution images from low-resolution images with finer details and better quality.

gans applications - what are gans - edureka

The applications can be immense, imagine a higher quality image with finer details generated from a low-resolution image. The amount of help it would produce to identify details in low-resolution images can be used for wider purposes including surveillance, documentation, security, detecting patterns, etc.

Image To Image Translation

Pix2Pix GAN is a model designed for general purpose image-image-translation.

gans applications - what are gans - edureka

Interactive Image Generation

GANs can be used to generate interactive images as well, Computer Science and artificial intelligence laboratory(CSAIL) has developed a GAN that can generate 3-D models with realistic lighting and reflections enabled by the shape and texture editing.

More recently, researchers have come up with a model that can synthesize a reenacted face animated by a person’s movement while preserving the appearance of the face at the same time.

gans applications - what are gans - edureka

This brings us to the end of this article where we have learned ‘What Are GANs”. I hope you are clear with all that has been shared with you in this tutorial.

If you found this article on “What Are GANs” relevant, check out the Edureka Certification Training for Machine Learning Using Python, a trusted online learning company with a network of more than 250,000 satisfied learners spread across the globe.

We are here to help you with every step on your journey and come up with a curriculum that is designed for students and professionals who want to be a Python developer. The course is designed to give you a head start into Python programming and train you for both core and advanced Python concepts along with various Python frameworks like Django.

If you come across any questions, feel free to ask all your questions in the comments section of “What Are GANs” and our team will be glad to answer.

Upcoming Batches For Python Programming Certification Course
Course NameDateDetails
Python Programming Certification Course

Class Starts on 23rd March,2024

23rd March

SAT&SUN (Weekend Batch)
View Details
Python Programming Certification Course

Class Starts on 20th April,2024

20th April

SAT&SUN (Weekend Batch)
View Details
Comments
0 Comments

Join the discussion

Browse Categories

webinar REGISTER FOR FREE WEBINAR
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP

Subscribe to our Newsletter, and get personalized recommendations.

image not found!
image not found!

What Are GANs? How and why you should use them!

edureka.co