Skip to content

moturuab/com-sci-com

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

42 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Abhishek Moturu

Twitter: @AbhishekMoturu

Generative Adversarial Networks (GANs)

Memes

Source: Meme Generator - Horse

This image is a representation of how the 2-player minimax game between the Generator and Discriminator in a GAN (in this case, trained using a dataset of pencil sketches of horses) looks like. The Generator initially performs very poorly and the Discriminator can easily tell the difference between a real image (from the training data distribution) and a fake image (created by the Generator, which maps from a latent space to an image space). Over time, as we train the GAN, the images generated by the Generator become essentially indistinguishable from those in the training data distribution, i.e. the Discriminator can no longer tell the difference between a real image and a fake image. We see this depicted above as the horse drawing improves over time.

Source: Meme Generator - The Office (My thanks to Sasha Doubov for inspiring me.)

In a similar line of thought as in the previous image, this image is a representation of the state of a GAN after successful training, once a unique solution is found. The Generator is able to generate images that perfectly match those in the training data distribution. So, at the end, the Discriminator will no longer be able to tell the difference between a real image (from the training data distribution) and a generated image (from the Generator). We see this depicted above as the real image and the generated image being "the same picture".

Technical Explanation

Using an adversarial approach, generative models can be estimated using GANs by simultaneously training (i.e. playing a 2-player minimax) with 2 models: a Generator and a Discriminator. While a Generator tries to emulate the training data distribution, the Discriminator guesses whether a given image comes from the training data distribution or from the Generator. The idea is that, over the course of training, the Generator goes from performing very poorly to very well and the Discriminator goes from performing very well to very poorly. This translates to the Generator being able to generate very good samples that seem like they could be from the training data distribution, by the end of the GAN training.

The exact formulation of the 2-player minimax game between the Generator (G) and Discriminator (D) is as follows:

Note that the first term of the value function V(D,G) is the log probability of x being from the training data rather than being generated by the Generator. The second term of the value function is the log probability of G(z), where z is from the latent space and used to generate G(z), being generated by the Generator rather than being from the training data. Since we minimize with respect to G and maximize with respect to D, this means that:

  • We want the Generator to generate better images so that it may be able to fool the discriminator into thinking that the images it generated are from the training data distribution rather than generated from random noise. In other words, we want the Generator to get better at making the Discriminator assign incorrect labels to the images it generates.
  • We want the Discriminator to get worse at correctly labeling both the training data (real) images and the generated (fake) images.

By the end of training, we ideally want the training data distribution and the Generator distribution to be the same and the Discriminator to only have a 50% accuracy, i.e. random chance, at guessing whether a given data point comes from the training data distribution or the Generator distribution.

Since the first paper on GANs in 2014, there have been many applications of GANs in the fields of facial image generation, fashion design, medical image generation and anomaly detection, 3D object generation, super-resolution, and astrophysics, to name a few.

Source: Generative Adversarial Nets

Releases

No releases published

Packages

No packages published