Objective of the Project
Build a DC-GAN (Deep Convolutional Generative Adversarial Network) to generate images of handwritten digits.
Important Details
- Dataset: MNIST handwritten digits dataset (grayscale)
- Model: Generative Adversarial Network (GAN)
- Code available at: https://github.com/aksharasoman/dcgan
- It can be built in google colab: python-notebook
Overview
A Generative Adversarial Network (GAN) model has two major components: a generator and a discriminator. Figure 1 gives outline of a GAN model.

A generator creates fake samples that mimic the real samples provided to the discriminator network. The discriminator is a binary classifier that evaluates these inputs, determining whether each one is real or fake. The generator’s objective is to produce fake samples that are so similar to real ones that the discriminator incorrectly identifies them as genuine.
GAN loss function consists of two parts: generator loss and discriminator loss.
During generator training, the discriminator’s weights are kept constant and are not updated, and vice versa.
Implementation
This project can be divided into 7 tasks.
- Configurations
- Load dataset
- Load dataset into batches
- Create discriminator network
- Create generator network
- Create loss function & optimizer
- Training Loop
For ease of understanding, you may refer to the iPython notebook, where each task is coded in separate sections.
- What is Generative Adversarial Network
- Applications (Current state-of-art performers for these applications)
- What is Generator?
- What is discriminator?
- Understanding architecture
- Loss functions
- How to generate a fake image using GAN?
- How to download and transform data in Pytorch?
- How to calculate input image size for each layer?
- How to build a GAN model from scratch in pytorch?
- How to train a Generative Adversarial Network?
- How to train the model on colab with GPU?
- How to train the model in a remote cluster environment?
- Challenges in GAN
Results Snapshot
References
- Coursera Guided Project: “Deep Learning with PyTorch : Generative Adversarial Network”