Neural Networks

Generative Adversarial Networks (GANs) – The Basics You Need To Know

Generative Adversarial Networks (GANs) – A very young family member of Deep Neural Networks Architecture. Introduce by Ian Goodfellow and his team at the University of Montreal in 2014. GANs are class of unsupervised machine learning algorithm.

 Adversarial training “The most interesting idea in the last 10 years in the field of Machine Learning.”                      – Sir. Yann LeCun, Facebook’s AI research director.

 

Lets Unpack This Jargon

As per the definition of word “Adversarial” from open internet “Involving two people or two sides who oppose each other i.e. adversary procedures. An adversarial relationship an adversarial system of justice with prosecution and defence opposing each other.

GAN Titel.png

So as name suggest it is called as Adversarial Networks because this is made up of two neural networks. Both neural networks are assigned different job role i.e. contesting with each other.

  • Neural Network one is called as Generator, because it generate new data instances.
  • Other neural net is called as Discriminator, evaluates work for first neural net for authenticity.

The cycle continue to obtain accuracy or near perfection results. Still confused, its ok let me try to give real world example as below

My son who is a good player of Chess Game. Since chess is a very famous game for many reasons but between me and my son its about beating each other. I know he is far better then me but because my need is to improve my self so I compete with him. Happy to loose to learn, what was wrong in my game and what was better or good in his. Always plan to do better next time from learning my mistakes in next game. I can say, I have learnt a lot.

So in above example if you replace my son with with “Discriminator” algorithm and myself with “Generator”, thats what GANs are all about.

 

But Excuse Me, But What Is A GAN In AI?

To understand “Generative Adversarial Networks”, its very important to differentiate between supervised learning and unsupervised learning. We can quickly see the difference as below.

Generative Adversarial Networks (GANs) - The Basics You Need To Know

For details on supervised and unsupervised learning see the below posts

As mentioned above GAN’s are fairly new architecture in the deep learning domain. They fall under unsupervised neural network category. The performance measure is far better then traditional neural nets. When we use google search engine we use GANs at time of typing, what we want to search.

Chinese have gone far more ahead in this filed and have created real time AI based news anchor. The model is trained on real news anchors video data i.e. speech patterns, facial movement etc.

The assumption here is they must have used GANs to train the model. But the most amazing part here is to achieve the output in real time and continuous manner. GANs any ways has ability to predict next video frame based upon the sequence of frames went in as an input. See the sample of CycleGAN below, second image is a generated one. Source

Horse.gif

The other side of these neural network is, they are used for creating fake news, images and video. GANs are new style/method to train neural networks and both are assigned different job role i.e. contesting with each other.

  • Discriminator – Evaluates work for first neural net for authenticity. This net has to go under regressive training. It comes back to normal operation once training is complete
  • Generator – Generate new random data instances. The sample looks like original by twisting and rendering but actually are fake.

Both of deep neural nets work simultaneously but separately and act as adversarially. The biggest advantage or differentiation of GAN’s is it create the stuff not just identify. Identifying a picture as painting and creating a panting are two separate tasks. GANs are used for creation task. So it about creation and creativity.

 

Generative Adversarial Networks (GANs) –  Architecture

GANs fall under unsupervised neural network category.  Are fairly a new architecture in the deep learning domain.  These networks consist of two models as mentioned above i.e.  Generative (G) and Discriminative (D) Model.

Generative Adversarial Networks (GANs) architecture helps to get rid of mundane task and allow to focus on new items. In gaming it gets used big time specially games like racing or running etc.

GAN Titel

Generative Adversarial Networks (GANs) - The Basics You Need To Know

Generator (G) – After getting well and regressive training it takes random input with slight noise to transform input as a similar image as real (refer image above). In this case idea is to find out counterfeit currency against real one. Generator works as de-convolutional neural network architecture call flow.

Discriminator (D) – A binary output generator / classifier.  This model works as a classifier to determine input. Whether given input looks like real or fake. Discriminator works as convolutional neural network architecture call flow.

For sure GANs are the results of a knowledge worker’s continuous efforts and persuasion to automate mundane tasks. From the picture above we can see to obtain the perfection or near real perfection stage GANs goes under regressive looped training iterations, weights adjustments back and forth between discriminator and the generator (through backpropagation). The astonishing learning which happens here is remarkable i.e.

  • Discriminator (D) – D learns to differentiate between real image and fake image created by generator.
  • Generator (G) – G cleverly learns from the feedback or learn by making mistakes.

Hope we can now correlate our real life example of me playing chess with my son one reason only “How do I improve my game”. In GAN the generator uses feedback from the discriminator to learn how to produce convincing output that the discriminator can’t distinguish from real.

