Adversarial Variational Bayes: Unifying Variational Autoencoders and Generative Adversarial Networks

Lars Mescheder, Sebastian Nowozin, Andreas Geiger

Introduction

Generative models in machine learning are models that can be trained on an unlabeled dataset and are capable of generating new data points after training is completed. As generating new content requires a good understanding of the training data at hand, such models are often regarded as a key ingredient to unsupervised learning.

In recent years, generative models have become more and more powerful. While many model classes such as PixelRNNs (van den Oord et al., 2016b), PixelCNNs (van den Oord et al., 2016a), real NVP (Dinh et al., 2016) and Plug & Play generative networks (Nguyen et al., 2016) have been introduced and studied, the two most prominent ones are Variational Autoencoders (VAEs) (Kingma & Welling, 2013; Rezende et al., 2014) and Generative Adversarial Networks (GANs) (Goodfellow et al., 2014).

Both VAEs and GANs come with their own advantages and disadvantages: while GANs generally yield visually sharper results when applied to learning a representation of natural images, VAEs are attractive because they naturally yield both a generative model and an inference model. Moreover, it was reported, that VAEs often lead to better log-likelihoods (Wu et al., 2016). The recently introduced BiGANs (Donahue et al., 2016; Dumoulin et al., 2016) add an inference model to GANs. However, it was observed that the reconstruction results often only vaguely resemble the input and often do so only semantically and not in terms of pixel values.

The failure of VAEs to generate sharp images is often attributed to the fact that the inference models used during training are usually not expressive enough to capture the true posterior distribution. Indeed, recent work shows that using more expressive model classes can lead to substantially better results (Kingma et al., 2016), both visually and in terms of log-likelihood bounds. Recent work (Chen et al., 2016) also suggests that highly expressive inference models are essential in presence of a strong decoder to allow the model to make use of the latent space at all.

In this paper, we present Adversarial Variational Bayes (AVB) Concurrently to our work, several researchers have described similar ideas. Some ideas of this paper were described independently by Huszár in a blog post on http://www.inference.vc and in Huszár (2017). The idea to use adversarial training to improve the encoder network was also suggested by Goodfellow in an exploratory talk he gave at NIPS 2016 and by Li & Liu (2016). A similar idea was also mentioned by Karaletsos (2016) in the context of message passing in graphical models. , a technique for training Variational Autoencoders with arbitrarily flexible inference models parameterized by neural networks. We can show that in the nonparametric limit we obtain a maximum-likelihood assignment for the generative model together with the correct posterior distribution.

While there were some attempts at combining VAEs and GANs (Makhzani et al., 2015; Larsen et al., 2015), most of these attempts are not motivated from a maximum-likelihood point of view and therefore usually do not lead to maximum-likelihood assignments. For example, in Adversarial Autoencoders (AAEs) (Makhzani et al., 2015) the Kullback-Leibler regularization term that appears in the training objective for VAEs is replaced with an adversarial loss that encourages the aggregated posterior to be close to the prior over the latent variables. Even though AAEs do not maximize a lower bound to the maximum-likelihood objective, we show in Section 6.2 that AAEs can be interpreted as an approximation to our approach, thereby establishing a connection of AAEs to maximum-likelihood learning.

Outside the context of generative models, AVB yields a new method for performing Variational Bayes (VB) with neural samplers. This is illustrated in Figure 1, where we used AVB to train a neural network to sample from a non-trival unnormalized probability density. This allows to accurately approximate the posterior distribution of a probabilistic model, e.g. for Bayesian parameter estimation. The only other variational methods we are aware of that can deal with such expressive inference models are based on Stein Discrepancy (Ranganath et al., 2016; Liu & Feng, 2016). However, those methods usually do not directly target the reverse Kullback-Leibler-Divergence and can therefore not be used to approximate the variational lower bound for learning a latent variable model.

We enable the usage of arbitrarily complex inference models for Variational Autoencoders using adversarial training.

