GANs — Context-Conditional GANs with MNIST (Part 5)

Original article was published on Deep Learning on Medium

GANs — Context-Conditional GANs with MNIST (Part 5)

Brief theoretical introduction to Context-Conditional Generative Adversarial Nets or CCGANs and practical implementation using Python and Keras/TensorFlow in Jupyter Notebook.

Context-Conditional Generative Adversarial Nets or CCGANs by fernanda rodríguez.

In this article, you will find:

  • Research paper,
  • Definition, network design, and cost function, and
  • Training CCGANs with MNIST dataset using Python and Keras/TensorFlow in Jupyter Notebook.

Research Paper

Denton, E.L., Gross, S., & Fergus, R. (2016). Semi-Supervised Learning with Context-Conditional Generative Adversarial Networks. ArXiv, abs/1611.06430.

Context-Conditional Generative Adversarial Nets — CCGANs

Context-Conditional Generative Adversarial Networks (CC-GANs) are conditional GANs where

  • The Generator 𝐺 is trained to fill in a missing image patch and
  • The Generator 𝐺 and Discriminator 𝐷 are conditioned on the surrounding pixels.

CC-GANs address a different task:

  • Determining if a part of an image is real or fake given the surrounding context.

The Generator 𝐺 receives as input an image with a randomly masked out patch. The Generator 𝐺 outputs an entire image. We fill in the missing patch from the generated output and then pass the completed image into 𝐷.

Read more about GANs:

Context-Conditional Generative Adversarial Nets or CCGANs Architecture by fernanda rodríguez.

x is the real data and z is the latent space.

Cost function CCGANs by fernanda rodríguez.

Training CGANs

  1. Data: MNIST dataset

2. Model:

3. Compile

4. Fit

5. Evaluate

epoch = 1/100, d_loss=0.419, g_loss=0.205 in CCGAN_MNIST
epoch = 100/100, d_loss=0.063, g_loss=0.200 in CCGAN_MNIST
Train summary CCGANs by fernanda rodríguez.

Github repository

Look the complete training CCGAN with MNIST dataset, using Python and Keras/TensorFlow in Jupyter Notebook.