Adversarial Symmetric Variational Autoencoder
Yunchen Pu, Weiyao Wang, Ricardo Henao, Liqun Chen, Zhe Gan, Chunyuan Li, Lawrence Carin
Introduction
Recently there has been increasing interest in developing generative models of data, offering the promise of learning based on the often vast quantity of unlabeled data. With such learning, one typically seeks to build rich, hierarchical probabilistic models that are able to fit to the distribution of complex real data, and are also capable of realistic data synthesis.
Generative models are often characterized by latent variables (codes), and the variability in the codes encompasses the variation in the data . The generative adversarial network (GAN) employs a generative model in which the code is drawn from a simple distribution (, isotropic Gaussian), and then the code is fed through a sophisticated deep neural network (decoder) to manifest the data. In the context of data synthesis, GANs have shown tremendous capabilities in generating realistic, sharp images from models that learn to mimic the structure of real data . The quality of GAN-generated images has been evaluated by somewhat ad hoc metrics like inception score .
However, the original GAN formulation does not allow inference of the underlying code, given observed data. This makes it difficult to quantify the quality of the generative model, as it is not possible to compute the quality of model fit to data. To provide a principled quantitative analysis of model fit, not only should the generative model synthesize realistic-looking data, one also desires the ability to infer the latent code given data (using an encoder). Recent GAN extensions have sought to address this limitation by learning an inverse mapping (encoder) to project data into the latent space, achieving encouraging results on semi-supervised learning. However, these methods still fail to obtain faithful reproductions of the input data, partly due to model underfitting when learning from a fully adversarial objective .
Variational autoencoders (VAEs) are designed to learn both an encoder and decoder, leading to excellent data reconstruction and the ability to quantify a bound on the log-likelihood fit of the model to data . In addition, the inferred latent codes can be utilized in downstream applications, including classification and image captioning . However, new images synthesized by VAEs tend to be unspecific and/or blurry, with relatively low resolution. These limitations of VAEs are becoming increasingly understood. Specifically, the traditional VAE seeks to maximize a lower bound on the log-likelihood of the generative model, and therefore VAEs inherit the limitations of maximum-likelihood (ML) learning . Specifically, in ML-based learning one optimizes the (one-way) Kullback-Leibler (KL) divergence between the distribution of the underlying data and the distribution of the model; such learning does not penalize a model that is capable of generating data that are different from that used for training.
Based on the above observations, it is desirable to build a generative-model learning framework with which one can compute and assess the log-likelihood fit to real (observed) data, while also being capable of generating synthetic samples of high realism. Since GANs and VAEs have complementary strengths, their integration appears desirable, with this a principal contribution of this paper. While integration seems natural, we make important changes to both the VAE and GAN setups, to leverage the best of both. Specifically, we develop a new form of the variational lower bound, manifested jointly for the expected log-likelihood of the observed data and for the latent codes. Optimizing this variational bound involves maximizing the expected log-likelihood of the data and codes, while simultaneously minimizing a symmetric KL divergence involving the joint distribution of data and codes. To compute parts of this variational lower bound, a new form of adversarial learning is invoked. The proposed framework is termed Adversarial Symmetric VAE (AS-VAE), since within the model () the data and codes are treated in a symmetric manner, () a symmetric form of KL divergence is minimized when learning, and () adversarial training is utilized. To illustrate the utility of AS-VAE, we perform an extensive set of experiments, demonstrating state-of-the-art data reconstruction and generation on several benchmarks datasets.
Background and Foundations
Consider an observed data sample , modeled as being drawn from , with model parameters and latent code . The prior distribution on the code is denoted , typically a distribution that is easy to draw from, such as isotropic Gaussian. The posterior distribution on the code given data is , and since this is typically intractable, it is approximated as , parameterized by learned parameters . Conditional distributions and are typically designed such that they are easily sampled and, for flexibility, modeled in terms of neural networks . Since is a latent code for , is also termed a stochastic encoder, with a corresponding stochastic decoder. The observed data are assumed drawn from , for which we do not have an explicit form, but from which we have samples, i.e., the ensemble used for learning.
Our goal is to learn the model such that it synthesizes samples that are well matched to those drawn from . We simultaneously seek to learn a corresponding encoder that is both accurate and efficient to implement. Samples are synthesized via with ; provides an efficient coding of observed , that may be used for other purposes (, classification or caption generation when is an image ).
Maximum likelihood (ML) learning of based on direct evaluation of is typically intractable. The VAE seeks to bound by maximizing variational expression , with respect to parameters , where
Maximizing wrt provides a lower bound on , hence the VAE setup is an approximation to ML learning of . Learning based on is equivalent to learning based on minimizing , again implemented in terms of the observed samples of . As discussed in , such learning does not penalize severely for yielding of relatively high probability in while being simultaneously of low probability in . This means that seeks to match to the properties of the observed data samples, but may also have high probability of generating samples that do not look like data drawn from . This is a fundamental limitation of ML-based learning , inherited by the traditional VAE in (1).
One reason for the failing of ML-based learning of is that the cumulative posterior on latent codes is typically different from , which implies that , with may yield samples that are different from those generated from . Hence, when learning one may seek to match to samples of , as done in (1), while simultaneously matching to samples of . The expression in (1) provides a variational bound for matching to samples of , thus one may naively think to simultaneously set a similar variational expression for , with these two variational expressions optimized jointly. However, to compute this additional variational expression we require an analytic expression for , which also means we need an analytic expression for , which we do not have.
Examining (2), we also note that approximates , which has limitations aligned with those discussed above for ML-based learning of . Analogous to the above discussion, we would also like to consider . So motivated, in Section 3 we develop a new form of variational lower bound, applicable to maximizing and , where is the -th of samples from . We demonstrate that this new framework leverages both and , by extending ideas from adversarial networks.
2 Adversarial Learning
The original idea of GAN was to build an effective generative model , with , as discussed above. There was no desire to simultaneously design an inference network . More recently, authors have devised adversarial networks that seek both and . As an important example, Adversarial Learned Inference (ALI) considers the following objective function:
where the expectations are approximated with samples, as in (1). The function , termed a discriminator, is typically implemented using a neural network with parameters . Note that in (3) we need only sample from and , avoiding the need for an explicit form for .
The framework in (3) can, in theory, match and , by finding a Nash equilibrium of their respective non-convex objectives . However, training of such adversarial networks is typically based on stochastic gradient descent, which is designed to find a local mode of a cost function, rather than locating an equilibrium . This objective mismatch may lead to the well-known instability issues associated with GAN training .
To alleviate this problem, some researchers add a regularization term, such as reconstruction loss or mutual information , to the GAN objective, to restrict the space of suitable mapping functions, thus avoiding some of the failure modes of GANs, i.e., mode collapsing. Below we will formally match the joint distributions as in (3), and reconstruction-based regularization will be manifested by generalizing the VAE setup via adversarial learning. Toward this goal we consider the following lemma, which is analogous to Proposition 1 in .
Consider Random Variables (RVs) and with joint distributions, and . The optimal discriminator for the following objective
is .
Under Lemma 1, we are able to estimate the and using the following corollary.
For RVs and with encoder joint distribution and decoder joint distribution , consider the following objectives:
If the parameters and are fixed, with the optimal discriminator for (5) and the optimal discriminator for (6), then
The proof is provided in the Appendix A. We also assume in Corollary 1.1 that and are sufficiently flexible such that there are parameters and capable of achieving the equalities in (7). Toward that end, and are implemented as - and -parameterized neural networks (details below), to encourage universal approximation .
Adversarial Symmetric Variational Auto-Encoder (AS-VAE)
A similar expression holds for , in terms of . This naturally suggests the cumulative variational expression
where and are updated using the adversarial objectives in (5) and (6), respectively.
In the original VAE, in which (1) was optimized, the reparametrization trick was invoked wrt , with samples and , as the expectation was performed wrt this distribution; this reparametrization is convenient for computing gradients wrt . In the AS-VAE in (10), expectations are also needed wrt . Hence, to implement gradients wrt , we also constitute a reparametrization of . Specifically, we consider samples with . in (10) is re-expressed as
The expectations in (11) are approximated via samples drawn from and , as well as samples of and . and can be implemented with a Gaussian assumption or via density transformation , detailed when presenting experiments in Section 5.
The complete objective of the proposed Adversarial Symmetric VAE (AS-VAE) requires the cumulative variational in (11), which we maximize wrt and as in (5) and (6), using the results in (7). Hence, we write
The following proposition characterizes the solutions of (12) in terms of the joint distributions of and .
The equilibrium for the min-max objective in (12) is achieved by specification if and only if (7) holds, and .
The proof is provided in the Appendix A. This theoretical result implies that () is an estimator that yields good reconstruction, and () matches the aggregated posterior to prior distribution .
Related Work
VAEs represent one of the most successful deep generative models developed recently. Aided by the reparameterization trick, VAEs can be trained with stochastic gradient descent. The original VAEs implement a Gaussian assumption for the encoder. More recently, there has been a desire to remove this Gaussian assumption. Normalizing flow employs a sequence of invertible transformation to make the distribution of the latent codes arbitrarily flexible. This work was followed by inverse auto-regressive flow , which uses recurrent neural networks to make the latent codes more expressive. More recently, SteinVAE applies Stein variational gradient descent to infer the distribution of latent codes, discarding the assumption of a parametric form of posterior distribution for the latent code. However, these methods are not able to address the fundamental limitation of ML-based models, as they are all based on the variational formulation in (1).
Experiments
We evaluate our model on three datasets: MNIST, CIFAR-10 and ImageNet. To balance performance and computational cost, and are approximated with a normalizing flow of length 80 for the MNIST dataset, and a Gaussian approximation for CIFAR-10 and ImageNet data. All network architectures are provided in the Appendix B. All parameters were initialized with Xavier , and optimized via Adam with learning rate 0.0001. We do not perform any dataset-specific tuning or regularization other than dropout . Early stopping is employed based on the average reconstruction loss of and on validation sets.
We show three types of results, using part of or all of our model to illustrate each component. () AS-VAE-r: This model is trained with the first half of the objective in (11) to maximize in (8); it is an ML-based method which focuses on reconstruction. () AS-VAE-g: This model is trained with the second half of the objective in (11) to maximize in (9); it can be considered as maximizing the likelihood of , and designed for generation. () AS-VAE: This is our proposed model, developed in Section 3.
To the authors’ knowledge, we are the first to report both inception score (IS) and NLL for natural images from a single model. For comparison, we implemented DCGAN and PixelCNN++ as baselines. The implementation of DCGAN is based on a similar network architecture as our model. Note that for NLL a lower value is better, whereas for IS a higher value is better.
Appendix A Proof
We start from a simple observation . The second term in (5) of the main paper can be rewritten as
Therefore, the objective function in (5) can be expressed as
This integral of (17) is maximal as a function of if and only if the integrand is maximal for every . Note that the problem achieves maximum at and . Hence, we have the optimal function of at
Similarly, we have .
Proof of Proposition 1
Assume achieves an equilibrium of (12) in the main paper. The Corollary 1.1 indicates that and .
The minimum of the first two terms is achieved if and only if , while the minimum of the last two terms is achieved at and , respectively. Note that if the joint match is achieved, the marginals will also match, which indicates that the optimal is achieved if and only if .
Appendix B Model Architecture
The model architectures are shown as following. For and , we use the same architecture but the parameters are not shared.