Javatpoint Logo
Javatpoint Logo

What is a Generative Adversarial Network (GAN)

Generative Adversarial Networks (GANs) can be described as extremely powerful kinds of neural networks that are employed to aid in Unsupervised Learning. They were created and first introduced in 2014 by Ian J. Goodfellow 2014. GANs are comprised of two neural networks that are in competition with one another and can analyse the changes within a set of data.

GANs are a method for generative modelling that uses deep learning methods like CNN (Convolutional Neural Network). Generative modelling is an unsupervised learning method that automatically discovers and learns patterns in input data so that the model can be used for new examples from the original dataset.

GANs are a method of training generative modelling by framing the problem as a supervised learning problem and using two sub-models. GANs have two components:

Generator This is a program that generates new data from real-world images.

Discriminator This compares the images with real-world examples to classify fake and real images.

Example The Generator generates random images (e.g., The Generator generates some random images (e.g., tables), and then the Discriminator compares these images with real-world table images. Finally, the Generator sends the feedback directly to Generator. See the GAN structure in the following figure.

What is a Generative Adversarial Network (GAN)

What is the Reason GANs were Invented in the First Place?

It is well-known that most of the neural nets used in mainstream research are easily misled into misclassifying items by introducing a tiny amount of noise to the data. Surprisingly, the model modified after adding noise has a higher probability of making a mistake than when it has made a good prediction. The reason for this is that machines learn from the smallest amount of data. This is a main drawback as it can be overfitted. The relationship between input and output is almost linear. While the lines of separation between different classes could be linear, they are comprised of linearities, and even minor changes in one point of the feature space could cause data to be classified incorrectly.

How does GAN works?

Generative Adversarial Networks (GANs) can be broken down into three parts:

  • Generative: To learn more about a dynamic model that explains how data are generated using a probabilistic model.
  • Adversarial: The process of training models, is conducted in an adversarial environment.
  • Networks: Make use of deep neural networks to create Artificial Intelligence (AI) algorithms to train for purposes.

Let's look at an example: generating images of Dogs.

Step 1: Training of Discriminator

  1. First, a random noise signal is sent through a generator. This generates useless images that contain noise.
  2. (See fig. 2)
  3. Discriminator has two inputs. The first is the Generator sample output images, and the second is real-world dog image samples.
  4. After comparing the images in fig., The Discriminator then populates certain values (probability). 2. It calculates 0.8 to 0.3 and 0.0.5 for generator output images and 0.1, 9.9, and 0.2 for real-world images.
  5. An error can be calculated by comparing the probabilities of generated images with 0 (Zero) and the probabilities of real-word images with 1. (Ex. (Ex.
  6. After it has calculated individual errors, it will calculate cumulative loss(loss), which is backpropagated. The weights of the Discriminator can then be adjusted. This is how a Discriminator gets trained.
What is a Generative Adversarial Network (GAN)

Step 2 - Training the Generator

  1. The loss is propagated back to the Discriminator in step 1. This will allow it to adjust its weights. We must also backpropagate an error, so it can adjust its weights and train itself to produce better images.
  2. The Generator generates images that are used to input the Generator.
  3. The Discriminator will now use the newly generated images as input. It calculates probabilities such as 0.5, 0.01, and 0.2. (See fig. 2)
  4. An error can be calculated by comparing the probabilities of images generated with 1 (One).
  5. After it has calculated individual errors, it will calculate cumulative loss(loss), which is backpropagated. The weights of the Generator then are adjusted. This is how Generator gets trained.
What is a Generative Adversarial Network (GAN)

After a few more iterations, the Generator will start generating images similar to real-world images.

Applications to GAN:

  • Generating images
  • Super Resolution
  • Image Modification
  • Photos of real people
  • Face Ageing

Next Topic#

Youtube For Videos Join Our Youtube Channel: Join Now


Help Others, Please Share

facebook twitter pinterest

Learn Latest Tutorials


Trending Technologies

B.Tech / MCA