Boundary-Seeking Generative Adversarial Networks

R Devon Hjelm, Athul Paul Jacob, Tong Che, Adam Trischler, Kyunghyun Cho, Yoshua Bengio

Introduction

Generative adversarial networks (GAN, Goodfellow et al., 2014) involve a unique generative learning framework that uses two separate models, a generator and discriminator, with opposing or adversarial objectives. Training a GAN only requires back-propagating a learning signal that originates from a learned objective function, which corresponds to the loss of the discriminator trained in an adversarial manner. This framework is powerful because it trains a generator without relying on an explicit formulation of the probability density, using only samples from the generator to train.

GANs have been shown to generate often-diverse and realistic samples even when trained on high-dimensional large-scale continuous data (Radford et al., 2015). GANs however have a serious limitation on the type of variables they can model, because they require the composition of the generator and discriminator to be fully differentiable.

With discrete variables, this is not true. For instance, consider using a step function at the end of a generator in order to generate a discrete value. In this case, back-propagation alone cannot provide the training signal, because the derivative of a step function is 0 almost everywhere. This is problematic, as many important real-world datasets are discrete, such as character- or word-based representations of language. The general issue of credit assignment for computational graphs with discrete operations (e.g. discrete stochastic neurons) is difficult and open problem, and only approximate solutions have been proposed in the past (Bengio et al., 2013; Gu et al., 2015; Gumbel & Lieblein, 1954; Jang et al., 2016; Maddison et al., 2016; Tucker et al., 2017). However, none of these have yet been shown to work with GANs. In this work, we make the following contributions:

We provide a theoretical foundation for boundary-seeking GANs (BGAN), a principled method for training a generator of discrete data using a discriminator optimized to estimate an ff-divergence (Nguyen et al., 2010; Nowozin et al., 2016). The discriminator can then be used to formulate importance weights which provide policy gradients for the generator.

We verify this approach quantitatively works across a set of ff-divergences on a simple classification task and on a variety of image and natural language benchmarks.

We demonstrate that BGAN performs quantitatively better than WGAN-GP (Gulrajani et al., 2017) in the simple discrete setting.

We show that the boundary-seeking objective extends theoretically to the continuous case and verify it works well with some common and difficult image benchmarks. Finally, we show that this objective has some improved stability properties within training and without.

Boundary-Seeking GANs

In this section, we will introduce boundary-seeking GANs (BGAN), an approach for training a generative model adversarially with discrete data, as well as provide its theoretical foundation. For BGAN, we assume the normal generative adversarial learning setting commonly found in work on GANs (Goodfellow et al., 2014), but these ideas should extend elsewhere.

Optimization using only back-propogation and stochastic gradient descent is possible when the generated samples are completely differentiable w.r.t. the parameters of the generator, θ\theta.

The inequality becomes tight when T\mathcal{T} is the family of all possible functions. The dual form allows us to change a problem involving likelihood ratios (which may be intractable) to an maximization problem over T\mathcal{T}. This sort of optimization is well-studied if T\mathcal{T} is a family of neural networks with parameters ϕ\phi (a.k.a., deep learning), so the supremum can be found with gradient ascent (Nowozin et al., 2016).

Maximizing Equation 5 provides a neural estimator of ff-divergence, or neural divergence (Huang et al., 2018). Given the family of neural networks, TΦ={Tϕ}ϕΦ\mathcal{T}_{\Phi}=\{T_{\phi}\}_{\phi\in\Phi}, is sufficiently expressive, this bound can become arbitrarily tight, and the neural divergence becomes arbitrarily close to the true divergence. As such, GANs are extremely powerful for training a generator of continuous data, leveraging a dual representation along with a neural network with theoretically unlimited capacity to estimate a difference measure.

2 Estimation of the target distribution

Following the definition of the ff-divergence and the convex conjugate, we have:

As f{f}^{\star} is convex, there is an absolute maximum when ft(t)=p(x)qθ(x)\frac{\partial{{f}^{\star}}}{\partial{t}}(t)=\frac{p(x)}{q_{\theta}(x)}. Rephrasing tt as a function, T(x)T(x), and by the definition of T(x)T^{\star}(x), we arrive at the desired result. ∎