We give theoretical insights into our method, showing that in the nonparametric limit our method recovers the true posterior distribution as well as a true maximum-likelihood assignment for the parameters of the generative model.

We empirically demonstrate that our model is able to learn rich posterior distributions and show that the model is able to generate compelling samples for complex data sets.

Background

As our model is an extension of Variational Autoencoders (VAEs) (Kingma & Welling, 2013; Rezende et al., 2014), we start with a brief review of VAEs.

VAEs are specified by a parametric generative model pθ(x∣z)p_{\theta}(x\mid z) of the visible variables given the latent variables, a prior p(z)p(z) over the latent variables and an approximate inference model qϕ(z∣x)q_{\phi}(z\mid x) over the latent variables given the visible variables. It can be shown that

The right hand side of (2.1) is called the variational lower bound or evidence lower bound (ELBO). If there is ϕ\phi such that qϕ(z∣x)=pθ(z∣x)q_{\phi}(z\mid x)=p_{\theta}(z\mid x), we would have

However, in general this is not true, so that we only have an inequality in (2.2).

When performing maximum-likelihood training, our goal is to optimize the marginal log-likelihood

where pDp_{\mathcal{D}} is the data distribution. Unfortunately, computing log⁡pθ(x)\log p_{\theta}(x) requires marginalizing out zz in pθ(x,z)p_{\theta}(x,z) which is usually intractable. Variational Bayes uses inequality (2.1) to rephrase the intractable problem of optimizing (2.3) into

Due to inequality (2.1), we still optimize a lower bound to the true maximum-likelihood objective (2.3).

Naturally, the quality of this lower bound depends on the expressiveness of the inference model qϕ(z∣x)q_{\phi}(z\mid x). Usually, qϕ(z∣x)q_{\phi}(z\mid x) is taken to be a Gaussian distribution with diagonal covariance matrix whose mean and variance vectors are parameterized by neural networks with xx as input (Kingma & Welling, 2013; Rezende et al., 2014). While this model is very flexible in its dependence on xx, its dependence on zz is very restrictive, potentially limiting the quality of the resulting generative model. Indeed, it was observed that applying standard Variational Autoencoders to natural images often results in blurry images (Larsen et al., 2015).

Method

In this work we show how we can instead use a black-box inference model qϕ(z∣x)q_{\phi}(z\mid x) and use adversarial training to obtain an approximate maximum likelihood assignment θ∗\theta^{*} to θ\theta and a close approximation qϕ∗(z∣x)q_{\phi^{*}}(z\mid x) to the true posterior pθ∗(z∣x)p_{\theta^{*}}(z\mid x). This is visualized in Figure 2: on the left hand side the structure of a typical VAE is shown. The right hand side shows our flexible black-box inference model. In contrast to a VAE with Gaussian inference model, we include the noise ϵ1\epsilon_{1} as additional input to the inference model instead of adding it at the very end, thereby allowing the inference network to learn complex probability distributions.

To derive our method, we rewrite the optimization problem in (2.4) as

When we have an explicit representation of qϕ(z∣x)q_{\phi}(z\mid x) such as a Gaussian parameterized by a neural network, (3.1) can be optimized using the reparameterization trick (Kingma & Welling, 2013; Rezende & Mohamed, 2015) and stochastic gradient descent. Unfortunately, this is not the case when we define qϕ(z∣x)q_{\phi}(z\mid x) by a black-box procedure as illustrated in Figure 2(b).

The idea of our approach is to circumvent this problem by implicitly representing the term

as the optimal value of an additional real-valued discriminative network T(x,z)T(x,z) that we introduce to the problem.

More specifically, consider the following objective for the discriminator T(x,z)T(x,z) for a given qϕ(x∣z)q_{\phi}(x\mid z):

To simplify the theoretical analysis, we assume that the model T(x,z)T(x,z) is flexible enough to represent any function of the two variables xx and zz. This assumption is often referred to as the nonparametric limit (Goodfellow et al., 2014) and is justified by the fact that deep neural networks are universal function approximators (Hornik et al., 1989).

