A Tensorflow implementation of GAN, WGAN and WGAN with gradient penalty.
(*) This repo is a modification of carpedm20/DCGAN-tensorflow.
(*) The full credit of the model structure design goes to carpedm20/DCGAN-tensorflow.
I started with carpedm20/DCGAN-tensorflow because its DCGAN implementation is not fixed for one dataset, which is not a common setting. Most WGAN and WGAN-GP implementations only work on 'mnist' or one given dataset.
A couple of modifications I've made that could be helpful to people who try to implement GAN on their own for the first time.
model_type
which could be one of 'GAN' (original), 'WGAN' (Wasserstein distance as loss), and 'WGAN_GP' (Wasserstein distance as loss function with gradient penalty), each corresponding to one variation of GAN model.UnifiedDCGAN
can build and train the graph differently according to model_type
.ops.py
.The download.py
file stays same as in carpedm20/DCGAN-tensorflow. I keep this file in the repo for the sake of easily fetching dataset for testing.
If you are interested in the math behind the loss functions of GAN and WGAN, read here.
(left) python main.py --dataset=mnist --model_type=GAN --batch_size=64 --input_height=28 --output_height=28 --max_iter=10000 --learning_rate=0.0002 --train
(middle) python main.py --dataset=mnist --model_type=WGAN --batch_size=64 --input_height=28 --output_height=28 --d_iter=5 --max_iter=10000 --learning_rate=0.00005 --train
(right) python main.py --dataset=mnist --model_type=WGAN_GP --batch_size=64 --input_height=28 --output_height=28 --d_iter=5 --max_iter=10000 --learning_rate=0.0001 --train