Giter Club home page Giter Club logo

conditional-generative-adversarial-network's Introduction

Conditional-Generative-Adversarial-Network

Generative Modeling

A generative model describes how a dataset is generated, in terms of a probabilistic model. By sampling from this model, we are able to generate new data.

Hierarchy Of Generative models

Hierarchy Of Generative Models

Examples of Generative model applications

Generative modelling use-cases

GAN Architecture workflow

Architecture Of GAN

How a GAN works?

The principle - generator v/s discriminator

The working principle of a GAN is a mini-max game between two neural networks called the generator and discriminator. The generator tries to fool the discriminator by generating distributions similar to real-domain, say real-looking images, while the discriminator labels the data distribution as real or fake (as you would have seen in a classifier). The generator learns from the feedback it gets from the discriminator and updates itself to produce as real a data distribution as it can.

Individual Losses

Generative Loss

The generator tries to minimize the loss function given below. Here D ( G ( z(i) ) ) is the output of the classifier(discriminator) for the generated image's distribution G ( z(i) ) for the ith training example. Thus, log ( 1 - D ( G (z(i)) ) ) would correspond to the probability that the discriminator is not fooled by the generated image and classified it correctly as a fake image. So, the generator learns by trying to minimize its failure to fool the generator. Generator Loss

Discriminative Loss

The discriminator tries to maximize the function given below. As we can see that the second term is the same as the function minimized by the generator. Thus, it represents the maximization of the probability of classifying a fake generated image correctly as a fake one. The first term in turn represents the ability of the discriminator to correctly classify a real image. Thus, maximizing this function would train the discriminator as required by us. Note: In the actual model, the loss function is always minimized, so a negative sign is placed before the loss function term of the discriminator. Discriminator Loss

The generator G and the discriminator D are jointly trained in a two-player minimax game formulation. The overall minimax objective function, resulting due to combination of the above equations is: Objective Function of GAN

CGAN - Conditional Generative Adversarial Network

In a normal GAN, only the generation of data distribution from noise occurs, there is no control over modes of the data to be generated. Thus, we can get an object of distribution only and it would not be specific. Only its belongingness to the data distribution would be ensured by our GAN model.

This is tackled by Conditional GANs, which are trained to produce a specific image belonging to the data distribution !!

While only noise is given as input normally to GANs, CGANs along with taking data as input, also take labels as additional input parameters. Now, the noise coupled with the label as a pair is expected to generate an output corresponding to the label, and training of the CGAN occurs in this manner. The discriminator is also fed input data along with labels similar to the generator, to make real-image(data) production easier.

Thus we can generate any specific-featured data from distribution by the use of CGANs, by just including the required labels as input to our model, thus making CGANs a very powerful generative tool. CGAN Architecture

Objective function of a two-player minimax game for conditional GAN

Objective function of CGAN

Setup Instructions

You can either download the repo or clone it by running the following in cmd prompt

$ https://github.com/Huzaib/Conditional-Generative-Adversarial-Network.git

Further, just run the jupyter notebook

Training Loss Curve

Loss Curve

GIF of images generated during training

Training GIF

Few Final Generated Results

Zero Two Three Five Six Nine

Resources

conditional-generative-adversarial-network's People

Contributors

huzaib avatar

Stargazers

 avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.