“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 someone who might find it useful.

I’m planning on exploring more topics in machine learning through these blog posts.

Keep Learning!