You are on page 1of 19

All Courses What do you want to learn?

Log in

AI & Machine Learning Tutorials Articles Ebooks Free Practice Tests On-demand Webinars Live Webinars

Home Resources AI & Machine Learning Deep Learning Tutorial for Beginners What are Generative Adversarial Networks (GANs)

What are Generative Adversarial Networks (GANs)


Lesson 15 of 32 By Avijeet Biswal

Last updated on Feb 20, 2023 76890


The Best Introduction to What GANs Are
Table of Contents
What are Generative Adversarial Networks?

What is a Generator?

What is a Discriminator?

How Do GANs Work?

Steps for Training GAN

View More
Previous Next

Tutorial Playlist
Deep 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.

Your AI/ML Career is Just


Around The Corner!
AI Engineer Master's Program

EXPLORE PROGRAM

What are Generative Adversarial Networks?

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.
What is a Generator?

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:
noisy input vector

generator network, which transforms the random input into a data instance

discriminator network, which classifies the generated data

generator loss, which penalizes the Generator for failing to dolt the discriminator

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.

Your AI/ML Career is Just


Around The Corner!
AI Engineer Master's Program
EXPLORE PROGRAM

What is 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:

The real data instances, such as real pictures of birds, humans, currency notes, etc., are used by the Discriminator as
positive samples during training.

The fake data instances created by the Generator are used as negative examples during the training process.

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’.

How Do GANs Work?

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.
Mathematical Equation
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.

Your AI/ML Career is Just


Around The Corner!
AI Engineer Master's Program Your AI/ML Career is Just Around The Corner!
EXPLORE PROGRAM

Steps for Training GAN

Define the problem

Choose the architecture of GAN

Train discriminator on real data

Generate fake inputs for the generator

Train discriminator on fake data

Train generator with the output of the discriminator

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.
L b l f d i t t th Di i i t t h l di ti i h th ld t f th f k t dd t
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.

Your AI/ML Career is Just


Around The Corner!
AI Engineer Master's Program Your AI/ML Career is Just Around The Corner!

EXPLORE PROGRAM

Application of GANs

With the help of DCGANs, you can train images of cartoon characters for generating faces of anime characters as
well as Pokemon characters.

GANs can be trained on the images of humans to generate realistic faces. The faces that you see below have been
generated using GANs and do not exist in reality.

GANs can build realistic images from textual descriptions of objects like birds, humans, and other animals. We input
a sentence and generate multiple images fitting the description
a sentence and generate multiple images fitting the description.

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.

Conclusion

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.

Your AI/ML Career is Just


Around The Corner!
AI Engineer Master's Program
Your AI/ML Career is Just Around The Corner!

EXPLORE PROGRAM

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.

Find our Post Graduate Program in AI and Machine Learning Online Bootcamp
in top cities:
Name Date Place

Post Graduate Program in AI and Machine Cohort starts on 5th Jan 2024, Your View
Learning Weekend batch City Details

Post Graduate Program in AI and Machine Cohort starts on 8th Jan 2024, Your View
Learning Weekend batch City Details

Post Graduate Program in AI and Machine Cohort starts on 17th Jan 2024, Your View
Learning Weekend batch City Details

About the Author

Avijeet Biswal

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.

View More

Recommended Programs
Post Graduate Program in AI and
Lifetime
Machine Learning
Access*
2742 Learners

Caltech AI & Machine Learning Bootcamp Lifetime


Access*
991 Learners

Caltech Post Graduate Program in AI and


Lifetime
Machine Learning
Access*
1114 Learners

*Lifetime access to high-quality, self-paced e-learning content.

Explore Category

Recommended Resources
The Best Introduction Getting Started with List of Generative
to What GANs Are - Google Display Adversarial Networks
Remo… Networ… A…

Tutorial Ebook Article


Follow us! Company Work with us Discover Learn On the Go!

About us Become an Skillup


Refer and Earn Get the Android App
instructor
Careers Skillup Sitemap
Blog as guest
Newsroom Resources Get the iOS App
Alumni speak RSS feed
Grievance redressal City Sitemap
Contact us For Businesses
Our Locations Corporate training

Partners
Digital
Transformation
Trending Post Graduate Programs

Artificial Intelligence Course | Cloud Computing Certification Course | Full Stack Web Development Course | PG in Data Science |
MS in Artificial Intelligence | Product Management Certification Course | Blockchain Course | Machine Learning Course | Cyber
Security Course in India | Project Management Certification Course | Lean Six Sigma Certification Course | Data Analytics
Program | AI and ML Course | Business Analysis Certification Course | Data Engineering Certification Courses

Trending Master Programs

PMP Plus Certification Training Course | Data Science Certifiation Course | Data Analyst Course | Masters in Artificial Intelligence
| Cloud Architect Certification Training Course | DevOps Engineer Certification Training Course | Digital Marketing Course | Cyber
Security Expert Course | MEAN Stack Developer Course | Business Analyst Course

Trending Courses

PMP Certification Training Course | CSM Certification Course | Data Science with Python Course | Tableau Certification Course |
Power BI Certification Course | TOGAF Certification Course | ITIL 4 Foundation Certification Training Course | CISSP Certification
Training | Java Certification Course | Python Certification Training Course | Big Data Hadoop Course | Leading SAFe ® 6 training
with SAFe Agilist Certification

Trending Categories

Project Management Courses | IT Service and Architecture | Digital Marketing | Cyber Security Certification Courses | DevOps |
AI & Machine Learning | Big Data | Business and Leadership | Professional Courses | Software Engineering Certifications |
Management Courses | Excel Courses | Job Oriented Courses | MBA Courses | Technical Courses | Computer Courses | Web
Development Courses | Business Courses | University Courses | NLP Courses | PG Courses | Online Certifications |
Certifications That Pay Well | Javascript Bootcamp | Software Engineering Bootcamps | Chat GPT Courses | Generative AI
Courses | Quality Management Courses | Agile Certifications | Cloud Computing Courses
Courses | Quality Management Courses | Agile Certifications | Cloud Computing Courses

Trending Resources

Python Tutorial | JavaScript Tutorial | Java Tutorial | Angular Tutorial | Node.js Tutorial | Docker Tutorial | Git Tutorial |
Kubernetes Tutorial | Power BI Tutorial | CSS Tutorial

Terms and Conditions Privacy Policy Refund Policy


© 2009-2023 - Simplilearn Solutions. All Rights Reserved. The certification names are the trademarks of their respective owners.

Disclaimer
PMP, PMI, PMBOK, CAPM, PgMP, PfMP, ACP, PBA, RMP, SP, and OPM3 are registered marks of the Project Management Institute, Inc.

You might also like