Improved generator objectives for GANs

Ben Poole, Alexander A. Alemi, Jascha Sohl-Dickstein, Anelia Angelova

Introduction

Generative adversarial networks (GANs) have become a popular method for fitting latent-variable directed generative models to complex datasets . While these models provide compelling visual samples, they are notoriously unstable and difficult to train and evaluate. Many recent papers have focused on new architectures and regularization techniques for improved stability and performance , but the objectives they optimize are fundamentally the same as the objectives in the original proposal .

The visual quality of samples from generative models trained with GANs often exceeds those of their variationally-trained counterparts . This is often credited to a difference in the divergence between the data and model distribution that each technique optimizes . GAN theory shows that an idealized formulation optimizes Jensen-Shannon divergence, while VAEs optimize a lower bound on log-likelihood, corresponding to a lower bound on the KL divergence. Recent work has generalized the GAN theory to target reverse KL and additional ff-divergences (including KL, reverse KL, and JS), allowing GANs to target a diverse set of behaviors .

However, these new theoretical advances fail to provide a justification for the GAN objectives that are used in practice. In particular, the generator objective used in practice is different from the one that is theoretically justified . This raises the question as to whether the theory used to motivate GANs applies to these modified objectives, and how the use of mismatched generator and discriminator objectives influences the behavior of GANs in practice.

Here we present a new interpretation of GANs as alternating between steps of density ratio estimation, and divergence minimization. This leads to a new understanding of the GAN generator objective that is used in practice as targeting a mode-seeking divergence that resembles reverse KL, thus providing an explanation for the mode dropping seen in practice. Furthermore, we introduce a set of new objectives for training the generator of a GAN that can trade off between sample quality and sample diversity, and show their effectiveness on CIFAR-10.

Theory

Given samples from a data density, x∼q(x)x\sim q(x), we would like to learn a generative model with density pp that matches the data density qq. Often the models we are interested in have intractable likelihoods, so that we can sample xx efficiently but cannot evaluate its likelihood. In the GAN framework , the intractable likelihood is bypassed by instead training a discriminator to classify between samples from the data and samples from the model. Given this discriminator, the parameters of the generative model are updated to increase the tendency of the discriminator to mis-classify samples from the model as samples from the data. This iterative process pushes the model density towards the data density without ever explicitly computing the likelihood of a sample. More formally, the GAN training process is typically motivated as solving a minimax optimization problem:

where pp is the generative model distribution, dd is the discriminator, and qq is the data distribution. Fixing pp, the optimal discriminator is d∗(x)=q(x)q(x)+p(x)d^{*}(x)=\frac{q(x)}{q(x)+p(x)} . Thus if the inner maximization over the discriminator is performed to completion for each step of pp, the GAN objective is equivalent to minimizing:

This has led to the understanding that GANs minimize the Jensen-Shannon divergence between the data density and the model density, and is thought to underlie the difference in sample quality between GANs and VAEs . However, this is not the objective that is used in practice, and we will see below that this alters the analysis.

Recently, proposed an extension to GANs to target divergences other than Jensen-Shannon. They generalize the set of divergences a GAN can target to the family of ff-divergences, where:

where f⋆f^{\star} is the Fenchel conjugateThe Fenchel conjugate is defined as f⋆(t)=sup⁡u∈domf(ut−f(u))f^{\star}(t)=\sup_{u\in\text{dom}_{f}}\left(ut-f(u)\right) of ff, and TT is the variational function also known as the discriminator in the GAN literatureWe use qq as the data distribution and pp as the model distribution, which is the opposite of .. Thus for any TT, we have a lower bound on the divergence that recovers exactly the discriminator objective used in the standard GAN when f(u)=ulog⁡u−(u+1)log⁡(u+1)f(u)=u\log u-(u+1)\log(u+1). As this is a lower bound on the ff-divergence, maximizing it with respect to the discriminator TT makes sense, and yields a tighter lower bound on the true divergence.

However, the objective to optimize for the generative model, pp, remains unclear. In both the original GAN paper and the ff-GAN paper , two objectives are proposed (denoted as GLB\mathcal{G}_{\text{LB}} and GALT\mathcal{G}_{\text{ALT}}):

