A beginner-friendly introduction to Generative Adversarial Networks (GANs) in machine learning.

Subscribe to my newsletter and never miss my upcoming articles

"Generative Adversarial Networks" (or GANs for short) is a fascinating approach for training neural networks.

It sounds really complicated but it isn't.

Let's talk about it.

Pre-requisites to follow along: None.

A GAN has 2 parts: A generator and a discriminator.

  • The generator generates images(in this case) and the discriminator tries to identify if the images made by the generator are real or fake.

  • Essentially putting 2 neural networks in a fight against each other.

Let's understand it better through this example:

  • We have a generator that generates images of a 10 dollar bill.

Here are some of the rules:

  • The discriminator tries to determine if it is fake or not.

  • For every image that it recognizes correctly whether it's fake or real, it receives a point.

  • A point is deducted for every mistake it makes.

The first few images which are generated by the generator are very obviously fake

The discriminator easily detects the fake photos generated by the generator.

Discriminator's Score: 1

image.png

Now the generator makes an image that is slightly "less fake" than the previous ones.

The discriminator still correctly detects that it is a fake but it's getting tougher every time.

Discriminator's Score: 2

image.png

Now, the generator has started making images that are really really close to real images.

(Notice that there is a small brown box on the left corner in the generated image as a defect)

The discriminator is fooled and it loses a point. 😢

Discriminator's Score: 1

image.png

The discriminator realizes that it has made a mistake and learns from it. This process continues and the discriminator learns and improves after every iteration.

GANs can also be applied in NLP (Natural Language Processing).

In fact, that is how GPT-3, one of the world's largest neural networks, was trained on text data.

Conclusion

If you liked this blog post then share it with your friends who might find this useful.

I'm planning on exploring more topics in machine learning like image augmentation, CNNs using through these blog posts.

Keep Learning!

Interested in reading more such articles from Pratham Prasoon?

Support the author by donating an amount of your choice.

Recent sponsors

Comments (2)

Jonathan Gossage's photo

Have you done any work with NLP or have you concentrated on image recognition?

Pratham Prasoon's photo

I have no experience with NLP, working on computer vision at the moment.