Generative Adversarial Network (GAN) in Unsupervised Machine Learning

  • Neelam Tyagi
  • Feb 13, 2020
  • Deep Learning
  • Machine Learning
Generative Adversarial Network (GAN) in Unsupervised Machine Learning title banner

The engagement of Deep Learning is to explore intense and stratified algorithms to express the probability distribution across the different types of data confronted in Artificial Intelligence (AI), such as real images, audio speech, bulk symbols in Natural Language Processing(NLP)


So far, including various prominent models in deep learning discriminative models have notable implications due to specific features like high-dimensionality mapping, intense distinct input to a class label, etc, and follow the principles of backpropagation and dropout algorithms.


One other discriminative model will be discussed in this blog, a full listing of our blog covers the definition of Generative Adversarial Networks (GAN), its architecture, working (loss function), and applications with some examples.





Ian Goodfellow, the GODfather of GAN: a man who has given a machine the gift of imagination[1], has introduced GAN in 2014 by bringing two neural networks against each other. The first neural network, discriminatory, attempts to resolve whether the information is real or fake, the other neural network, generator, strives to produce data that the discriminator assumes is real.


In the past, he had designed a powerful Artificial Intelligence (AI) tool and now we must have encountered the consequences including him.  


At that time, most researchers were already using neural networks, algorithms were modeled on the basis of a trellis of neurons in human brains, expected that “generative model” ables to produce plausible new data of their own. 


No wonder more, what he invented that time is now called "Generative Adversarial Network", or a GAN. The technique has kindled tremendous enthusiasm in the realm of Machine Learning (ML) and directed his inventor into an AI notoriety.


The main intention behind GANs is to furnish machines with something kindred to imaginations. 


Let’s focus more on the deep aspects of GANs !!!!



When fake gets real aka what is GAN?


Generative adversarial networks are impressive discoveries in machine learning, GANs are generative models, i.e. they produce new data formation that matches the training data.


GANs possess algorithmic architecture consisting of two neural networks, placing against each other in order to receive new synthetic data samples. They are widely used for image generation, video generation, and speech generation.


For instance, GANs can generate images that are very similar to human faces, although generated images don’t belong to real face to any person. 


Expressing how GAN is implemented for generating images.

Examples of real and fake images as data


Another example, Naive Bayes, is a generative model that is also used as a discriminative model, and Latent Dirichlet Allocation (LDA) or Gaussian Mixture Model.


One of the major gains that GAN provides is a more specific approach for Data Augmentation, in fact, it is said that data augmentation is a simplified version of generative modeling.


In brief terms, data augmentation techniques can prevent neural networks from acquiring inappropriate examples, and boosting overall performance. It enhances model efficiency and provides a regularizing effect that reduces generalization errors. It is primitive in the case of images data incorporating flips, crops, zooms, and other relevant transformations in existing images in the training dataset.  


Architecture and Working of GANs


As stated above, the concept of simplest design of GANs is depicted in the below diagram, the first neural network is termed as the generator, it initiates with randomly distributed data and transforms this noise into plausible information that touches the distribution of the real data available initially. And, the second neural network is termed as a discriminator, it distinguishes the real information from the training dataset that the generator produces.    


Focusing on the simplest architecture of GAN where the Discriminator and the Generator Neural Networks aid assistance to sharp each others' skills.

The simple architecture of GAN


Superficially, the generator never considers the authentic data, but always seeks to learn and create realistic-genuine information by obtaining feedback from the discriminator, known as adversarial loss, and when executed appropriately, the generator functions well.


The more profusely these two neural networks instruct each other, the more they add sharpen-skills in their thread.


While enduring this process, the discriminator facilitates itself in detecting counterfeit data while the generator seeks to receive and compose identical information viewed in the real world. (Suggesting here to read the blog: What is Deepfake Technology for more learning of fake and real portrait creations).