Theorem 1 indicates that the target density function can be re-written in terms of a generated density function and a scaling factor. We refer to this scaling factor, w(x)=(f/T)(T(x))w^{\star}(x)=(\partial{{f}^{\star}}/\partial{T})(T^{\star}(x)), as the optimal importance weight to make the connection to importance sampling In the case of the ff-divergence used in Goodfellow et al. (2014), the optimal importance weight equals w(x)=eF(x)=D(x)/(1D(x))w^{\star}(x)=e^{F^{\star}(x)}=D^{\star}(x)/(1-D^{\star}(x)). In general, an optimal discriminator is hard to guarantee in the saddle-point optimization process, so in practice, TϕT_{\phi} will define a lower-bound that is not exactly tight w.r.t. the ff-divergence. Nonetheless, we can define an estimator for the target density function using a sub-optimal TϕT_{\phi}.

3 Boundary-seeking GANs

As mentioned above and repeated here, GANs only work when the value function is completely differentiable w.r.t. the parameters of the generator, θ\theta. The gradients that would otherwise be used to train the generator of discrete variables are zero almost everywhere, so it is impossible to train the generator directly using the value function. Approximations for the back-propagated signal exist (Bengio et al., 2013; Gu et al., 2015; Gumbel & Lieblein, 1954; Jang et al., 2016; Maddison et al., 2016; Tucker et al., 2017), but as of this writing, none has been shown to work satisfactorily in training GANs with discrete data.

Here, we introduce the boundary-seeking GAN as a method for training GANs with discrete data. We first introduce a policy gradient based on the KL-divergence which uses the importance weights as a reward signal. We then introduce a lower-variance gradient which defines a unique reward signal for each zz and prove this can be used to solve our original problem.

Here, the connection to importance sampling is even clearer, and this gradient resembles other importance sampling methods for training generative models in the discrete setting (Bornschein & Bengio, 2014; Rubinstein & Kroese, 2016). However, we expect the variance of this estimator will be high, as it requires estimating the partition function, β\beta (for instance, using Monte-Carlo sampling). We address reducing the variance from estimating the normalized importance weights next.

Lower-variance policy gradient

where we have approximated the expectation using the Monte-Carlo estimate.

Minimizing the expected conditional KL-divergences is stricter than minimizing the KL-divergence in Equation 7, as it requires all of the conditional distributions to match independently. We show that the KL-divergence of the marginal probabilities is zero when the expectation of the conditional KL-divergence is zero as well as show this estimator works better in practice in the Appendix.

Connection to policy gradients

REINFORCE is a common technique for dealing with discrete data in GANs (Che et al., 2017; Li et al., 2017). Equation 9 is a policy gradient in the special case that the reward is the normalized importance weights. This reward approaches the likelihood ratio in the non-parametric limit of an optimal discriminator. Here, we make another connection to REINFORCE as it is commonly used, with baselines, by deriving the gradient of the reversed KL-divergence.

Let Tϕ(x)T_{\phi}(x) be defined as above where f/T(Tϕ(x))=eFϕ(x)\partial{{f}^{\star}}/\partial{T}(T_{\phi}(x))=e^{F_{\phi}(x)}. Consider the gradient of the reversed KL-divergence:

4 Continuous variables and the stability of GANs

For continuous variables, minimizing the variational lower-bound suffices as an optimization technique as we have the full benefit of back-propagation to train the generator parameters, θ\theta. However, while the convergence of the discriminator is straightforward, to our knowledge there is no general proof of convergence for the generator except in the non-parametric limit or near-optimal case. What’s worse is the value function can be arbitrarily large and negative. Let us assume that maxT=M<\max T=M<\infty is unique. As f{f}^{\star} is convex, the minimum of the lower-bound over θ\theta is:

