Generative Adversarial Networks


Hola Todos..!I am Talib, a data science guy.

One of the most interesting things about Data Science is Neural Networks and their working.

Here I am writing about Generative Adversarial Networks which I personally find very interesting and is actually interesting to note that what they are capable of doing.

So lets get started and get to know what are those



We all remember in the movie Star Wars: Rogue One how the character of Carrie Fisher i.e. Princess Leia was remastered and people were really critical about the CGI quality which was used in which face of young Carrie Fisher was just pasted over the body of another actress which really generated the criticism and ruined the ending for many. One of the Star Wars fan and deep fake creator Derpfake fixed all the shortcomings of the CGI using deepfake and posted it on YouTube and star war fans really wanted that in Movie. The Star Wars team learned from their mistake and used this tool for Carrie’s scenes in Rise of Skywalker using canned footage of Fisher from The Force Awakens.

Politicians and celebrities are the most common victims of deepfakes. A while ago University of Washington computer scientists had used neural network AI to model the shape of Obama’s mouth and make it lip synch to audio input creating a fake video of Obama.

High-profile figures are used because their public profiles provide ample source material for AI to learn from, but with the amount of selfies the average person takes in a lifetime and technological advances, perhaps soon anyone could be used as a source.

So in this post we are going to look behind the technology responsible for deepfake creation.

The technology used in Deepfake is Generative Adversarial Networks. Without further discussion lets get to know what is Generative Adversarial Network.

The Generative Adversarial Networks commonly known as GANs are a set of Neural Networks that was discovered my Ian Goodfellow and his colleagues in 2014.

A set of two neural networks that is used in Unsupervised Learning. The Generative Adversarial Networks basically generates data from scratch be it images, videos and music. French- American Turing award winner computer scientist Yann LeCun described it as “the most interesting idea in the last 10 years in Machine Learning field”.

Let’s have a peek at what it can do before going deep into the concept.


So as we can see that we have only a picture of Albert Einstein on the rightmost that is all that we have, rest all the things are done by Generative Adversarial Networks….

We may wonder how it is done let’s have a look at the process behind it.


How GANs work?

So generative adversarial networks consist of two different deep neural networks. One is called the forger and the other one is the detector. Let’s see what these forger and detector do.

Forger or Generator:

Its one of the two neural networks that is feed in with some random noisy data and from that random data it creates something of an intermediate form of data or says a fake image from the input data which is not actually what we want as an output but that is certainly the lower version of what we need. The forger can be understood better by the following image.

Working of the Generator


Detector or Discriminator:

The other neural network which is there for the detection of the fake or the intermediate output generated by the generator. It is able to detect the forged or the fake image generated by the generator as it is provided with the actual and real images. Once the generator provides the output it is taken by the discriminator and it checks for its authenticity by comparing it with real data. The working of discriminator can be understood by the following image.

Working of the Discriminator


Coming on to the actual process that how these two separate networks interact with each other and generate such images that are almost impossible to discriminate from the original.

We can observe here that both the generator and discriminator are under a feedback loop and that’s the exact process of how GAN works.

  • The Discriminator gets feedback from the real data that whether the generated image is real or fake.
  • The Generator gets the feedback from the discriminator about the authenticity of the image it has generated.

The generator and discriminator can be thought of as a simple thief and cop where the thief is learning to generate fake identity every time to get away from being detected by the cop and the cop is learning to detect the thief. In this way, both the cop and the thief are getting smart and the process goes on and on until the generator gets so much trained that it almost generates an image that cannot be detected anymore by the discriminator itself.

Both the neural nets are trying to optimize a different and opposing objective function, or loss function, in a zero-zum game. This is essentially an actor-critic model. As the discriminator changes its behavior, so does the generator, and vice versa.

The generative adversarial network for the MNIST data


On a concluding note, the generative data gives us a lot of potentials but some great dangers too.

Some generative networks for eg. OpenAI’s GP2 generate paragraphs that will almost look like something a journalist has written. Also one of the applications of GANs is Deepfakes where the model is trained in such a way that it superimposes the face of a different person with different person’s body as well as the voice can also be changed with the help of GANs.

So this is the basic concept of the GAN. The potentials are far bigger than what is described here.

That’s it for the GAN. If you liked what you read then comment, share out the website for more interesting posts.

In the next post we will be seeing whats deepfake and how they works and what negative and positive sorts of impact they have created in AI field. Stay tuned for that..

You can reach out to me here

Adios… Hasta Luego



You may also like...

Leave a Reply

Your email address will not be published. Required fields are marked *