GAN (Generative Adversarial Networks)
GANs are an approach to generative modeling using deep learning methods.
Lets understand GANs using a simple example.
Their are fake currencies and real currencies. Police is able to distinguish between fake and real ones and gives feedback to fake currencies generator and it tries to do better next time. I know it’s bit confusing but after a few moments I am sure you will get it.
The training of model is done in two steps.
Police that is our discriminator is trained and it distinguishes between fake and real notes.
Our generator of fake notes is trained and discriminator layer is frozen.
Let’s look at the code and understand better.
Here I have only discussed only the main part the full code repo is available at last.
We just initialized the variables.
This is our generator model. It will give output and we can resize it in 28*28 image. You try a different number of layers with different number of preceptrons.
Here we have our discriminator model.
This is our Step 2 were we froze our discriminator model.
As you can observe we first train our discriminator(police) and then freeze it and train out generator. you can observe that they mutually helps each other to preform better and more better. Just go threw the code and once again read the article I am sure you will get it. It will take some time in first go but let it settle.
Few tips to note-
- Noise should be sample of Gaussian Distribution.
You can have better quality of images by using DCGANs, but we will continue this some other day.
GitHub repo link — https://github.com/tjjain/GAN
I have tried to explain in most easy language as possible. I just started with writing all these stuff it will be great if you can tell me where I can improve to provide better content.