Let Gθ:ZXG_{\theta}:\mathcal{Z}\rightarrow\mathcal{X} be a generator function that takes as input a latent variable drawn from a simple prior, zh(z)z\sim h(z). Let TϕT_{\phi} and w(x)w(x) be defined as above. We define the continuous BGAN objective as: θ^=argminθ(logw(Gθ(z)))2.\hat{\theta}=\operatorname*{\arg\min}_{\theta}(\log{w(G_{\theta}(z))})^{2}. We chose the log\log, as with our treatments of ff-divergences in Table 1, the objective is just the square of the statistic network output:

This objective can be seen as changing a concave optimization problem (which is poor convergence properties) to a convex one.

Related work and discussion

Our work relies on estimating the likelihood ratio from the discriminator, the theoretical foundation of which we draw from ff-GAN (Nowozin et al., 2016). The connection between the likelihood ratios and the policy gradient is known in previous literature (Jie & Abbeel, 2010), and the connection between the discriminator output and the likelihood ratio was also made in the context of continuous GANs (Mohamed & Lakshminarayanan, 2016; Tran et al., 2017). However, our work is the first to successfully formulate and apply this approach to the discrete setting.

Importance sampling

Our method is very similar to re-weighted wake-sleep (RWS, Bornschein & Bengio, 2014), which is a method for training Helmholtz machines with discrete variables. RWS also relies on minimizing the KL divergence, the gradients of which also involve a policy gradient over the likelihood ratio. Neural variational inference and learning (NVIL, Mnih & Gregor, 2014), on the other hand, relies on the reverse KL. These two methods are analogous to our importance sampling and REINFORCE-based BGAN formulations above.

GAN for discrete variables

Training GANs with discrete data is an active and unsolved area of research, particularly with language model data involving recurrent neural network (RNN) generators (Yu et al., 2016; Li et al., 2017). Many REINFORCE-based methods have been proposed for language modeling (Yu et al., 2016; Li et al., 2017; Dai et al., 2017) which are similar to our REINFORCE-based BGAN formulation and effectively use the sigmoid of the estimated log-likelihood ratio. The primary focus of these works however is on improving credit assignment, and their approaches are compatible with the policy gradients provided in our work.

There have also been some improvements recently on training GANs on language data by rephrasing the problem into a GAN over some continuous space (Lamb et al., 2016; Kim et al., 2017; Gulrajani et al., 2017). However, each of these works bypass the difficulty of training GANs with discrete data by rephrasing the deterministic game in terms of continuous latent variables or simply ignoring the discrete sampling process altogether, and do not directly solve the problem of optimizing the generator from a difference measure estimated from the discriminator.

Remarks on stabilizing adversarial learning, IPMs, and regularization

A number of variants of GANs have been introduced recently to address stability issues with GANs. Specifically, generated samples tend to collapse to a set of singular values that resemble the data on neither a per-sample or distribution basis. Several early attempts in modifying the train procedure (Berthelot et al., 2017; Salimans et al., 2016) as well as the identifying of a taxonomy of working architectures (Radford et al., 2015) addressed stability in some limited setting, but it wasn’t until Wassertstein GANs (WGAN, Arjovsky et al., 2017) were introduced that there was any significant progress on reliable training of GANs.

WGANs rely on an integral probability metric (IPM, Sriperumbudur et al., 2009) that is the dual to the Wasserstein distance. Other GANs based on IPMs, such as Fisher GAN (Mroueh & Sercu, 2017) tout improved stability in training. In contrast to GANs based on ff-divergences, besides being based on metrics that are “weak”, IPMs rely on restricting T\mathcal{T} to a subset of all possible functions. For instance in WGANs, T={TTLK}\mathcal{T}=\{T\mid\|T\|_{L}\leq K\}, is the set of K-Lipschitz functions. Ensuring a statistic network, TϕT_{\phi}, with a large number of parameters is Lipschitz-continuous is hard, and these methods rely on some sort of regularization to satisfy the necessary constraints. This includes the original formulation of WGANs, which relied on weight-clipping, and a later work (Gulrajani et al., 2017) which used a gradient penalty over interpolations between real and generated data.