As it turns out, the optimal discriminator T∗(x,z)T^{*}(x,z) according to the objective in (3.3) is given by the negative of (3.2).

For pθ(x∣z)p_{\theta}(x\mid z) and qϕ(z∣x)q_{\phi}(z\mid x) fixed, the optimal discriminator T∗T^{*} according to the objective in (3.3) is given by

The proof is analogous to the proof of Proposition 1 in Goodfellow et al. (2014). See the Supplementary Material

Together with (3.1), Proposition 1 allows us to write the optimization objective in (2.4) as

where T∗(x,z)T^{*}(x,z) is defined as the function that maximizes (3.3).

To optimize (3.5), we need to calculate the gradients of (3.5) with respect to θ\theta and ϕ\phi. While taking the gradient with respect to θ\theta is straightforward, taking the gradient with respect to ϕ\phi is complicated by the fact that we have defined T∗(x,z)T^{*}(x,z) indirectly as the solution of an auxiliary optimization problem which itself depends on ϕ\phi. However, the following Proposition shows that taking the gradient with respect to the explicit occurrence of ϕ\phi in T∗(x,z)T^{*}(x,z) is not necessary:

The proof can be found in the Supplementary Material. ∎

Using the reparameterization trick (Kingma & Welling, 2013; Rezende et al., 2014), (3.5) can be rewritten in the form

for a suitable function zϕ(x,ϵ)z_{\phi}(x,\epsilon). Together with Proposition 1, (3.7) allows us to take unbiased estimates of the gradients of (3.5) with respect to ϕ\phi and θ\theta.

2 Algorithm

In theory, Propositions 1 and 2 allow us to apply Stochastic Gradient Descent (SGD) directly to the objective in (2.4). However, this requires keeping T∗(x,z)T^{*}(x,z) optimal which is computationally challenging. We therefore regard the optimization problems in (3.3) and (3.7) as a two-player game. Propositions 1 and 2 show that any Nash-equilibrium of this game yields a stationary point of the objective in (2.4).

In practice, we try to find a Nash-equilibrium by applying SGD with step sizes hih_{i} jointly to (3.3) and (3.7), see Algorithm 1. Here, we parameterize the neural network TT with a vector ψ\psi. Even though we have no guarantees that this algorithm converges, any fix point of this algorithm yields a stationary point of the objective in (2.4).

Note that optimizing (3.5) with respect to ϕ\phi while keeping θ\theta and TT fixed makes the encoder network collapse to a deterministic function. This is also a common problem for regular GANs (Radford et al., 2015). It is therefore crucial to keep the discriminative TT network close to optimality while optimizing (3.5). A variant of Algorithm 1 therefore performs several SGD-updates for the adversary for one SGD-update of the generative model. However, throughout our experiments we use the simple 11-step version of AVB unless stated otherwise.

3 Theoretical results

In Sections 3.1 we derived AVB as a way of performing stochastic gradient descent on the variational lower bound in (2.4). In this section, we analyze the properties of Algorithm 1 from a game theoretical point of view.

As the next proposition shows, global Nash-equilibria of Algorithm 1 yield global optima of the objective in (2.4):

Assume that TT can represent any function of two variables. If (θ∗,ϕ∗,T∗)(\theta^{*},\phi^{*},T^{*}) defines a Nash-equilibrium of the two-player game defined by (3.3) and (3.7),

and (θ∗,ϕ∗)(\theta^{*},\phi^{*}) is a global optimum of the variational lower bound in (2.4).

The proof can be found in the Supplementary Material. ∎

Our parameterization of qϕ(z∣x)q_{\phi}(z\mid x) as a neural network allows qϕ(z∣x)q_{\phi}(z\mid x) to represent almost any probability density on the latent space. This motivates

Assume that TT can represent any function of two variables and qϕ(z∣x)q_{\phi}(z\mid x) can represent any probability density on the latent space. If (θ∗,ϕ∗,T∗)(\theta^{*},\phi^{*},T^{*}) defines a Nash-equilibrium for the game defined by (3.3) and (3.7), then

