/how-to-gan

Experiments with simple GANs and DCGANs in PyTorch

Primary LanguagePython

how-to-gan

Experiments with GANs in PyTorch following the papers Generative Adversarial Networks and Unsupervised Representation Learning with Deep Convolutional Generative Adversarial Networks.

Learning the normal distribution with multilayer perceptrons (MLPs)

An implementation of the pedagogical explanation of the GAN training algorithm presented in Generative Adversarial Networks.

python gan_normal.py

Learning the normal distribution

While the generator does manage to approach the real distribution, training is unstable and very hyperparameter sensitive. For me, this is a good example of a simple toy problem that works in theory but in practice ends up not working as expected. GANs seem to do fine with high-dimensional data like images but struggle to learn clean low-dimensional data like a normal distribution. There are a number of other implementations that reach similar results, offer possible explanations, and ways to improve:

MLPs on MNIST

Multilayer perceptron discriminator and generator based on Generative Adversarial Networks trained on the MNIST dataset.

python gan_mnist.py

GAN MNIST

Training is fairly stable and the results are visually comparable to the ones presented in the paper.

Convolutional networks on CIFAR-10

Convolutional discriminator and generator based on Generative Adversarial Networks trained on the CIFAR-10 dataset.

python gan_cifar10_conv.py

GAN CIFAR-10

Training is fairly stable and the results are visually comparable to the ones presented in the paper.

DCGAN on CIFAR-10

DCGAN implementation based on Unsupervised Representation Learning with Deep Convolutional Generative Adversarial Networks trained on the CIFAR-10 dataset.

python dcgan_cifar10.py

DCGAN CIFAR-10

Training is very stable and the results are visually comparable to the ones presented in the paper.

Installation

Dependencies

  • Python 3
  • pip

Installation

  1. Clone the repository
    git clone https://github.com/davidtvs/how-to-gan.git
    
  2. Install package requirements:
    pip install -r requirements.txt