TFGAN Examples
TFGAN is a lightweight library for training and evaluating Generative Adversarial Networks (GANs). GANs have been in a wide range of tasks including image translation, superresolution, and data augmentation. This directory contains fully-working examples that demonstrate the ease and flexibility of TFGAN. Each subdirectory contains a different working example. The sub-sections below describe each of the problems, and include some sample outputs. We've also included a jupyter notebook, which provides a walkthrough of TFGAN.
Contacts
Maintainers of TFGAN:
Table of contents
MNIST
MNIST with GANEstimator
CIFAR10
Image compression
MNIST
We train a simple generator to produce MNIST digits. The unconditional case maps noise to MNIST digits. The conditional case maps noise and digit class to MNIST digits. InfoGAN learns to produce digits of a given class without labels, as well as controlling style. The network architectures are defined here.
We use a classifier trained on MNIST digit classification for evaluation.
Unconditional MNIST
Conditional MNIST
InfoGAN MNIST
MNIST with GANEstimator
This setup is exactly the same as in the unconditional MNIST example, but uses the tf.Learn
GANEstimator
.
CIFAR10
We train a DCGAN generator to produce CIFAR10 images. The unconditional case maps noise to CIFAR10 images. The conditional case maps noise and image class to CIFAR10 images. The network architectures are defined here.
We use the Inception Score to evaluate the images.
Unconditional CIFAR10
Conditional CIFAR10
Image compression
In neural image compression, we attempt to reduce an image to a smaller representation such that we can recreate the original image as closely as possible. See Full Resolution Image Compression with Recurrent Neural Networks
for more details on using neural networks for image compression.
In this example, we train an encoder to compress images to a compressed binary representation and a decoder to map the binary representation back to the image. We treat both systems together (encoder -> decoder) as the generator.
A typical image compression trained on L1 pixel loss will decode into blurry images. We use an adversarial loss to force the outputs to be more plausible.
This example also highlights the following infrastructure challenges:
Some other notes on the problem:
Since the network is fully convolutional, we train on image patches.
Bottleneck layer is floating point during training and binarized during evaluation.
Results
No adversarial loss
Adversarial loss
Architectures
Compression Network
The compression network is a DCGAN discriminator for the encoder and a DCGAN generator for the decoder from Unsupervised Representation Learning with Deep Convolutional Generative Adversarial Networks
. The binarizer adds uniform noise during training then binarizes during eval, as in End-to-end Optimized Image Compression
.
Discriminator
The discriminator looks at 70x70 patches, as in Image-to-Image Translation with Conditional Adversarial Networks
.
链接:GAN