Google open sources TFGAN: Lightweight Library for Generative Adversarial Networks

Dec. 16, 2017, 8:24 a.m. By: Pranjal Kumar


It’s a well-known fact that training a neural network involves defining a loss function. Loss function indicates how close or far a network is from its objective. As with the image classification function, we tend to provide loss function that penalizes them for giving wrong classifications. But, loss function cannot be defined that easily for all problems especially if they involve human perception like image compression or text to speech system.

The generative Adversarial network is a technique which leads to improvement in various applications like superresolution, generating an image from text. GANs introduce a new theoretical and software engineering challenges which can be difficult to keep up with the fast pace of GAN research. To tackle this issue, Google has open sourced TFGAN.

TFGAN is a lightweight library which is designed to make it easy to train and evaluate GANs. It provides developers an infrastructure which is easily trained a GAN. It also provides a well-tested loss and evaluation metrics and easy to sue examples which highlights the flexibility of TFGAN. Google has also released a tutorial which includes a high-level API to quickly get a model trained on your data.


TFGAN provides simple function calls which cover the most of GAN use-cases so that developers can get a model running on their data set in just a few lines of code. Another advantage is that TFGAN is built in a modular way to cover more exotic GAN designs. Developers can use the modules you want — loss, evaluation, features are all independent. The lightweight feature means that developers can use it alongside other frameworks or even native TensorFlow.

Developers will also have an option to select from a large number of already-implemented losses and features without having to rewrite their own. Google has also assured that developers do not have to worry about numerical or statistical mistakes that are easily made with GAN libraries.

By using TFGAN, many developers can use the same infrastructure as used by Google researchers and will have access to the cutting-edge improvements. Developers can also contribute to GitHub repository which other developers can use.

GitHub Link - TFGAN

TFGAN MNIST unconditional gan training

Video Source: Joel Shor