θ∗\theta^{*} is a maximum-likelihood assignment

qϕ∗(z∣x)q_{\phi^{*}}(z\mid x) is equal to the true posterior pθ∗(z∣x)p_{\theta^{*}}(z\mid x)

T∗T^{*} is the pointwise mutual information between xx and zz, i.e.

This is a straightforward consequence of Proposition 3, as in this case (θ∗,ϕ∗)(\theta^{*},\phi^{*}) optimizes the variational lower bound in (2.4) if and only if 1 and 2 hold. Inserting the result from 2 into (3.8) yields 3. ∎

Adaptive Contrast

While in the nonparametric limit our method yields the correct results, in practice T(x,z)T(x,z) may fail to become sufficiently close to the optimal function T∗(x,z)T^{*}(x,z). The reason for this problem is that AVB calculates a contrast between the two densities pD(x)qϕ(z∣x)p_{\mathcal{D}}(x)q_{\phi}(z\mid x) to pD(x)p(z)p_{\mathcal{D}}(x)p(z) which are usually very different. However, it is known that logistic regression works best for likelihood-ratio estimation when comparing two very similar densities (Friedman et al., 2001).

To improve the quality of the estimate, we therefore propose to introduce an auxiliary conditional probability distribution rα(z∣x)r_{\alpha}(z\mid x) with known density that approximates qϕ(z∣x)q_{\phi}(z\mid x). For example, rα(z∣x)r_{\alpha}(z\mid x) could be a Gaussian distribution with diagonal covariance matrix whose mean and variance matches the mean and variance of qϕ(z∣x)q_{\phi}(z\mid x).

Using this auxiliary distribution, we can rewrite the variational lower bound in (2.4) as

We call this technique Adaptive Contrast (AC), as we are now contrasting the current inference model qϕ(z∣x)q_{\phi}(z\mid x) to an adaptive distribution rα(z∣x)r_{\alpha}(z\mid x) instead of the prior p(z)p(z). Using Adaptive Contrast, the generative model pθ(x∣z)p_{\theta}(x\mid z) and the inference model qϕ(z∣x)q_{\phi}(z\mid x) are trained to maximize

where T∗(x,z)T^{*}(x,z) is the optimal discriminator distinguishing samples from rα(z∣x)r_{\alpha}(z\mid x) and qϕ(z∣x)q_{\phi}(z\mid x).

Consider now the case that rα(z∣x)r_{\alpha}(z\mid x) is given by a Gaussian distribution with diagonal covariance matrix whose mean μ(x)\mu(x) and variance vector σ(x)\sigma(x) match the mean and variance of qϕ(z∣x)q_{\phi}(z\mid x). As the Kullback-Leibler divergence is invariant under reparameterization, the first term in (4.1) can be rewritten as

In practice, we estimate μ(x)\mu(x) and σ(x)\sigma(x) using a Monte-Carlo estimate. In the Supplementary Material we describe a network architecture for qϕ(z∣x)q_{\phi}(z\mid x) that makes the computation of this estimate particularly efficient.

Experiments

We tested our method both as a black-box method for variational inference and for learning generative models. The former application corresponds to the case where we fix the generative model and a data point xx and want to learn the posterior qϕ(z∣x)q_{\phi}(z\mid x).

An additional experiment on the celebA dataset (Liu et al., 2015) can be found in the Supplementary Material.

When the generative model and a data point xx is fixed, AVB gives a new technique for Variational Bayes with arbitrarily complex approximating distributions. We applied this to the “Eight School” example from Gelman et al. (2014). In this example, the coaching effects yiy_{i}, i=1,…,8i=1,\dots,8 for eight schools are modeled as