Unfortunately, the above works provide little details on whether TϕT_{\phi} is actually in the constrained set in practice, as this is probably very hard to evaluate in the high-dimensional setting. Recently, Roth et al. (2017) introduced a gradient norm penalty similar to that in Gulrajani et al. (2017) without interpolations and which is formulated in terms of ff-divergences. In our work, we’ve found that this approach greatly improves stability, and we use it in nearly all of our results. That said, it is still unclear empirically how the discriminator objective plays a strong role in stabilizing adversarial learning, but at this time it appears that correctly regularizing the discriminator is sufficient.

Discrete variables: experiments and results

We first verify the gradient estimator provided by BGAN works quantitatively in the discrete setting by evaluating its ability to train a classifier with the CIFAR-10 dataset (Krizhevsky & Hinton, 2009). The “generator” in this setting is a multinomial distribution, gθ(yx)g_{\theta}(y\mid x) modeled by the softmax output of a neural network. The discriminator, Tϕ(x,y)T_{\phi}(x,y), takes as input an image / label pair so that the variational lower-bound is:

For these experiments, we used a simple 44-layer convolutional neural network with an additional 33 fully-connected layers. We trained the importance sampling BGAN on the set of ff-divergences given in Table 1 as well as the REINFORCE counterpart for 200200 epochs and report the accuracy on the test set. In addition, we ran a simple classification baseline trained on cross-entropy as well as a continuous approximation to the problem as used in WGAN-based approaches (Gulrajani et al., 2017). No regularization other than batch normalization (BN, Ioffe & Szegedy, 2015) was used with the generator, while gradient norm penalty (Roth et al., 2017) was used on the statistic networks. For WGAN, we used clipping, and chose the clipping parameter, the number of discriminator updates, and the learning rate separately based on training set performance. The baseline for the REINFORCE method was learned using a moving average of the reward.

Our results are summarized in Table 2. Overall, BGAN performed similarly to the baseline on the test set, with the REINFORCE method performing only slightly worse. For WGAN, despite our best efforts, we could only achieve an error rate of 72.3%72.3\% on the test set, and this was after a total of 600600 epochs to train. Our efforts to train WGAN using gradient penalty failed completely, despite it working with higher-dimension discrete data (see Appendix).

2 Discrete image and natural language generation

We tested BGAN using two imaging benchmarks: the common discretized MNIST dataset (Salakhutdinov & Murray, 2008) and a new quantized version of the CelebA dataset (see Liu et al., 2015, for the original CelebA dataset).

