Understanding Basics: Generative Adversarial Networks

Anushruthika
3 min readSep 6, 2023

--

UNDERSTANDING GANs

A Generative Adversarial Network (GAN) is a type of artificial neural network architecture in machine learning and deep learning that consists of two neural networks, the Generator and the Discriminator, which are trained together in a competitive process. The Generator tries to produce data (such as images, text, or audio) that is indistinguishable from real data, while the Discriminator’s task is to differentiate between real and generated data. This adversarial training process helps the Generator continuously improve its ability to create increasingly realistic data.

Imagine you want to create realistic paintings of landscapes. You decide to use a GAN for this purpose.

  1. Generator (Artist): The Generator is like an artist who starts with a blank canvas. Initially, it randomly generates an image that doesn’t resemble a landscape at all.
  2. Discriminator (Art Critic): The Discriminator is like an art critic. It shows both real landscape paintings (from a dataset) and the fake landscapes created by the Generator. In the beginning, the Discriminator is terrible at distinguishing between real and fake paintings because the Generator’s work is so bad.
  3. Training Process:
  • The Generator creates a fake landscape.
  • The Discriminator evaluates it. If it detects that it’s fake, it provides feedback to the Generator.
  • The Generator uses this feedback to try and create a more convincing landscape.
  • This process repeats in a loop. Over time, the Generator gets better at producing realistic landscapes, while the Discriminator becomes more skilled at telling real from fake.

End Result: After many iterations, the Generator becomes so good at creating landscapes that the Discriminator can hardly tell the difference between real and generated paintings. You now have a GAN that can produce highly realistic landscape paintings!

ARCHITECTURE OF GANs

Architecture of GAN

In every GAN, you supply a Random Noise Seed or a latent vector which can be a dimensional or two-dimensional array that is sent as a noise as an input to the generator. The generator network upscales this array to create a fake two-dimensional image. Now both the fake and real image is sent to the discriminator network which is trained to sort the real and fake images.

Based on the generator loss and discriminator loss the fine-tuning is done to a maximum number of epochs.

5 STEPS TO GANs

  • Define the GAN architecture based on the application
  • Train the discriminator to distinguish real from fake
  • Train the generator to fake the data which can fool the discriminator and look realistic
  • Continue discriminator and generator training for multiple epochs.
  • Save the generator model to create new fake data.

During the training of the generator hold the discriminator value as a constant similarly while training the discriminator hold the generator value as a constant. Each should be trained under a static adversary.

Applications

  • Generate Fake data for augmenting other machine learning algorithms
  • Generate faces
  • Image-to-image translation
  • Text-to-image translation
  • Super Resolution: Getting higher-resolution pictures.

--

--