where μ\mu, τ\tau and the ηi\eta_{i} are the model parameters to be inferred. We place a N(0,1)\mathcal{N}(0,1) prior on the parameters of the model. We compare AVB against two variational methods with Gaussian inference model (Kucukelbir et al., 2015) as implemented in STAN (Stan Development Team, 2016). We used a simple two layer model for the posterior and a powerful 55-layer network with RESNET-blocks (He et al., 2015) for the discriminator. For every posterior update step we performed two steps for the adversary. The ground-truth data was obtained by running Hamiltonian Monte-Carlo (HMC) for 500000 steps using STAN. Note that AVB and the baseline variational methods allow to draw an arbitrary number of samples after training is completed whereas HMC only yields a fixed number of samples.

We evaluate all methods by estimating the Kullback-Leibler-Divergence to the ground-truth data using the ITE-package (Szabo, 2013) applied to 1000010000 samples from the ground-truth data and the respective approximation. The resulting Kullback-Leibler divergence over the number of iterations for the different methods is plotted in Figure 3. We see that our method clearly outperforms the methods with Gaussian inference model. For a qualitative visualization, we also applied Kernel-density-estimation to the 2-dimensional marginals of the (μ,τ)(\mu,\tau)- and (τ,η1)(\tau,\eta_{1})-variables as illustrated in Figure 4. In contrast to variational Bayes with Gaussian inference model, our approach clearly captures the multi-modality of the posterior distribution. We also observed that Adaptive Contrast makes learning more robust and improves the quality of the resulting model.

2 Generative Models

To illustrate the application of our method to learning a generative model, we trained the neural networks on a simple synthetic dataset containing only the 44 data points from the space of 2×22\times 2 binary images shown in Figure 6 and a 22-dimensional latent space. Both the encoder and decoder are parameterized by 2-layer fully connected neural networks with 512 hidden units each. The encoder network takes as input a data point xx and a vector of Gaussian random noise ϵ\epsilon and produces a latent code zz. The decoder network takes as input a latent code zz and produces the parameters for four independent Bernoulli-distributions, one for each pixel of the output image. The adversary is parameterized by two neural networks with two 512512-dimensional hidden layers each, acting on xx and zz respectively, whose 512512-dimensional outputs are combined using an inner product.

We compare our method to a Variational Autoencoder with a diagonal Gaussian posterior distribution. The encoder and decoder networks are parameterized as above, but the encoder does not take the noise ϵ\epsilon as input and produces a mean and variance vector instead of a single sample.

The ability of AVB to learn more complex posterior models leads to improved performance as Table 1 shows. In particular, AVB leads to a higher likelihood score that is close to the optimal value of −log⁡(4)-\log(4) compared to a standard VAE that struggles with the fact that it cannot divide the latent space appropriately. Moreover, we see that the reconstruction error given by the mean cross-entropy between an input xx and its reconstruction using the encoder and decoder networks is much lower when using AVB instead of a VAE with diagonal Gaussian inference model. We also observe that the estimated variational lower bound is close to the true log-likelihood, indicating that the adversary has learned the correct function.

MNIST

In addition, we trained deep convolutional networks based on the DC-GAN-architecture (Radford et al., 2015) on the binarized MNIST-dataset (LeCun et al., 1998). For the decoder network, we use a 55-layer deep convolutional neural network. For the encoder network, we use a network architecture that allows for the efficient computation of the moments of qϕ(z∣x)q_{\phi}(z\mid x). The idea is to define the encoder as a linear combination of learned basis noise vectors, each parameterized by a small fully-connected neural network, whose coefficients are parameterized by a neural network acting on xx, please see the Supplementary Material for details. For the adversary, we replace the fully connected neural network acting on zz and xx with a fully connected 44-layer neural networks with 10241024 units in each hidden layer. In addition, we added the result of neural networks acting on xx and zz alone to the end result.

To validate our method, we ran Annealed Importance Sampling (AIS) (Neal, 2001), the gold standard for evaluating decoder based generative models (Wu et al., 2016) with 10001000 intermediate distributions and 55 parallel chains on 20482048 test examples. The results are reported in Table 2. Using AIS, we see that AVB without AC overestimates the true ELBO which degrades its performance. Even though the results suggest that AVB with AC can also overestimate the true ELBO in higher dimensions, we note that the log-likelihood estimate computed by AIS is also only a lower bound to the true log-likelihood (Wu et al., 2016).