The two popular network designs of Generative Adversarial Networks (GANs) are below, we will discuss about them in future post in details.

  • DCGAN – Deep Convolutional Generative Adversarial Networks main job is to transpod convolutional to upsample to generate image.
  • CycleGan – Cyclic Generative Adversarial Networks – Builds reasoning box to learn and tag what is real.

 

How do GANs Intuitively Work?

Lets get touchy around working of GANs. GANs have proven and demonstrated to generate all type of data from scratch which looks real, almost to real but not real. We know there are two main algorithms used in GANs

  • Generator Neural Network
  • Discriminator Neural Network.

From image above its clear that after heavy lifting training the generator network fed with random inputs which do its best to generate a sample of input data. Discriminator qualify those inputs as “Real” or  “Fake”.

 

Generator Neural Network

Generator is fed with series of random data and then it perform its core function job i.e mathematical operations i.e matrix, probability etc to generate output.

Generator Neural NetworkIn our case we have taken image as an input data. Once trained, the generator can produce images from latent samples / random data which looks very real.

 

Discriminator Neural Network.

Discriminator Neural Network gets trained just like deep neural network and fed with actual training data. Here it acts like a classifier with 2 outputs or works like a binary number generating box which generate output as 1 of 0.

Discriminator Neural Networks png.png

Value 1 represent for real and 0 for fake. The core function again based on mathematical functions which as process to identify images based on features as real (1)  or fake (0). Since discriminator uses classification technique to get trained, so this part falls under supervised learning method.

 

Steps For Training Generative Adversarial Networks (GANs)

GAN ProcessStep-1 Problem Definition – In our example above we will carry forward the same problem i.e. cross checking counterfeit current vs genuine currency. We want to generate fake images not fake text or video. Our Data set should have relevant information for it

Step-2  Setting up of GAN i.e. Environment & Architecture – Now we need to define to define the generator and the discriminator i.e as convolutional neural networks and de-convolutional neural networks as we will be feeding images.

Step-3  Discriminator Training (Real Data) –  We got real currency images which we want to generate as not real in-order to detect counterfeit currency. So now we need to train our discriminator correctly for correct prediction i.e as real (1).

Step-4  Discriminator Training (Fake Data) –  In this we will train our generator with fake data. Idea is to now get our discriminator evaluate and predict them as fake (0).

Step 5 Generator Training (with output from discriminator)Taking output from discriminator tagged as real predictions, now we need to train generator. Here we train generator to generate fake data and fool discriminator.

Step 6,7 and 8 :  Performance Optimisation. In these steps our basic idea to do below small steps

  • Perform Loop Iteration (All previous steps)
  • Checking & validating
  • Performance measurement.

After we perform 3 steps as above regressively we get our model better and better. We can test our our model is able to detect counterfeit currency.

 

Real Life Use Cases Of Generative Adversarial Networks (GANs)

GANs development has been impressive in such a short time. Creating high resolution images and high resolution videos are the coolest things happening today with GANs. Some cool applications of GANs.are as below.

  • Animated Characters
  • Predicting Next Video Frame
  • Image Enhancement
  • Text to Image and Image to Image Translation
  • CycleGAN – As shown above converting horse image to zebra
  • Image Repair

 

Points to Note:

All credits if any remains on the original contributor only. We have covered GANs at high level in this post. GAN’s main job is to generate data from scratch. The two algorithms i.e Generator and Discriminator are the at core here and uses historical data. In the past post we have walked through unsupervised machine learning.

 

Books + Other readings Referred

  • Research through Open Internet – NewsPortals,  Development report papers and Live conferences.
  • This paper from Cornel university library on GAN.
  • Lab and hands on experience of  @AILabPage (Self taught learners group) members.

 

Feedback & Further Question

Do you have any questions about Supervised Learning or Machine Learning ? Leave a comment or ask your question via email . Will try my best to answer it.

 

SECaaS - Security as a Service Is the Next Big ThingConclusion –  We have seen in post above that GANs are the newest members in Artificial Neural Network family. Mainly used for creation or rather recreation of information or facts. GANs help us make sense of what’s already in front of fake or real.

Deep Learning in short is going much beyond machine learning and its algorithms that are either supervised or unsupervised. In DL it uses many layers of nonlinear processing units for feature extraction and transformation.

ANN’s structure is what enables artificial intelligence, machine learning and supercomputing to flourish. Neural networks are powers language translation, face recognition, picture captioning, text summarisation and lot more.

 

============================ About the Author =======================

Read about Author at : About Me

Thank you all, for spending your time reading this post. Please share your opinion / comments / critics / agreements or disagreement. Remark for more details about posts, subjects and relevance please read the disclaimer.

FacebookPage    ContactMe      Twitter

====================================================================

Facebook Comments
Advertisements

2 replies »

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.