GLB\mathcal{G}_{\text{LB}}: Minimize the lower bound in Equation 4. For standard GANs, this corresponds to minimizing the probability of the discriminator classifying a sample from the model as fake.

GALT\mathcal{G}_{\text{ALT}}: Optimize an alternative objective:

For standard GANs, this corresponds to maximizing the log probability of the discriminator classifying a sample from the model as real.

The first approach minimizes a lower bound, and thus improvements in the objective can correspond to making Df(q∥p)D_{f}(q\|p) smaller, or, more problematically, by making the lower bound on Df(q∥p)D_{f}(q\|p) looser. In practice this leads to slower convergence, and thus the first objective is not widely used.

The second approach is empirically motivated in as speeding up training, and theoretically motivated by the observation that p=qp=q remains a fixed point of the learning dynamics. However, the behavior of this generator objective when the generative model does not have the capacity to realize the data density remains unclear. This is the regime we care about as most generative models do not have the capacity to exactly model the data.

2 Discriminator as a density ratio estimator

To address the theoretical and practical issues we first present a simple relationship between the discriminator and an estimate of the density ratio. Given known data and model densities, the optimal discriminator with respect to an ff-divergence, fDf_{D}, was derived in as:

where fD′f_{D}^{\prime} is the derivative of fDf_{D}. If fD′f_{D}^{\prime} is invertible, we can reverse the relationship, and use the discriminator to recover the ratio of the data density to the model density:

In practice we don’t have access to the optimal discriminator T∗(x)T^{*}(x), and instead use the current discriminator T(x)T(x) as an approximation.

3 A new set of generator objectives

Given access to an approximate density ratio q(x)/p(x)q(x)/p(x), we can now optimize any objective that depends only on samples from qq or pp and the value of the density ratio. Conveniently, ff-divergences are a family of divergences that depend only on samples from one distribution and the density ratio! Given samples from pp and an estimate of the density ratio at each point, we can compute an estimate of the ff-divergence, fGf_{G} between pp and qq:

where GfD,fG\mathcal{G}_{f_{D},f_{G}} is the generator objective, fGf_{G} is the ff-divergence targeted for the generator, and fDf_{D} the ff-divergence targeted for the discriminator. fGf_{G} and fDf_{D} need not be the same ff-divergence. For non-optimal discriminators, this objective will be a biased approximation of the ff-divergence, but is not guaranteed to be either an upper or lower bound on fGf_{G}.

Our new algorithm for GAN training iterates the following steps:

Optimize the discriminator, TT, to maximize a lower-bound on DfD(q∥p)D_{f_{D}}\left(q\|p\right) using Equation 4.

Optimize the generator, pp, to minimize GfD,fG\mathcal{G}_{f_{D},f_{G}}, using the estimate of the density ratio from the current discriminator, TT, in Equation 8.

While the first step is identical to the standard ff-GAN training algorithm, the second step comprises a new generator update that can be used to fit a generative model to the data while targeting any ff-divergence. In practice, we alternate single steps of optimization on each minibatch of data.

4 Related work

Several recent papers have identified novel objectives for GAN generators. In , they propose a generator objective corresponding to fGf_{G} being reverse KL, and show that it improves performance on image super-resolution. identifies the generator objective that corresponds to minimizing the KL divergence, but does not empirically evaluate this objective.

Concurrent with our work, two papers propose closely related GAN training algorithms. In , they directly estimate the density ratio by optimizing a different discriminator objective that corresponds to rewriting the discriminator in terms of the density ratio:

This approach requires learning a network that directly outputs the density ratio, which can be very small or very large and in practice the networks that parameterize the density ratio must be clipped . We found estimating a function of the density ratio to be more stable, in particular using the GAN discriminator objective the discriminator T(x)T(x) estimates log⁡q(x)q(x)+p(x)\log\frac{q(x)}{q(x)+p(x)}. However, there are likely ways of combining these approaches in the future to directly estimate stable functions of the density ratio independent of the discriminator divergence.