Using AVB with AC, we see that we improve both on a standard VAE and AVB without AC. When comparing to other state of the art methods, we see that our method achieves state of the art results on binarized MNISTNote that the methods in the lower half of Table 2 were trained with different decoder architectures and therefore only provide limited information regarding the quality of the inference model.. For an additional experimental evaluation of AVB and three baselines for a fixed decoder architecture see the Supplementary Material. Some random samples for MNIST are shown in Figure 7. We see that our model produces random samples that are perceptually close to the training set.

Related Work

AVB strives to optimize the same objective as a standard VAE (Kingma & Welling, 2013; Rezende et al., 2014), but approximates the Kullback-Leibler divergence using an adversary instead of relying on a closed-form formula.

Substantial work has focused on making the class of approximate inference models more expressive. Normalizing flows (Rezende & Mohamed, 2015; Kingma et al., 2016) make the posterior more complex by composing a simple Gaussian posterior with an invertible smooth mapping for which the determinant of the Jacobian is tractable. Auxiliary Variable VAEs (Maaløe et al., 2016) add auxiliary variables to the posterior to make it more flexible. However, no other approach that we are aware of allows to use black-box inference models to optimize the ELBO.

2 Connection to Adversarial Autoencoders

Makhzani et al. (Makhzani et al., 2015) introduced the concept of Adversarial Autoencoders. The idea is to replace the term

in (2.4) with an adversarial loss that tries to enforce that upon convergence

While related to our approach, the approach by Makhzani et al. modifies the variational objective while our approach retains the objective.

The approach by Makhzani et al. can be regarded as an approximation to our approach, where T(x,z)T(x,z) is restricted to the class of functions that do not depend on xx. Indeed, an ideal discriminator that only depends on zz maximizes

Clearly, this simplification is a crude approximation to our formulation from Section 3, but Makhzani et al. (2015) show that this method can still lead to good sampling results. In theory, restricting T(x,z)T(x,z) in this way ensures that upon convergence we approximately have

but qϕ(z∣x)q_{\phi}(z\mid x) need not be close to the true posterior pθ(z∣x)p_{\theta}(z\mid x). Intuitively, while mapping pD(x)p_{\mathcal{D}}(x) through qϕ(z∣x)q_{\phi}(z\mid x) results in the correct marginal distribution, the contribution of each xx to this distribution can be very inaccurate.

In contrast to Adversarial Autoencoders, our goal is to improve the ELBO by performing better probabilistic inference. This allows our method to be used in a more general setting where we are only interested in the inference network itself (Section 5.1) and enables further improvements such as Adaptive Contrast (Section 4) which are not possible in the context of Adversarial Autoencoders.

3 Connection to f-GANs

Nowozin et al. (Nowozin et al., 2016) proposed to generalize Generative Adversarial Networks (Goodfellow et al., 2014) to f-divergences (Ali & Silvey, 1966) based on results by Nguyen et al. (Nguyen et al., 2010). In this paragraph we show that f-divergences allow to represent AVB as a zero-sum two-player game.

Nguyen et al. (2010) show that by using the convex conjugate f∗f^{*} of ff, (Hiriart-Urruty & Lemaréchal, 2013), we obtain

where TT is a real-valued function. In particular, this is true for the reverse Kullback-Leibler divergence with f(t)=tlog⁡tf(t)=t\log t. We therefore obtain

with f∗(ξ)=exp⁡(ξ−1)f^{*}(\xi)=\exp(\xi-1) the convex conjugate of f(t)=tlog⁡tf(t)=t\log t.

By replacing the objective (3.3) for the discriminator with