For CelebA quantization, we first downsampled the images from 64×6464\times 64 to 32×3232\times 32. We then generated a 1616-color palette using Pillow, a fork of the Python Imaging Project (https://python-pillow.org). This palette was then used to quantize the RGB values of the CelebA samples to a one-hot representation of 1616 colors. Our models used deep convolutional GANs (DCGAN, Radford et al., 2015). The generator is fed a vector of 6464 i.i.d. random variables drawn from a uniform distribution, $$. The output nonlinearity was sigmoid for MNIST to model the Bernoulli centers for each pixel, while the output was softmax for quantized CelebA.

Our results show that training the importance-weighted BGAN on discrete MNIST data is stable and produces realistic and highly variable generated handwritten digits (Figure 2). Further quantitative experiments comparing BGAN against WGAN with the gradient penalty (WGAN-GP Gulrajani et al., 2017) showed that when training a new discriminator on the samples directly (keeping the generator fixed), the final estimated distance measures were higher (i.e., worse) for WGAN-GP than BGAN, even when comparing using the Wasserstein distance. The complete experiment and results are provided in the Appendix. For quantized CelebA, the generator trained as a BGAN produced reasonably realistic images which resemble the original dataset well and with good diversity.

-billion word

Next, we test BGAN in a natural language setting with the 1-billion word dataset (Chelba et al., 2013), modeling at the character-level and limiting the dataset to sentences of at least 3232 and truncating to 3232 characters. For character-level language generation, we follow the architecture of recent work (Gulrajani et al., 2017), and use deep convolutional neural networks for both the generator and discriminator.

Training with BGAN yielded stable, reliably good character-level generation (Table 3), though generation is poor compared to recurrent neural network-based methods (Sutskever et al., 2011; Mikolov, 2012). However, we are not aware of any previous work in which a discrete GAN, without any continuous relaxation (Gulrajani et al., 2017), was successfully trained from scratch without pretraining and without an auxiliary supervised loss to generate any sensible text. Despite the low quality of the text relative to supervised recurrent language models, the result demonstrates the stability and capability of the proposed boundary-seeking criterion for training discrete GANs.

Continuous variables: experiments and results

Here we present results for training the generator on the boundary-seeking objective function. In these experiments, we use the original GAN variational lower-bound from Goodfellow et al. (2014), only modifying the generator function. All results use gradient norm regularization (Roth et al., 2017) to ensure stability.

We test here the ability of continuous BGAN to train on high-dimensional data. In these experiments, we train on the CelebA, LSUN (Yu et al., 2015) datasets, and the 2012 ImageNet dataset with all 10001000 labels (Krizhevsky et al., 2012). The discriminator and generator were both modeled as 44-layer Resnets (He et al., 2016) without conditioning on labels or attributes.

Figure 3 shows examples from BGAN trained on these datasets. Overall, the sample quality is very good. Notably, our Imagenet model produces samples that are high quality, despite not being trained conditioned on the label and on the full dataset. However, the story here may not be that BGAN necessarily generates better images than using the variational lower-bound to train the generator, since we found that images of similar quality on CelebA could be attained without the boundary-seeking loss as long as gradient norm regularization was used, rather we confirm that BGAN works well in the high-dimensional setting.

2 Stability of continuous BGAN

As mentioned above, gradient norm regularization greatly improves stability and allows for training with very large architectures. However, training still relies on a delicate balance between the generator and discriminator: over-training the generator may destabilize learning and lead to worse results. We find that the BGAN objective is resilient to such over-training.

To test this, we train on the CIFAR-10 dataset using a simple DCGAN architecture. We use the original GAN objective for the discriminator, but vary the generator loss as the variational lower-bound, the proxy loss (i.e., the generator loss function used in Goodfellow et al., 2014), and the boundary-seeking loss (BGAN). To better study the effect of these losses, we update the generator for 55 steps for every discriminator step.

Our results (Figure 4) show that over-optimizing the generator significantly degrades sample quality. However, in this difficult setting, BGAN learns to generate reasonable samples in fewer epochs than other objective functions, demonstrating improved stability.

Following the generator gradient

We further test the different objectives by looking at the effect of gradient descent on the pixels. In this setting, we train a DCGAN (Radford et al., 2015) using the proxy loss. We then optimize the discriminator by training it for another 10001000 updates. Next, we perform gradient descent directly on the pixels, the original variational lower-bound, the proxy, and the boundary seeking losses separately.

Our results show that following the BGAN objective at the pixel-level causes the least degradation of image quality. This indicates that, in training, the BGAN objective is the least likely to disrupt adversarial learning.

Conclusion

Reinterpreting the generator objective to match the proposal target distribution reveals a novel learning algorithm for training a generative adversarial network (GANs, Goodfellow et al., 2014). This proposed approach of boundary-seeking provides us with a unified framework under which learning algorithms for both discrete and continuous variables are derived. Empirically, we verified our approach quantitatively and showed the effectiveness of training a GAN with the proposed learning algorithm, which we call a boundary-seeking GAN (BGAN), on both discrete and continuous variables, as well as demonstrated some properties of stability.

Acknowledgements

RDH thanks IVADO, MILA, UdeM, NIH grants R01EB006841 and P20GM103472, and NSF grant 1539067 for support. APJ thanks UWaterloo, Waterloo AI lab and MILA for their support and Michael Noukhovitch, Pascal Poupart for constructive discussions. KC thanks AdeptMind, TenCent, eBay, Google (Faculty Awards 2015, 2016), NVIDIA Corporation (NVAIL) and Facebook for their support. YB thanks CIFAR, NSERC, IBM, Google, Facebook and Microsoft for their support. We would like to thank Simon Sebbagh for his input and help with Theorem 2. Finally, we wish to thank the developers of Theano (Al-Rfou et al., 2016), Lasagne http://lasagne.readthedocs.io, and Fuel (Van Merriënboer et al., 2015) for their valuable code-base.

References

Appendix

In these experiments, we produce some quantitative measures for BGAN against WGAN with the gradient penalty (WGAN-GP, Gulrajani et al., 2017) on the discrete MNIST dataset. In order to use back-propagation to train the generator, WGAN-GP uses the softmax probabilities directly, bypassing the sampling process at pixel-level and problems associated with estimating gradients through discrete processes. Despite this, WGAN-GP is been able to produce samples that visually resemble the target dataset.

Here, we train 33 models on the discrete MNIST dataset using identical architectures with the BGAN with the JS and reverse KL ff-divergences and WGAN-GP objectives. Each model was trained for 300300 generator epochs, with the discriminator being updated 55 times per generator update for WGAN-GP and 11 time per generator update for the BGAN models (in other words, the generators were trained for the same number of updates). This model selection procedure was chosen as the difference measure (i.e., JSD, reverse KL divergence, and Wasserstein distance) as estimated during training converged for each model. WGAN-GP was trained with a gradient penalty hyper-parameter of 5.05.0, which did not differ from the suggested 10.010.0 in our experiments with discrete MNIST. The BGAN models were trained with the gradient norm penalty of 5.05.0 (Roth et al., 2017).

Next, for each model, we trained 33 new discriminators with double capacity (twice as many hidden units on each layer) to maximize the the JS and reverse KL divergences and Wasserstein distance, keeping the generators fixed. These discriminators were trained for 200200 epochs (chosen from convergence) with the same gradient-based regularizations as above. For all of these models, the discriminators were trained using the samples, as they would be used in practical applications. For comparison, we also trained an additional discriminator, evaluating the WGAN-GP model above on the Wasserstein distance using the softmax probabilities.

Final evaluation was done by estimating difference measures using 6000060000 MNIST training examples againt 6000060000 samples from each generator, averaged over 1212 batches of 50005000. We used the training set as this is the distribution over which the discriminators were trained. Test set estimates in general were close and did not diverge from training set distances, indicating the discriminators were not overfitting, but training set estimates were slightly higher on average.

Our results show that the estimates from the sampling distribution from BGAN is consistently lower than that from WGAN-GP, even when evaluating using the Wasserstein distance. However, when training the discriminator on the softmax probabilities, WGAN-GP has a much lower Wasserstein distance. Despite quantitative differences, samples from these different models were indistinguishable as far as quality by visual inspection. This indicates that, though playing the adversarial game using the softmax outputs can generate realistic-looking samples, this procedure ultimately hurts the generator’s ability to model a truly discrete distribution.

2 Theoretical and empirical validation of the variance reduction method

Here we validate the policy gradient provided in Equation 10 theoretically and empirically.

As the conditional KL-divergence is has an absolute minimum at zero, the expectation can only be zero when the all of the conditional KL-divergences are zero. In other words:

In order to empirically evaluate the effect of using an Monte-Carlo estimate of β\beta from Equation 8 versus the variance-reducing method in Equation 10, we trained several models using various sample sizes from the prior, h(z)h(z), and the conditional, gθ(xz)g_{\theta}(x\mid z).

We compare both methods with 6464 samples from the prior and 55, 1010, and 100100 samples from the conditional. In addition, we compare to a model that estimates β\beta using 640640 samples from the prior and a single sample from the conditional. These models were all run on discrete MNIST for 5050 epochs with the same architecture as those from Section 4.2 with a gradient penalty of 1.01.0, which was the minimum needed to ensure stability in nearly all the models.

Our results (Figure 6) show a clear improvement using the variance-reducing method from Equation 10 over estimating β\beta. Wall-clock times were nearly identical for methods using the same number of total samples (blue, green, and red dashed and solid line pairs). Both methods improve as the number of conditional samples is increased.