-
TensorFlow implementation of Unsupervised Representation Learning with Deep Convolutional Generative Adversarial Networks.
-
The DCGAN model is defined here.
-
Please refer to the docs (coming soon) for custom configuration of the model and the callbacks setup.
- Python 3.3+
- Tensorflow 1.0+
- TensorCV
All directories are setup in config.py.
- Before training, put all the training images in
config.data_dir
. - Trained model will be saved every 100 steps in
config.model_dir
. - Sample generated images will be saved every 100 training steps in
config.infer_dir
. - Images generated during testing will be saved in
config.result_dir
.
Please note, all the images should have the same size.
- You can run this script on CIFAR10, MNIST dataset as well as your own dataset in format of Matlab .mat files and image files.
To train a model on CIFAR10 and MNIST dataset:
$ python DCGAN.py --train --cifar --batch_size 64
$ python DCGAN.py --train --mnist --batch_size 64
To train on your own dataset:
.mat files:
$ python DCGAN.py --train --matlab --batch_size 64 --mat_name MAT_NAME_IN_MAT_FILE
images files:
$ python DCGAN.py --train --image --batch_size 64 --type IMAGE_FILE_EXTENSION(start with '.')
To test using an existing model, size and channels of images used for training the model need to be specified, and the batch size has to be the same as training:
$ python DCGAN.py --predict --batch_size SAME_AS_TRAINING --h IMAGE_HEIGHT\
--w IMAGE_WIDTH --input_channel NUM_INPUT_CHANNEL
- Both discriminator and generator use learning rate 0.0002
- To avoid small discriminator loss, update generator twice for each update of discriminator, as suggested here.
- init
Summary is written every 10 steps.
- loss of generator and discriminator
- gradients of generator and discriminator
- discriminator output for real image and generated image
- real image and generated image
details can be found in docs (coming soon)
- TrainSummary()
- CheckScalar()
- GANInference()
- InferImages()
More results will be added later.
Qian Ge