we can reformulate the maximum-likelihood-problem as a mini-max zero-sum game. In fact, the derivations from Section 3 remain valid for any ff -divergence that we use to train the discriminator. This is similar to the approach taken by Poole et al. (Poole et al., 2016) to improve the GAN-objective. In practice, we observed that the objective (6.10) results in unstable training. We therefore used the standard GAN-objective (3.3), which corresponds to the Jensen-Shannon-divergence.

4 Connection to BiGANs

BiGANs (Donahue et al., 2016; Dumoulin et al., 2016) are a recent extension to Generative Adversarial Networks with the goal to add an inference network to the generative model. Similarly to our approach, the authors introduce an adversary that acts on pairs (x,z)(x,z) of data points and latent codes. However, whereas in BiGANs the adversary is used to optimize the generative and inference networks separately, our approach optimizes the generative and inference model jointly. As a result, our approach obtains good reconstructions of the input data, whereas for BiGANs we obtain these reconstructions only indirectly.

Conclusion

We presented a new training procedure for Variational Autoencoders based on adversarial training. This allows us to make the inference model much more flexible, effectively allowing it to represent almost any family of conditional distributions over the latent variables.

We believe that further progress can be made by investigating the class of neural network architectures used for the adversary and the encoder and decoder networks as well as finding better contrasting distributions.

Acknowledgements

This work was supported by Microsoft Research through its PhD Scholarship Programme.

References

I Proofs

This section contains the proofs that were omitted in the main text.

The derivation of AVB in Section 3.1 relies on the fact that we have an explicit representation of the optimal discriminator T∗(x,z)T^{*}(x,z). This was stated in the following Proposition:

As in the proof of Proposition 1 in Goodfellow et al. (2014), we rewrite the objective in (3.3) as

This integral is maximal as a function of T(x,z)T(x,z) if and only if the integrand is maximal for every (x,z)(x,z). However, the function

attains its maximum at t=aa+bt=\tfrac{a}{a+b}, showing that

To apply our method in practice, we need to obtain unbiased gradients of the ELBO. As it turns out, this can be achieved by taking the gradients w.r.t. a fixed optimal discriminator. This is a consequence of the following Proposition: See 2

For an arbitrary family of probability densities qϕq_{\phi} we have

Together with (I.5), this implies (3.6). ∎

In Section 3.3 we characterized the Nash-equilibria of the two-player game defined by our algorithm. The following Proposition shows that in the nonparametric limit for T(x,z)T(x,z) any Nash-equilibrium defines a global optimum of the variational lower bound:

If (θ∗,ϕ∗,T∗)(\theta^{*},\phi^{*},T^{*}) defines a Nash-equilibrium, Proposition 1 shows (3.8). Inserting (3.8) into (3.5) shows that (ϕ∗,θ∗)(\phi^{*},\theta^{*}) maximizes

as a function of ϕ\phi and θ\theta. A straightforward calculation shows that (I.7) is equal to

Notice that (I.8) evaluates to L(θ∗,ϕ∗)\mathcal{L}(\theta^{*},\phi^{*}) when we insert (θ∗,ϕ∗)(\theta^{*},\phi^{*}) for (θ,ϕ)(\theta,\phi).

Assume now, that (θ∗,ϕ∗)(\theta^{*},\phi^{*}) does not maximize the variational lower bound L(θ,ϕ)\mathcal{L}(\theta,\phi). Then there is (θ′,ϕ′)(\theta^{\prime},\phi^{\prime}) with

Inserting (θ′,ϕ′)(\theta^{\prime},\phi^{\prime}) for (θ,ϕ)(\theta,\phi) in (I.8) we obtain

which is strictly bigger than L(θ∗,ϕ∗)\mathcal{L}(\theta^{*},\phi^{*}), contradicting the fact that (θ∗,ϕ∗)(\theta^{*},\phi^{*}) maximizes (I.8). Together with (3.8), this proves the theorem. ∎

II Adaptive Contrast

In Section 4 we derived a variant of AVB that contrasts the current inference model with an adaptive distribution rather than the prior. This leads to Algorithm 2. Note that we do not consider the μ(k)\mu^{(k)} and σ(k)\sigma^{(k)} to be functions of ϕ\phi and therefore do not backpropagate gradients through them.

