If you’ve ever used an advanced filter on a picture before sharing it on Instagram or Facebook, chances are you used artificial intelligence and didn’t even know it. A great example of this is a mobile app called Prisma that applies amazing filters to your pictures based on styles. With this app, you could input this picture and apply this filter to make it look like this:
It could be doing this by using a Generative Adversarial Network, a neural network that has been trained specifically on this style of picture. Here is a simple breakdown of how a GAN works.
The Generator – its job is to generate things, at first very randomly. The generator submits these things to the Discriminator to be graded. The generator will perform very poorly in the beginning, but using the feedback from the Discriminator, it will slowly get better and better.
The Discriminator – its job is to grade the things from the generator. But first, it is fed things that are known to be true so it knows what a good thing really looks like. Once it has this “ground truth”, it will have the ability to tell the generator if the output is good or bad.
In reality, this interaction between the generator and discriminator will happen thousands of times, all depending on how long it takes for it to learn enough to create a good result.
Here is an example of a GAN I trained using batches of pictures of vehicles and animals from the CIFAR-10 dataset.
After the 1st round of training, it looks like gibberish and random noise.
After the 20th round of testing, it’s starting to look like actual things. But still, if you look closely enough, it’s not quite there. Compare that to a real sample of the training data below:
Pretty close right? I hope these examples help you to understand the basic intuition of how GANs work. The exciting thing about these types of neural networks is that they actually generate output versus answering a problem. Compare that to a neural net that can identify objects, make recommendations on videos based on what you’ve watched, or predict stock prices from previous stock price history.