Name: Towards AI Legal Name: Towards AI, Inc. Description: Towards AI is the world's leading artificial intelligence (AI) and technology publication. Read by thought-leaders and decision-makers around the world. Phone Number: +1-650-246-9381 Email: [email protected]
228 Park Avenue South New York, NY 10003 United States
Website: Publisher: https://towardsai.net/#publisher Diversity Policy: https://towardsai.net/about Ethics Policy: https://towardsai.net/about Masthead: https://towardsai.net/about
Name: Towards AI Legal Name: Towards AI, Inc. Description: Towards AI is the world's leading artificial intelligence (AI) and technology publication. Founders: Roberto Iriondo, , Job Title: Co-founder and Advisor Works for: Towards AI, Inc. Follow Roberto: X, LinkedIn, GitHub, Google Scholar, Towards AI Profile, Medium, ML@CMU, FreeCodeCamp, Crunchbase, Bloomberg, Roberto Iriondo, Generative AI Lab, Generative AI Lab Denis Piffaretti, Job Title: Co-founder Works for: Towards AI, Inc. Louie Peters, Job Title: Co-founder Works for: Towards AI, Inc. Louis-François Bouchard, Job Title: Co-founder Works for: Towards AI, Inc. Cover:
Towards AI Cover
Logo:
Towards AI Logo
Areas Served: Worldwide Alternate Name: Towards AI, Inc. Alternate Name: Towards AI Co. Alternate Name: towards ai Alternate Name: towardsai Alternate Name: towards.ai Alternate Name: tai Alternate Name: toward ai Alternate Name: toward.ai Alternate Name: Towards AI, Inc. Alternate Name: towardsai.net Alternate Name: pub.towardsai.net
5 stars – based on 497 reviews

Frequently Used, Contextual References

TODO: Remember to copy unique IDs whenever it needs used. i.e., URL: 304b2e42315e

Resources

Take our 85+ lesson From Beginner to Advanced LLM Developer Certification: From choosing a project to deploying a working product this is the most comprehensive and practical LLM course out there!

Publication

Decoding the Science Behind Generative Adversarial Networks
Deep Learning

Decoding the Science Behind Generative Adversarial Networks

Last Updated on August 16, 2020 by Editorial Team

Author(s): Daksh Trehan

Deep Learning

A dummies guide to GANs that aims at the art ofΒ faking!

Generative adversarial networks(GANs) took the Machine Learning field by storm last year with those impressive fake human-like faces.

Bonus Point* They are basically generated fromΒ nothing.

Irrefutably, GANs implements implicit learning methods where the model learns without the data directly passing through the network, unlike those explicit techniques where weights are learned directly from theΒ data.

Intuition

Photo by Robert Nyman onΒ Unsplash

Okay, suppose in the city of Rio de Janeiro, money forging felonies are increasing so a department is appointed to check in these cases. Detectives are expected to classify the legit ones and fake ones. When the officers correctly classify fake currency they are appreciated and when they make mistakes, feedback is provided by Central Bank. Now, whenever fake currencies are busted, forgers aims at circulating better fake currencies in the market. This is the recursive process when detectives identify fake currencies, the forger learns a better way to develop a more authentic currency, similarly with the admission of more fake currencies in the market the detectives develop an even better strategy to identify fabricated currencies. Both detectives and forgers will become better at what they do by learning from eachΒ other.

This is the basic intuition behindΒ GANs.

In GANs, there are two networks Discriminators (the detectives) and the Generator (the forger). The generator aims at creating fake data and discriminator is expected to bust fake ones. The recursive process makes both generator and discriminator to compete to perform better. They’re interdependent on each other as both of them play an essential role in each other’s learningΒ process.

Another point to ponder is that both networks are constantly learning. Let’s say the discriminator wrongly classified fake data as a real one, that would lead to generator learning that the current developed data is a good one. But, this is technically wrong and will be corrected by discriminator when it gets the feedback from the government about theΒ same.

How GANsΒ learn?

Goal: To generate new data i.e. new images, texts, speech,Β etc.

Generative Modeling

This is the type of modeling that involves learning trends based on given data and try to generate samples that closely resembles the provided data. A very common illustration of Generative modeling can be regarded as, predicting the sequential data.

Generative models follow a joint probability distribution.

The end goal is to get X fromΒ Y.

P(X, Y) can be read as the probability distribution of variables X andΒ Y.

Discriminative Modeling

This type of model generally includes those algorithms that aim at classifying the data from a given trend. Analyzing an image as a cat or a dog in it can be regarded as its bestΒ example.

While discriminative models are the ones that discriminate (classify) the data from a given distribution. Telling if a given picture has a cat or a dog in it, is the simplest example of discriminative modeling.

