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
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:
- Generative Adversarial Networks by Andrej Karpathy
- Generative Adversarial Nets in TensorFlow
- An introduction to Generative Adversarial Networks
- Generative Adversarial Networks (GANs) in 50 lines of code (PyTorch)
MLPs on MNIST
Multilayer perceptron discriminator and generator based on Generative Adversarial Networks trained on the MNIST dataset.
python gan_mnist.py
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
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
Training is very stable and the results are visually comparable to the ones presented in the paper.
Installation
Dependencies
- Python 3
- pip
Installation
- Clone the repository
git clone https://github.com/davidtvs/how-to-gan.git
- Install package requirements:
pip install -r requirements.txt