-
The code is adapted from the PyTorch documentation examples:
https://github.com/pytorch/examples/tree/master/dcgan -
The file download_lsun.py comes from a nice repository for downloading LSUN dataset:
https://github.com/fyu/lsun -
I have added massive comments for the code. Hope it beneficial for understanding GANs/DCGANs, especially for a beginner.
- CentOS Linux release 7.2.1511 (Core)
- python 3.6.5
- pytorch 1.0.0
- torchvision
- argparse
- os
- random
- subprocess
- urllib
python3 main.py --dataset mnist --cuda
Two folders will be created, i.e., ./data
& ./results
. The ./data
folder stores dataset.
The ./results
folder stores the generated images and the trained models.
You can also use cifar10, lsun, imagenet, randomly generated fake data, etc.
python3 download_lsun.py --category bedroom
Download data for bedroom and save it to ./data.
By replacing the option of --category
, you can download data of each category in LSUN as well.
python3 download_lsun.py
Download the whole data set.
- The DCGAN architecture is a relatively primary version. Now there exists some new modifications.
- The batch_size, size of feature maps of both G and D are all set to 64, different from that in the paper (128).
- With above hyperparameters set to 128, the model confronts gradient vanishing. Hope someone help me with it.
- PyTorch documentation
- https://github.com/pytorch/examples/tree/master/dcgan
- https://github.com/fyu/lsun