Steps to design generative models;


  1. Addressing the problem, what is need to generate bogus news or counterfeit images should be addressed in order to accumulate relevant data for it.

  2. Specify architecture of GANs, for any problem, fixing how specific GANs look, as generator and discriminator are multilayer perceptrons or Convolution Neural Networks (CNN) depending upon the problem. 

  3. Instruct Discriminator on authentic data for n times, fetch the real data that gets formed fake on and train the discriminator to estimate them perfectly as real, n varies from one to infinity.

  4. Instruct Discriminator for fake data and generate fake input for the generator, obtain fake data and allow the discriminator to estimate them perfectly as fake.

  5. Instruct generator from the output of the discriminator, retrieve the output or predictions of the discriminator as a purpose to train the generator to make fools of the discriminator; repeat the last 3 steps to some times. 

  6. Inspect the authorization of fake data, examine the fake data manually if it seems bogus and end up with instructing if fake data seems appropriate, else repeat step 3. At last, GANs evaluation can be performed. 


GAN Loss Function


GAN consists of two-loss functions: one is generator training and the other is a discriminator training, both work together to express the single range measurement between probability distribution.


The generator can change only one term that reflects the distribution of fake data, so during generator training, another term must be dropped out that expresses the distribution of real data.


In simple words, if a discriminator works perfectly, it gives high values for genuine data samples and low values for counterfeit data emerging from the generator, on the other hand, a generator works on opposite rules, it makes discriminator specify high values for the generated information. 


Mathematically, it can be represented by the equation,


V (D max,G min) = Ex~pdata(x)[log D(x)] + Ez~pz(z)[log(1-D(G(z))]



G = Generator, 

D = Discriminator,

Ex= Expected values of real data, 

Ez= Expected values of random input data to the Generator,

pdata(x) = distribution of real data, 

P(z) = distribution of generator,

x = sample from Pdata(x), 

z = sample from P(z),

D(x) = Discriminator network, 

and G(z) = Generator network


Featuring the working methodology of GAN Loss Function incorporating the Discriminator and the Generator Neural Network that specify the authenticity of fake and real data.

GAN loss function working design


Where a generator tries to minimize the loss function (minimizing (log(1-D(G(z)))), the discriminator tries to maximize the probability assigned to real and fake images, or maximize the average of the log probability for real images and log of the inverted probabilities of fake images (maximizing log D(x)+log(1-D(G(z)))).


Application of GANs


  • A trained and skilled generator can be used for making multiple creations, once it gets the arrangement of the training data then it can be deployed several numbers of times for receiving realistic outputs like images, language, numerical simulations, pharmaceuticals or anything beyond one’s imagination. 


  • A trained and skilled discriminator can be implemented for identifying malformations, irregularities, outliers, freaks, or anything especially out of ordinary scale. This leaves an estimable shadow in the disciplines of cybersecurity, cosmology, radiology, manufacturing, and construction, etc. 


  • Other significant applications included Text to Image Generation, used in producing movies and comics by generating a sequence of images based on text data instances.[2]


  • Image to Image Generation, to map a pattern from input data to output data images, like transforming a horse into zebra.


  • E-commerce and industrial design, to recommend commodity and producing new 3D products based on product data, for example, designing new clothing styles according to consumers’ demand.


  • Most popular creation is by NVIDIA researchers of Generating Faces, the team used 20k data samples pictures of superstar’s faces and produced photorealistic images of characters who nevermore were in reality.





A Generative Adversarial Network (GAN) is worthwhile as a type of manufacture in neural network technology to proffer a huge range of potential applications in the domain of artificial intelligence. Basically it is composed of two neural networks, generator, and discriminator, that play a game with each other to sharpen their skills. Together, they provide a foremost simulation of visionary exercise. 


Even though it is justifiable to maintain in expressions of generative neural networks, 


You might not think that programmers are artists, but programming is an extremely creative profession. It’s logic-based creativity. - John Romero


Specialists are keen to look at the strength that GAN can have to elevate the endowment of neural networks and their expertise to reminisce in human ways. For more blogs on Analytics, Do read Analytics Steps!



  • 360digitmgas

    Jun 19, 2020

    I like viewing web sites which comprehend the price of delivering the excellent useful resource free of charge. I truly adored reading your posting. Thank you! data science course in coimbatore