The end goal is to predict Y fromΒ X.

P(Y|X) can be regarded as β€œProbability of event Y occurring given event X has occurred”.

Discriminative vs Generative, Source

GAN follows Generative modeling and hence it aims at generating P(X,Y)

Model Architecture

A typicalΒ GAN

Noise

This comes from the random distribution that can be transformed into the required data. By introducing noise, we are making our GAN robust and thus easing its process to β€œproduce a wide variety of data, sampling from different places in the target distribution.”

Noise should be sampled from Gaussian Distribution.

Data from the Real Distribution

This is the required distribution. We expect GAN to generate data inspired by this distribution with a little help of noiseΒ data.

Generator

This is an essential component of GAN. It focuses on developing data following the trends of distribution.

Generators are required to upsample the input data to generate output data. The upsampling layer is a no weight layer that helps in increasing the spatial size of our inputΒ vector.

The generator creates data that would be classified by discriminator as real or fake. The generator will be fined with more loss if the data generated shares less resemblance with actual data and then using backpropagation it will try to learn from its mistakes to develop a better strategy to fool the discriminator.

Generator operation, Source

Generator training:

  • Sample randomΒ noise.
  • Produce output using randomΒ noise.
  • Analyze loss based on the discriminator’s classification.
  • Backpropagate through both discriminator and generator to get gradients.
  • Update weights using gradients.

Goal: To minimize the probability of detecting fake and realΒ data.

Input accepted: RandomΒ noise

Output generated: FakeΒ data

Discriminator

It is just a regular classifier that tries to distinguish real data from fake ones. Its network architecture depends upon the type of data it is implementing upon e.g. it might use RNN for text data, CNN for imageΒ data.

It tries to increase the number of channels thus easing the process to learn more features aboutΒ data.

The discriminator tries to classify the data, it usually ignores the generator’s loss and just implements a discriminator’s loss. The discriminator will be fined with more loss if it misclassifies actual data with a fake one and then using backpropagation it will try to learn from its mistakes to develop a better strategy to fool generator.

Discriminator operation, Source

Discriminator training:

  • Classify the input data as real orΒ fake.
  • Analyze the loss function for misclassifying.
  • Update weights using backpropagation.

Goal: To maximize the probability of detection of real & fakeΒ data.

input: Data (Real+Fake)

output: Probability of data being Real orΒ Fake.

Training ourΒ model

While training our model, both networks must be trained separately. First, the discriminator is trained for several steps and then the training is shifted for generator.

If we try to train both networks simultaneously it would be like aiming for a flying bird and hence increasing our chances ofΒ failure.

As the generator gets better with training, the performance of discriminator gets struck i.e. it becomes difficult for it to classify real and fake data. If the generator succeeds perfectly to achieve its goal i.e. minimizing the probability of detection, the accuracy of discriminator swoops down to 0.5. The downgrade inaccuracy suggests that discriminator has shifted its strategy from statistical to random methods. This further leads to languish Generator’s accuracy and worsening our model’s performance.

Type of GANΒ models

GANs variations, Source

Conclusion

Hopefully, this article will help you to understand about Generative Adversarial Networks(GAN) in the best possible way and also assist you to its practical usage.

As always, thank you so much for reading, and please share this article if you found itΒ useful!

Feel free toΒ connect:

LinkedIn ~ https://www.linkedin.com/in/dakshtrehan/

Instagram ~ https://www.instagram.com/_daksh_trehan_/

Github ~ https://github.com/dakshtrehan

Follow for further Machine Learning/ Deep LearningΒ blogs.

Medium ~ https://medium.com/@dakshtrehan

Want to learnΒ more?

Detecting COVID-19 Using DeepΒ Learning

The Inescapable AI Algorithm: TikTok

An insider’s guide to Cartoonization using MachineΒ Learning

Why are YOU responsible for George Floyd’s Murder and Delhi CommunalΒ Riots?

Understanding LSTM’s andΒ GRU’s

Recurrent Neural Network forΒ Dummies

Convolution Neural Network forΒ Dummies

Diving Deep into DeepΒ Learning

Why Choose Random Forest and Not DecisionΒ Trees

Clustering: What it is? When to useΒ it?

Start off your ML Journey with k-Nearest Neighbors

Naive Bayes Explained

Activation Functions Explained

Parameter Optimization Explained

Gradient Descent Explained

Logistic Regression Explained

Linear Regression Explained

Determining Perfect Fit for your MLΒ Model

Cheers!


Decoding the Science Behind Generative Adversarial Networks was originally published in Towards AIβ€Šβ€”β€ŠMultidisciplinary Science Journal on Medium, where people are continuing the conversation by highlighting and responding to this story.

Published via Towards AI

Feedback ↓