III Architecture for MNIST-experiment

To apply Adaptive Contrast to our method, we have to be able to efficiently estimate the moments of the current inference model qϕ(z∣x)q_{\phi}(z\mid x). To this end, we propose a network architecture like in Figure 8. The final output zz of the network is a linear combination of basis noise vectors where the coefficients depend on the data point xx, i.e.

The noise basis vectors vi(ϵi)v_{i}(\epsilon_{i}) are defined as the output of small fully-connected neural networks fif_{i} acting on normally-distributed random noise ϵi\epsilon_{i}, the coefficient vectors ai(x)a_{i}(x) are defined as the output of a deep convolutional neural network gg acting on xx.

The moments of the ziz_{i} are then given by

IV Additional Experiments

We also used AVB (without AC) to train a deep convolutional network on the celebA-dataset (Liu et al., 2015) for a 6464-dimensional latent space with N(0,1)\mathcal{N}(0,1)-prior. For the decoder and adversary we use two deep convolutional neural networks acting on xx like in Radford et al. (2015). We add the noise ϵ\epsilon and the latent code zz to each hidden layer via a learned projection matrix. Moreover, in the encoder and decoder we use three RESNET-blocks (He et al., 2015) at each scale of the neural network. We add the log-prior log⁡p(z)\log p(z) explicitly to the adversary T(x,z)T(x,z), so that it only has to learn the log-density of the inference model qϕ(z∣x)q_{\phi}(z\mid x).

The samples for celebA are shown in Figure 10. We see that our model produces visually sharp images of faces. To demonstrate that the model has indeed learned an abstract representation of the data, we show reconstruction results and the result of linearly interpolating the zz-vector in the latent space in Figure 10. We see that the reconstructions are reasonably sharp and the model produces realistic images for all interpolated zz-values.

MNIST

To evaluate how AVB with adaptive contrast compares against other methods on a fixed decoder architecture, we reimplemented the methods from Maaløe et al. (2016) and Kingma et al. (2016). The method from Maaløe et al. (2016) tries to make the variational approximation to the posterior more flexible by using auxiliary variables, the method from Kingma et al. (2016) tries to improve the variational approximation by employing an Inverse Autoregressive Flow (IAF), a particularly flexible instance of a normalizing flow (Rezende & Mohamed, 2015). In our experiments, we compare AVB with adaptive contrast to a standard VAE with diagonal Gaussian inference model as well as the methods from Maaløe et al. (2016) and Kingma et al. (2016).

In our first experiment, we evaluate all methods on training a decoder that is given by a fully-connected neural network with ELU-nonlinearities and two hidden layers with 300300 units each. The prior distribution p(z)p(z) is given by a 3232-dimensional standard-Gaussian distribution.

The results are shown in Table 3(a). We observe, that both AVB and the VAE with auxiliary variables achieve a better (approximate) ELBO than a standard VAE. When evaluated using AIS, both methods result in similar log-likelihoods. However, AVB results in a better reconstruction error than an auxiliary variable VAE and a better (approximate) ELBO. We observe that our implementation of a VAE with IAF did not improve on a VAE with diagonal Gaussian inference model. We suspect that this due to optimization difficulties.

In our second experiment, we train a decoder that is given by the shallow convolutional neural network described in Salimans et al. (2015) with 800800 units in the last fully-connected hidden layer. The prior distribution p(z)p(z) is given by either a 88-dimensional or a 3232-dimensional standard-Gaussian distribution.

The results are shown in Table 3(b) and Table 3(c). Even though AVB achieves a better (approximate) ELBO and a better reconstruction error for a 3232-dimensional latent space, all methods achieve similar log-likelihoods for this decoder-architecture, raising the question if strong inference models are always necessary to obtain a good generative model. Moreover, we found that neither auxiliary variables nor IAF did improve the ELBO. Again, we believe this is due to optimization challenges.