Generative adversarial networks were first introduced in 2014 by Ian J. Goodfellow and other researchers in the paper. (Click here to see the paper).
Generative adversarial networks or GANs usage generative modeling.
What is generative modeling:
In generative modeling we create new data from original data by learning the input data, meaning generative models learn the pattern and features of input data in such a way that it produces new data that looks like the same as input data.
We can say that generative modeling is unsupervised learning, which says that a model patterns and regularities in data itself.
For example, gans can create a realistic image of a human face by learning human face images, even though the faces don't belong to any real person.
Why gans are getting so much attention nowadays?
Let's see some applications of gans to understand its role in practical life.
- Generating realistic photos of human faces.
- To generate human faces with age. (Faceaging)
- Photos to cartoon.
- Text to image translation and vice versa.4
- art generation
- Music generation
- Video generation and using different features in videos and many more...
As you can see gans can produce high quality and colorful art, images, paintings and more ...that only can do by humans till now, makes gans popular.
Now let's take look at the working mechanism of gans.
A generative adversarial network consists of two models one is the generative model and the other is the discriminator. The generative model is represented by G and the Discriminator is represented by D.
The generator is used to learn input data to produce new data imitate input data.
The Discriminator is used to discriminate between generated data and input data.
In simple terms, the discriminator works as a classifier that classifies the generated data (fake data generated by generator) and input data (real data).
These two networks are trained simultaneously which means the Generator and Discriminator compete with each other using a min-max game (an equation of loss function).
min-max game is an optimization strategy in which two networks try to minimize their loss function.
In the above equation, we are trying to minimize the loss function for the generator so that it can produce fake images that look real and maximizing the loss function for the discriminator so that it can not distinguish between real and fake.
In the above equation, theta_g is the loss function for the generator and theta_d is the loss function for the discriminator.
x- input data (Noise)
z- generated data from the generator
Flow Diagram for working mechanism of Discriminator and Generator
We can say that generator is trying to fool the discriminator while the discriminator is trying to not get fooled by the generator. At first, the generator produces not very realistic images and the discriminator is also naive, with time both models improved and, at some point generator succeeded in fooling the discriminator. At this point, the discriminator is not able to distinguish between real and fake.