Reader small image

You're reading from  Hands-On Generative Adversarial Networks with Keras

Product typeBook
Published inMay 2019
Reading LevelIntermediate
PublisherPackt
ISBN-139781789538205
Edition1st Edition
Languages
Tools
Right arrow
Author (1)
Rafael Valle
Rafael Valle
author image
Rafael Valle

Rafael Valle is a research scientist at NVIDIA focusing on audio applications. He has years of experience developing high performance machine learning models for data/audio analysis, synthesis and machine improvisation with formal specifications. Dr. Valle was the first to generate speech samples from scratch with GANs and to show that simple yet efficient techniques can be used to identify GAN samples. He holds an Interdisciplinary PhD in Machine Listening and Improvisation from UC Berkeley, a Masters degree in Computer Music from the MH-Stuttgart in Germany and a Bachelors degree in Orchestral Conducting from UFRJ in Brazil.
Read more about Rafael Valle

Right arrow

Progressive Growing of GANs

Progressive Growing of Generative Adversarial Networks (GANs) is a training methodology that is introduced in a context where high-resolution image synthesis was dominated by autoregressive models, such as PixelCNN and Variational Autoencoders (VAEs) – just like the models used in the paper Improved Variational Inference with Inverse Autoregressive Flow (https://arxiv.org/abs/1606.04934).

As we described in earlier chapters, although autoregressive models are able to produce high-quality images, when compared to their counterparts they lack an explicit latent representation that can be directly manipulated. Additionally, due to their autoregressive nature, at the time of inference autoregressive models tend to be slower than their counterparts. On the other hand, VAE-based models have quicker inference but are harder to train, and the VAE-based...

Technical requirements

Progressive Growing of GANs

Progressive Growing of GANs offers a methodology that circumvents many of the problems related to GANs. It was the first publication to produce CelebA images using a resolution of 1024 by 1024; this was a task that was very challenging at the time the paper was published:

Samples generated with Progressive Growing of GANs. Source: Progressive Growing of GANs for Improved Quality, Stability and Variation. https://arxiv.org/pdf/1710.10196.pdf

As the name suggests, the methodology used in Progressive Growing of GANs consists of gradually increasing the resolution of the inputs, in this case, images, which are being handled or synthesized by the discriminator and generator. Likewise, layers are added to the discriminator and the generator in order to support higher resolutions.

In practice, instead of adding layers, a user defines the full graph of the...

Experimental setup

In this section, we are going to implement training functions that are compatible with the Progressive Growing of GANs methodology. These training and logging functions will be used to train the discriminator and the generator, which will also be implemented in this section.

We will also implement helper functions in order to make it easier to compute our loss function based on the Wasserstein GAN with Gradient Penalty.

Training

Our training method consists of the following two parts:

  • Initializing the required variables and compiling models
  • The training loop itself

We will start by looking at the training layout:

def train(n_channels=3, resolution=32, z_dim=128, n_labels=0, lr=1e-3,
e_drift=1e...

Model implementation

Implementing the models for Progressive Growing of GANs is a complex task, as the models have many custom layers and operations that are not implemented out of the box, including layers to perform pixel normalization, weight normalization during runtime, and more.

In addition to these layers, in our model design, we are including a mechanism in the models themselves; this allows for the runtime evaluation of the block that will be used as a model output, including how much input it receives from the previous layer.

The implementation described in this book, which encourages code reuse, uses (or adapts) code from an excellent implementation made by the Microsoft's Student Club of Beihang University group (https://github.com/MSC-BUAA/Keras-progressive_growing_of_gans/tree/master/Progressive%20growing%20of%20GANs).

...

Summary

In this chapter, we learned about the Progressive Growing of GANs architecture and how to implement it. We learned how to increase variation by using minibatch standard deviation, along with how to normalize the generator and discriminator for training stability.

In the next chapter, we will learn about the generation of discrete sequences using GANs.

lock icon
The rest of the chapter is locked
You have been reading a chapter from
Hands-On Generative Adversarial Networks with Keras
Published in: May 2019Publisher: PacktISBN-13: 9781789538205
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
undefined
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $15.99/month. Cancel anytime

Author (1)

author image
Rafael Valle

Rafael Valle is a research scientist at NVIDIA focusing on audio applications. He has years of experience developing high performance machine learning models for data/audio analysis, synthesis and machine improvisation with formal specifications. Dr. Valle was the first to generate speech samples from scratch with GANs and to show that simple yet efficient techniques can be used to identify GAN samples. He holds an Interdisciplinary PhD in Machine Listening and Improvisation from UC Berkeley, a Masters degree in Computer Music from the MH-Stuttgart in Germany and a Bachelors degree in Orchestral Conducting from UFRJ in Brazil.
Read more about Rafael Valle