Blog(in Chinese):
用GAN生成二维样本的小例子
Inspired & based on Dev Nag's GAN example:
- Use batch size instead of cardinality to achieve better convergency, the original version is actually generating 100 (cardinality by default) dimensional gaussian distribution for discriminator, so the convergency is BAD.
- Use 2D samples, with visualization of training.
- Demo of conditional GAN.
- GPU support.
Play with GAN to generate 2D samples that you can define your own probability density function (PDF) with a gray image.
python sampler.py
Will demo 10000 samples from the PDF defined by a gray image.
python gan_demo.py inputs/zig.jpg
Training will be visualized as the following:
For more complex distributions, conditional GAN is much better. This demo reads distributions from different pdfs, encoding conditions as one-hot vector.
python cgan_demo.py inputs/binary
Training will be visualized as the following:
Compared to vanilla GAN version:
More examples:
Vortex with C-GAN
python gan_demo.py -h