More generically, the training process can be thought of as two interacting systems: one that identifies a statistic of the model and data, and another that uses that statistic to make the model closer to the data. discusses many approaches similar to the one presented here, but do not present experimental results.

We can use our new family of generator objectives to better understand GALT\mathcal{G}_{\text{ALT}}, the objective that is used in practice (Eq. 5). Given that fDf_{D} is the standard GAN divergence, we can solve for the generator divergence, fGf_{G}, such that GALT=GfD,fG\mathcal{G}_{\text{ALT}}=\mathcal{G}_{f_{D},f_{G}}, yielding:

Thus minimizing GALT\mathcal{G}_{\text{ALT}} corresponds to minimizing an approximation of the fGf_{G} divergence between the data density and the model density, not minimizing the Jensen-Shannon divergence.

To better understand the behavior of this divergence, we fit a single Gaussian to a mixture of two Gaussians in one dimension (Figure 1). We find that the GAN divergence optimized in practice is even more mode-seeking than JS and reverse KL. This behavior is likely the cause of many problems experienced with GANs in practice: samples often fail to cover the diversity of the dataset.

Experiments

In order to highlight the effect the generator objective can have on the generated samples, we targeted several objectives at various α\alpha divergences, as well as the traditional generator objective GALT\mathcal{G}_{\text{ALT}}. In Figure 2, we see that the generator objective has a large impact on sample diversity. In particular, for very mode-seeking divergences (α=−3\alpha=-3 and α=−1\alpha=-1), the samples fail to capture the diversity of class labels in the dataset, as is immediately visually obvious from over-representation of greens and browns in the generated samples. For more mode-covering divergences (α=0.5\alpha=0.5 (squared Hellinger), KL) we see much better diversity in colors and sampled classes, without any noticeably degradation in sample quality.

Discussion

Our work presents a new interpretation of GAN training, and a new set of generator objectives for GANs that can be used to target any ff-divergence. We demonstrate that targeting JS for the discriminator and targeting other objectives for the generator yields qualitatively different samples, with mode-seeking objectives producing less diverse samples, and mode-covering objectives producing more diverse samples. However, training with very mode-seeking objectives does not yield extremely high-quality samples. Similarly, targeting mode-covering objectives like KL improves sample diversity, but the quality of samples does not visibly worsen. Visual evaluation of sample quality is a potentially fraught measure of quality however. Future work will be needed to investigate the impact of alternate generator objectives and provide better quantitative metrics and understanding of what factors drive sample quality and diversity in GANs.

We thank Augustus Odena for feedback on the manuscript, Vincent Dumoulin for the baseline code, and Luke Metz, Luke Vilnis, and the Google Brain team for valuable and insightful discussions.

References

Appendix A Deriving the generator objectives

Here we derive the generator objectives when the discriminator divergence is fD(u)=ulog⁡u−(u+1)log⁡(u+1)f_{D}(u)=u\log u-(u+1)\log(u+1), corresponding to the standard GAN discriminator objective. As in , we parameterize the discriminator as T(x)=gf(V(x))T(x)=g_{f}(V(x)) where gfg_{f} has the same range as fD′f_{D}^{\prime}. For the GAN case, this corresponds to gf(v)=−log⁡(1+exp⁡(−v))g_{f}(v)=-\log(1+\exp(-v)).

First, we can compute the inverse of the gradient of fDf_{D} which is used to estimate the density ratio:

For GANs, the discriminator is parameterized as T(x)=−log⁡(1+exp⁡(−V(x))T(x)=-\log(1+\exp(-V(x)), so we can compute the density ratio as:

Given this estimate of the density ratio, we can then compute the generator objective as fG(eV(x))f_{G}(e^{V(x)}). The table below contains the generator objectives for many different fGf_{G} given fD(u)=ulog⁡u−(u+1)log⁡(u+1)f_{D}(u)=u\log u-(u+1)\log(u+1):

Appendix B CIFAR-10 architecture details

This is a slightly modified version of the architecture from . Input images were scaled from toto.