Hierarchical Implicit Models and Likelihood-Free Variational Inference

Dustin Tran, Rajesh Ranganath, David M. Blei

Introduction

Consider a model of coin tosses. With probabilistic models, one typically posits a latent probability, and supposes each toss is a Bernoulli outcome given this probability . After observing a collection of coin tosses, Bayesian analysis lets us describe our inferences about the probability.

However, we know from the laws of physics that the outcome of a coin toss is fully determined by its initial conditions (say, the impulse and angle of flip) . Therefore a coin toss’ randomness does not originate from a latent probability but in noisy initial parameters. This alternative model incorporates the physical system, better capturing the generative process. Furthermore the model is implicit, also known as a simulator: we can sample data from its generative process, but we may not have access to calculate its density .

Coin tosses are simple, but they serve as a building block for complex implicit models. These models, which capture the laws and theories of real-world physical systems, pervade fields such as population genetics , statistical physics , and ecology ; they underlie structural equation models in economics and causality ; and they connect deeply to generative adversarial networks (gans) , which use neural networks to specify a flexible implicit density .

Unfortunately, implicit models, including gans, have seen limited success outside specific domains. There are two reasons. First, it is unknown how to design implicit models for more general applications, exposing rich latent structure such as priors, hierarchies, and sequences. Second, existing methods for inferring latent structure in implicit models do not sufficiently scale to high-dimensional or large data sets. In this paper, we design a new class of implicit models and we develop a new algorithm for accurate and scalable inference.

For modeling, § 2 describes hierarchical implicit models, a class of Bayesian hierarchical models which only assume a process that generates samples. This class encompasses both simulators in the classical literature and those employed in gans. For example, we specify a Bayesian gan, where we place a prior on its parameters. The Bayesian perspective allows gans to quantify uncertainty and improve data efficiency. We can also apply them to discrete data; this setting is not possible with traditional estimation algorithms for gans .

For inference, § 3 develops likelihood-free variational inference (lfvi), which combines variational inference with density ratio estimation . Variational inference posits a family of distributions over latent variables and then optimizes to find the member closest to the posterior . Traditional approaches require a likelihood-based model and use crude approximations, employing a simple approximating family for fast computation. lfvi expands variational inference to implicit models and enables accurate variational approximations with implicit variational families: lfvi does not require the variational density to be tractable. Further, unlike previous Bayesian methods for implicit models, lfvi scales to millions of data points with stochastic optimization.

This work has diverse applications. First, we analyze a classical problem from the approximate Bayesian computation (abc) literature, where the model simulates an ecological system . We analyze 100,000 time series which is not possible with traditional methods. Second, we analyze a Bayesian gan, which is a gan with a prior over its weights. Bayesian gans outperform corresponding Bayesian neural networks with known likelihoods on several classification tasks. Third, we show how injecting noise into hidden units of recurrent neural networks corresponds to a deep implicit model for flexible sequence generation.

This paper connects closely to three lines of work. The first is Bayesian inference for implicit models, known in the statistics literature as approximate Bayesian computation (abc) . abc steps around the intractable likelihood by applying summary statistics to measure the closeness of simulated samples to real observations. While successful in many domains, abc has shortcomings. First, the results generated by abc depend heavily on the chosen summary statistics and the closeness measure. Second, as the dimensionality grows, closeness becomes harder to achieve. This is the classic curse of dimensionality.

The second is gans . gans have seen much interest since their conception, providing an efficient method for estimation in neural network-based simulators. Larsen et al., propose a hybrid of variational methods and gans for improved reconstruction. Chen et al., apply information penalties to disentangle factors of variation. Donahue et al., , Dumoulin et al., propose to match on an augmented space, simultaneously training the model and an inverse mapping from data to noise. Unlike any of the above, we develop models with explicit priors on latent variables, hierarchies, and sequences, and we generalize gans to perform Bayesian inference.

The final thread is variational inference with expressive approximations . The idea of casting the design of variational families as a modeling problem was proposed in Ranganath et al., 2016b . Further advances have analyzed variational programs —a family of approximations which only requires a process returning samples—and which has seen further interest . Implicit-like variational approximations have also appeared in auto-encoder frameworks and message passing . We build on variational programs for inferring implicit models.

Hierarchical Implicit Models

Hierarchical models play an important role in sharing statistical strength across examples . For a broad class of hierarchical Bayesian models, the joint distribution of the hidden and observed variables is

where xn{\boldsymbol{\mathbf{x}}}_{n} is an observation, zn{\boldsymbol{\mathbf{z}}}_{n} are latent variables associated to that observation (local variables), and β{\boldsymbol{\mathbf{\beta}}} are latent variables shared across observations (global variables). See Fig. 1 (left).

With hierarchical models, local variables can be used for clustering in mixture models, mixed memberships in topic models , and factors in probabilistic matrix factorization . Global variables can be used to pool information across data points for hierarchical regression , topic models , and Bayesian nonparametrics .

Hierarchical models typically use a tractable likelihood p(xnzn,β)p({\boldsymbol{\mathbf{x}}}_{n}\,|\,{\boldsymbol{\mathbf{z}}}_{n},{\boldsymbol{\mathbf{\beta}}}). But many likelihoods of interest, such as simulator-based models and generative adversarial networks , admit high fidelity to the true data generating process and do not admit a tractable likelihood. To overcome this limitation, we develop hierarchical implicit models (hims).

Hierarchical implicit models have the same joint factorization as Eq.1 but only assume that one can sample from the likelihood. Rather than define p(xnzn,β)p({\boldsymbol{\mathbf{x}}}_{n}\,|\,{\boldsymbol{\mathbf{z}}}_{n},{\boldsymbol{\mathbf{\beta}}}) explicitly, hims define a function gg that takes in random noise ϵns(){\boldsymbol{\mathbf{\epsilon}}}_{n}\sim s(\cdot) and outputs xn{\boldsymbol{\mathbf{x}}}_{n} given zn{\boldsymbol{\mathbf{z}}}_{n} and β{\boldsymbol{\mathbf{\beta}}},

The induced, implicit likelihood of xnA{\boldsymbol{\mathbf{x}}}_{n}\in A given zn{\boldsymbol{\mathbf{z}}}_{n} and β{\boldsymbol{\mathbf{\beta}}} is

This integral is typically intractable. It is difficult to find the set to integrate over, and the integration itself may be expensive for arbitrary noise distributions s()s(\cdot) and functions gg.

Fig. 1 (right) displays the graphical model for hims. Noise (ϵn{\boldsymbol{\mathbf{\epsilon}}}_{n}) are denoted by triangles; deterministic computation (xn{\boldsymbol{\mathbf{x}}}_{n}) are denoted by squares. We illustrate two examples.

where Gaussian noises ϵ1,ϵ2\epsilon_{1},\epsilon_{2} are added at each full time step. The simulator runs for TT time steps given initial population sizes for x1,x2x_{1},x_{2}. Lognormal priors are placed over β\beta. The Lotka-Volterra model is grounded by theory but features an intractable likelihood. We study it in § 4.

Generative adversarial networks (gans) define an implicit model and a method for parameter estimation . They are known to perform well on image generation . Formally, the implicit model for a gan is

where gg is a neural network with parameters θ{\boldsymbol{\mathbf{\theta}}}, and ss is a standard normal or uniform. The neural network gg is typically not invertible; this makes the likelihood intractable.

The parameters θ{\boldsymbol{\mathbf{\theta}}} in gans are estimated by divergence minimization between the generated and real data. We make gans amenable to Bayesian analysis by placing a prior on the parameters θ{\boldsymbol{\mathbf{\theta}}}. We call this a Bayesian gan. Bayesian gans enable modeling of parameter uncertainty and are inspired by Bayesian neural networks, which have been shown to improve the uncertainty and data efficiency of standard neural networks . We study Bayesian gans in Table 1; Appendix B provides example implementations in the Edward probabilistic programming language .

Likelihood-Free Variational Inference

We described hierarchical implicit models, a rich class of latent variable models with local and global structure alongside an implicit density. Given data, we aim to calculate the model’s posterior p(z,βx)=p(x,z,β)/p(x)p({\boldsymbol{\mathbf{z}}},{\boldsymbol{\mathbf{\beta}}}\,|\,{\boldsymbol{\mathbf{x}}})=p({\boldsymbol{\mathbf{x}}},{\boldsymbol{\mathbf{z}}},{\boldsymbol{\mathbf{\beta}}})/p({\boldsymbol{\mathbf{x}}}). This is difficult as the normalizing constant p(x)p({\boldsymbol{\mathbf{x}}}) is typically intractable. With implicit models, the lack of a likelihood function introduces an additional source of intractability.

We use variational inference . It posits an approximating family qQq\in\mathcal{Q} and optimizes to find the member closest to p(z,βx)p({\boldsymbol{\mathbf{z}}},{\boldsymbol{\mathbf{\beta}}}\,|\,{\boldsymbol{\mathbf{x}}}). There are many choices of variational objectives that measure closeness . To choose an objective, we lay out desiderata for a variational inference algorithm for implicit models:

Scalability. Machine learning hinges on stochastic optimization to scale to massive data . The variational objective should admit unbiased subsampling with the standard technique,

where some computation f()f(\cdot) over the full data is approximated with a mini-batch of data {xm}\{{\boldsymbol{\mathbf{x}}}_{m}\}.

Implicit Local Approximations. Implicit models specify flexible densities; this induces very complex posterior distributions. Thus we would like a rich approximating family for the per-data point approximations q(znxn,β)q({\boldsymbol{\mathbf{z}}}_{n}\,|\,{\boldsymbol{\mathbf{x}}}_{n},{\boldsymbol{\mathbf{\beta}}}). This means the variational objective should only require that one can sample znq(znxn,β){\boldsymbol{\mathbf{z}}}_{n}\sim q({\boldsymbol{\mathbf{z}}}_{n}\,|\,{\boldsymbol{\mathbf{x}}}_{n},{\boldsymbol{\mathbf{\beta}}}) and not evaluate its density.

One variational objective meeting our desiderata is based on the classical minimization of the Kullback-Leibler (kl) divergence. (Surprisingly, Appendix C details how the kl is the only possible objective among a broad class.)

Classical variational inference minimizes the kl divergence from the variational approximation qq to the posterior. This is equivalent to maximizing the evidence lower bound (elbo),

Let qq factorize in the same way as the posterior,

where q(znxn,β)q({\boldsymbol{\mathbf{z}}}_{n}\,|\,{\boldsymbol{\mathbf{x}}}_{n},{\boldsymbol{\mathbf{\beta}}}) is an intractable density and since the data x{\boldsymbol{\mathbf{x}}} is constant during inference, we drop conditioning for the global q(β)q({\boldsymbol{\mathbf{\beta}}}). Substituting pp and qq’s factorization yields

This objective presents difficulties: the local densities p(xn,znβ)p({\boldsymbol{\mathbf{x}}}_{n},{\boldsymbol{\mathbf{z}}}_{n}\,|\,{\boldsymbol{\mathbf{\beta}}}) and q(znxn,β)q({\boldsymbol{\mathbf{z}}}_{n}\,|\,{\boldsymbol{\mathbf{x}}}_{n},{\boldsymbol{\mathbf{\beta}}}) are both intractable. To solve this, we consider ratio estimation.

2 Ratio Estimation for the KL Objective

Let q(xn)q({\boldsymbol{\mathbf{x}}}_{n}) be the empirical distribution on the observations x{\boldsymbol{\mathbf{x}}} and consider using it in a “variational joint” q(xn,znβ)=q(xn)q(znxn,β)q({\boldsymbol{\mathbf{x}}}_{n},{\boldsymbol{\mathbf{z}}}_{n}\,|\,{\boldsymbol{\mathbf{\beta}}})=q({\boldsymbol{\mathbf{x}}}_{n})q({\boldsymbol{\mathbf{z}}}_{n}\,|\,{\boldsymbol{\mathbf{x}}}_{n},{\boldsymbol{\mathbf{\beta}}}). Now subtract the log empirical logq(xn)\log q({\boldsymbol{\mathbf{x}}}_{n}) from the elbo above. The elbo reduces to

(Here the proportionality symbol means equality up to additive constants.) Thus the elbo is a function of the ratio of two intractable densities. If we can form an estimator of this ratio, we can proceed with optimizing the elbo.

We apply techniques for ratio estimation . It is a key idea in gans , and similar ideas have rearisen in statistics and physics . In particular, we use class probability estimation: given a sample from p()p(\cdot) or q()q(\cdot) we aim to estimate the probability that it belongs to p()p(\cdot). We model this using σ(r(;θ))\sigma(r(\cdot;{\boldsymbol{\mathbf{\theta}}})), where rr is a parameterized function (e.g., neural network) taking sample inputs and outputting a real value; σ\sigma is the logistic function outputting the probability.

We train r(;θ)r(\cdot;{\boldsymbol{\mathbf{\theta}}}) by minimizing a loss function known as a proper scoring rule . For example, in experiments we use the log loss,

The loss is zero if σ(r(;θ))\sigma(r(\cdot;{\boldsymbol{\mathbf{\theta}}})) returns 1 when a sample is from p()p(\cdot) and 0 when a sample is from q()q(\cdot). (We also experiment with the hinge loss; see § 4.) If r(;θ)r(\cdot;{\boldsymbol{\mathbf{\theta}}}) is sufficiently expressive, minimizing the loss returns the optimal function ,

As we minimize Eq.5, we use r(;θ)r(\cdot;{\boldsymbol{\mathbf{\theta}}}) as a proxy to the log ratio in Eq.4. Note rr estimates the log ratio; it’s of direct interest and more numerically stable than the ratio.

The gradient of Dlog\mathcal{D}_{\textrm{log}} with respect to θ{\boldsymbol{\mathbf{\theta}}} is

We compute unbiased gradients with Monte Carlo.

3 Stochastic Gradients of the KL Objective

To optimize the elbo, we use the ratio estimator,

All terms are now tractable. We can calculate gradients to optimize the variational family qq. Below we assume the priors p(β),p(znβ)p({\boldsymbol{\mathbf{\beta}}}),p({\boldsymbol{\mathbf{z}}}_{n}\,|\,{\boldsymbol{\mathbf{\beta}}}) are differentiable. (We discuss methods to handle discrete global variables in the next section.)

We focus on reparameterizable variational approximations . They enable sampling via a differentiable transformation TT of random noise, δs()\delta\sim s(\cdot). Due to Eq.7, we require the global approximation q(β;λ)q({\boldsymbol{\mathbf{\beta}}};{\boldsymbol{\mathbf{\lambda}}}) to admit a tractable density. With reparameterization, its sample is

for a choice of transformation Tglobal(;λ)T_{\textrm{global}}(\cdot;{\boldsymbol{\mathbf{\lambda}}}) and noise s()s(\cdot). For example, setting s()=N(0,1)s(\cdot)=\mathcal{N}(0,1) and Tglobal(δglobal)=μ+σδglobalT_{\textrm{global}}({\boldsymbol{\mathbf{\delta}}}_{\textrm{global}})=\mu+\sigma{\boldsymbol{\mathbf{\delta}}}_{\textrm{global}} induces a normal distribution N(μ,σ2)\mathcal{N}(\mu,\sigma^{2}).

Similarly for the local variables zn{\boldsymbol{\mathbf{z}}}_{n}, we specify

Unlike the global approximation, the local variational density q(znxn;ϕ)q({\boldsymbol{\mathbf{z}}}_{n}\,|\,{\boldsymbol{\mathbf{x}}}_{n};{\boldsymbol{\mathbf{\phi}}}) need not be tractable: the ratio estimator relaxes this requirement. It lets us leverage implicit models not only for data but also for approximate posteriors. In practice, we also amortize computation with inference networks, sharing parameters ϕ\phi across the per-data point approximate posteriors.

The gradient with respect to global parameters λ{\boldsymbol{\mathbf{\lambda}}} under this approximating family is

The gradient backpropagates through the local sampling zn=Tlocal(δn,xn,β;ϕ){\boldsymbol{\mathbf{z}}}_{n}=T_{\textrm{local}}({\boldsymbol{\mathbf{\delta}}}_{n},{\boldsymbol{\mathbf{x}}}_{n},{\boldsymbol{\mathbf{\beta}}};{\boldsymbol{\mathbf{\phi}}}) and the global reparameterization β=Tglobal(δglobal;λ){\boldsymbol{\mathbf{\beta}}}=T_{\textrm{global}}({\boldsymbol{\mathbf{\delta}}}_{\textrm{global}};{\boldsymbol{\mathbf{\lambda}}}). We compute unbiased gradients with Monte Carlo. The gradient with respect to local parameters ϕ{\boldsymbol{\mathbf{\phi}}} is

where the gradient backpropagates through TlocalT_{\textrm{local}}.The ratio rr indirectly depends on ϕ{\boldsymbol{\mathbf{\phi}}} but its gradient w.r.t. ϕ{\boldsymbol{\mathbf{\phi}}} disappears. This is derived via the score function identity and the product rule (see, e.g., Ranganath et al., [45, Appendix]).

4 Algorithm

Algorithm 1 outlines the procedure. We call it likelihood-free variational inference (lfvi). lfvi is black box: it applies to models in which one can simulate data and local variables, and calculate densities for the global variables. lfvi first updates θ{\boldsymbol{\mathbf{\theta}}} to improve the ratio estimator rr. Then it uses rr to update parameters {λ,ϕ}\{{\boldsymbol{\mathbf{\lambda}}},{\boldsymbol{\mathbf{\phi}}}\} of the variational approximation qq. We optimize rr and qq simultaneously. The algorithm is available in Edward .

lfvi is scalable: we can unbiasedly estimate the gradient over the full data set with mini-batches . The algorithm can also handle models of either continuous or discrete data. The requirement for differentiable global variables and reparameterizable global approximations can be relaxed using score function gradients .

Point estimates of the global parameters β{\boldsymbol{\mathbf{\beta}}} suffice for many applications . Algorithm 1 can find point estimates: place a point mass approximation qq on the parameters β{\boldsymbol{\mathbf{\beta}}}. This simplifies gradients and corresponds to variational EM.

Experiments

We developed new models and inference. For experiments, we study three applications: a large-scale physical simulator for predator-prey populations in ecology; a Bayesian gan for supervised classification; and a deep implicit model for symbol generation. In addition, Appendix F, provides practical advice on how to address the stability of the ratio estimator by analyzing a toy experiment. We initialize parameters from a standard normal and apply gradient descent with ADAM.

Lotka-Volterra Predator-Prey Simulator. We analyze the Lotka-Volterra simulator of § 2 and follow the same setup and hyperparameters of Papamakarios and Murray, . Its global variables β{\boldsymbol{\mathbf{\beta}}} govern rates of change in a simulation of predator-prey populations. To infer them, we posit a mean-field normal approximation (reparameterized to be on the same support) and run Algorithm 1 with both a log loss and hinge loss for the ratio estimation problem; Appendix D details the hinge loss. We compare to rejection ABC, MCMC-ABC, and SMC-ABC . MCMC-ABC uses a spherical Gaussian proposal; SMC-ABC is manually tuned with a decaying epsilon schedule; all ABC methods are tuned to use the best performing hyperparameters such as the tolerance error.

Fig. 2 displays results on two data sets. In the top figures and bottom left, we analyze data consisting of a simulation for T=30T=30 time steps, with recorded values of the populations every 0.20.2 time units. The bottom left figure calculates the negative log probability of the true parameters over the tolerance error for abc methods; smaller tolerances result in more accuracy but slower runtime. The top figures compare the marginal posteriors for two parameters using the smallest tolerance for the abc methods. Rejection ABC, MCMC-ABC, and SMC-ABC all contain the true parameters in their 95% credible interval but are less confident than our methods. Further, they required 100,000100,000 simulations from the model, with an acceptance rate of 0.004%0.004\% and 2.990%2.990\% for rejection ABC and MCMC-ABC respectively.

The bottom right figure analyzes data consisting of 100,000100,000 time series, each of the same size as the single time series analyzed in the previous figures. This size is not possible with traditional methods. Further, we see that with our methods, the posterior concentrates near the truth. We also experienced little difference in accuracy between using the log loss or the hinge loss for ratio estimation.

where g(θ)g(\cdot\,|\,{\boldsymbol{\mathbf{\theta}}}) is a 2-layer multilayer perception with ReLU activations, batch normalization, and is parameterized by weights and biases θ{\boldsymbol{\mathbf{\theta}}}. We place normal priors, θN(0,1){\boldsymbol{\mathbf{\theta}}}\sim\mathcal{N}(0,1).

We analyze two choices of the variational model: one with a mean-field normal approximation for q(θx)q({\boldsymbol{\mathbf{\theta}}}\,|\,{\boldsymbol{\mathbf{x}}}), and another with a point mass approximation (equivalent to maximum a posteriori). We compare to a Bayesian neural network, which uses the same generative process as Eq.10 but draws from a Categorical distribution rather than feeding noise into the neural net. We fit it separately using a mean-field normal approximation and maximum a posteriori. Table 1 shows that Bayesian gans generally outperform their Bayesian neural net counterpart.

Note that Bayesian gans can analyze discrete data such as in generating a classification label. Traditional gans for discrete data is an open challenge . In Appendix E, we compare Bayesian gans with point estimation to typical gans. Bayesian gans are also able to leverage parameter uncertainty for analyzing these small to medium-size data sets.

One problem with Bayesian gans is that they cannot work with very large neural networks: the ratio estimator is a function of global parameters, and thus the input size grows with the size of the neural network. One approach is to make the ratio estimator not a function of the global parameters. Instead of optimizing model parameters via variational EM, we can train the model parameters by backpropagating through the ratio objective instead of the variational objective. An alternative is to use the hidden units as input which is much lower dimensional [53, Appendix C].

Injecting Noise into Hidden Units. In this section, we show how to build a hierarchical implicit model by simply injecting randomness into hidden units. We model sequences x=(x1,,xT){\boldsymbol{\mathbf{x}}}=({\boldsymbol{\mathbf{x}}}_{1},\ldots,{\boldsymbol{\mathbf{x}}}_{T}) with a recurrent neural network. For t=1,,Tt=1,\ldots,T,

where gzg_{z} and gxg_{x} are both 1-layer multilayer perceptions with ReLU activation and layer normalization. We place standard normal priors over all weights and biases. See Fig. 3(a).

We developed a class of hierarchical implicit models and likelihood-free variational inference, merging the idea of implicit densities with hierarchical Bayesian modeling and approximate posterior inference. This expands Bayesian analysis with the ability to apply neural samplers, physical simulators, and their combination with rich, interpretable latent structure.

More stable inference with ratio estimation is an open challenge. This is especially important when we analyze large-scale real world applications of implicit models. Recent work for genomics offers a promising solution .

We thank Balaji Lakshminarayanan for discussions which helped motivate this work. We also thank Christian Naesseth, Jaan Altosaar, and Adji Dieng for their feedback and comments. DT is supported by a Google Ph.D. Fellowship in Machine Learning and an Adobe Research Fellowship. This work is also supported by NSF IIS-0745520, IIS-1247664, IIS-1009542, ONR N00014-11-1-0651, DARPA FA8750-14-2-0009, N66001-15-C-4032, Facebook, Adobe, Amazon, and the John Templeton Foundation.

Appendix A Noise versus Latent Variables

Hims have two sources of randomness for each data point: the latent variable zn{\boldsymbol{\mathbf{z}}}_{n} and the noise ϵn{\boldsymbol{\mathbf{\epsilon}}}_{n}; these sources of randomness get transformed to produce xn{\boldsymbol{\mathbf{x}}}_{n}. Bayesian analysis infers posteriors on latent variables. A natural question is whether one should also infer the posterior of the noise.

The posterior’s shape—and ultimately if it is meaningful—is determined by the dimensionality of noise and the transformation. For example, consider the gan model, which has no local latent variable, xn=g(ϵn;θ){\boldsymbol{\mathbf{x}}}_{n}=g({\boldsymbol{\mathbf{\epsilon}}}_{n};{\boldsymbol{\mathbf{\theta}}}). The conditional p(xnϵn)p({\boldsymbol{\mathbf{x}}}_{n}\,|\,{\boldsymbol{\mathbf{\epsilon}}}_{n}) is a point mass, fully determined by ϵn{\boldsymbol{\mathbf{\epsilon}}}_{n}. When g(;θ)g(\cdot;{\boldsymbol{\mathbf{\theta}}}) is injective, the posterior p(ϵnxn)p({\boldsymbol{\mathbf{\epsilon}}}_{n}\,|\,{\boldsymbol{\mathbf{x}}}_{n}) is also a point mass,

where g1g^{-1} is the left inverse of gg.This means for injective functions of the randomness (both noise and latent variables), the “posterior” may be worth analysis as a deterministic hidden representation , but it is not random.

The point mass posterior can be found via nonlinear least squares. Nonlinear least squares yields the iterative algorithm

for some step size sequence ρt\rho_{t}. Note the updates will get stuck when the gradient of ff is zero. However, the injective property of ff allows the iteration to be checked for correctness (simply check if f(ϵ^n)=xnf(\hat{{\boldsymbol{\mathbf{\epsilon}}}}_{n})={\boldsymbol{\mathbf{x}}}_{n}).

Appendix B Implicit Model Examples in Edward

We demonstrate implicit models via example implementations in Edward .

Appendix C KL Uniqueness

An integral probability metric measures distance between two distributions pp and qq,

Integral probability metrics have been used for parameter estimation in generative models and for variational inference in models with tractable density . In contrast to models with only local latent variables, to infer the posterior, we need an integral probability metric between it and the variational approximation. The direct approach fails because sampling from the posterior is intractable.

An indirect approach requires constructing a sufficiently broad class of functions with posterior expectation zero based on Stein’s method . These constructions require a likelihood function and its gradient. Working around the likelihood would require a form of nonparametric density estimation; unlike ratio estimation, we are unaware of a solution that sufficiently scales to high dimensions.

As another class of divergences, the ff divergence is

Unlike integral probability metrics, ff divergences are naturally conducive to ratio estimation, enabling implicit pp and implicit qq. However, the challenge lies in scalable computation. To subsample data in hierarchical models, we need ff to satisfy up to constants f(ab)=f(a)+f(b)f(ab)=f(a)+f(b), so that the expectation becomes a sum over individual data points. For continuous functions, this is a defining property of the log\log function. This implies the KL-divergence from qq to pp is the only ff divergence where the subsampling technique in our desiderata is possible.

Appendix D Hinge Loss

Let r(xi,zi,β;θ)r({\boldsymbol{\mathbf{x}}}_{i},{\boldsymbol{\mathbf{z}}}_{i},{\boldsymbol{\mathbf{\beta}}};\theta) output a real value, as with the log loss in Section 4. The hinge loss is

We minimize this loss function by following unbiased gradients. The gradients are calculated analogously as for the log loss. The optimal rr^{*} is the log ratio.

Appendix E Comparing Bayesian GANs with MAP to GANs with MLE

In Section 4, we argued that MAP estimation with a Bayesian gan enables analysis over discrete data, but gans—even with a maximum likelihood objective —cannot. This is a surprising result: assuming a flat prior for MAP, the two are ultimately optimizing the same objective. We compare the two below.

For gans, assume the discriminator outputs a logit probability, so that it’s unconstrained instead of on $$. gans with MLE use the discriminative problem

Solving the generative problem with reparameterization gradients requires backpropagating through data generated from the model, xp(x;w){\boldsymbol{\mathbf{x}}}\sim p({\boldsymbol{\mathbf{x}}};{\boldsymbol{\mathbf{w}}}). This is not possible for discrete x{\boldsymbol{\mathbf{x}}}. Further, the exponentiation also makes this objective numerically unstable and thus unusable in practice.

The first term is zero for a flat prior p(w)1p({\boldsymbol{\mathbf{w}}})\propto 1 and point mass approximation; the problem reduces to

Solving this is possible for discrete x{\boldsymbol{\mathbf{x}}}: it only requires backpropagating gradients through r(x,w)r({\boldsymbol{\mathbf{x}}},{\boldsymbol{\mathbf{w}}}) with respect to w{\boldsymbol{\mathbf{w}}}, all of which is differentiable. Further, the objective does not require a numerically unstable exponentiation.

Ultimately, the difference lies in the role of the ratio estimators. Recall for Bayesian gans, we use the ratio estimation problem

The optimal ratio estimator is the log-ratio r(x,w)=logp(xw)logq(x)r^{*}({\boldsymbol{\mathbf{x}}},{\boldsymbol{\mathbf{w}}})=\log p({\boldsymbol{\mathbf{x}}}\,|\,{\boldsymbol{\mathbf{w}}})-\log q({\boldsymbol{\mathbf{x}}}). Optimizing it with respect to w{\boldsymbol{\mathbf{w}}} reduces to optimizing the log-likelihood logp(xw)\log p({\boldsymbol{\mathbf{x}}}\,|\,{\boldsymbol{\mathbf{w}}}). The optimal discriminator for gans with MLE has the same ratio, D(x)=logp(x;w)logq(x)D^{*}({\boldsymbol{\mathbf{x}}})=\log p({\boldsymbol{\mathbf{x}}};{\boldsymbol{\mathbf{w}}})-\log q({\boldsymbol{\mathbf{x}}}); however, it is a constant function with respect to w{\boldsymbol{\mathbf{w}}}. Hence one cannot immediately substitute D(x)D^{*}({\boldsymbol{\mathbf{x}}}) as a proxy to optimizing the likelihood. An alternative is to use importance sampling; the result is the former objective .

Appendix F Stability of Ratio Estimator

With implicit models, the difference from standard KL variational inference lies in the ratio estimation problem. Thus we would like to assess the accuracy of the ratio estimator. We can check this by comparing to the true ratio under a model with tractable likelihood.

Note the log-likelihood logp(xβ)\log p({\boldsymbol{\mathbf{x}}}\,|\,{\boldsymbol{\mathbf{\beta}}}) minus r(x,β)r^{*}({\boldsymbol{\mathbf{x}}},{\boldsymbol{\mathbf{\beta}}}) is equal to the empirical distribution nlogq(xn)\sum_{n}\log q({\boldsymbol{\mathbf{x}}}_{n}), a constant. Therefore if a ratio estimator rr is accurate, its difference with logp(xβ)\log p({\boldsymbol{\mathbf{x}}}\,|\,{\boldsymbol{\mathbf{\beta}}}) should be a constant with low variance across values of β{\boldsymbol{\mathbf{\beta}}}.

See Fig. 5. The top graph displays the estimate of logq(x)\log q({\boldsymbol{\mathbf{x}}}) over updates of the variational approximation q(β)q({\boldsymbol{\mathbf{\beta}}}); each estimate uses a sample from the current q(β)q({\boldsymbol{\mathbf{\beta}}}). The ratio estimator rr is more accurate as qq exactly converges to the posterior. This matches our intuition: if data generated from the model is close to the true data, then the ratio is more stable to estimate.

An alternative hypothesis for Fig. 5 is that the ratio estimator has simply accumulated information during training. This turns out to be untrue; see the bottom graphs. On the left, qq is fixed at a random initialization; the estimate of logq(x)\log q({\boldsymbol{\mathbf{x}}}) is displayed over updates of rr. After many updates, rr still produces unstable estimates. In contrast, the right shows the same procedure with qq fixed at the posterior. rr is accurate after few updates.

Several practical insights appear for training. First, it is not helpful to update rr multiple times before updating qq (at least in initial iterations). Additionally, if the specified model poorly matches the data, training will be difficult across all iterations.

The property that ratio estimation is more accurate as the variational approximation improves is because q(xn)q({\boldsymbol{\mathbf{x}}}_{n}) is set to be the empirical distribution. (Note we could subtract any density q(xn)q({\boldsymbol{\mathbf{x}}}_{n}) from the elbo in Equation 4.) Likelihood-free variational inference finds q(β)q({\boldsymbol{\mathbf{\beta}}}) that makes the observed data likely under p(xnβ)p({\boldsymbol{\mathbf{x}}}_{n}\,|\,{\boldsymbol{\mathbf{\beta}}}), i.e., p(xnβ)p({\boldsymbol{\mathbf{x}}}_{n}\,|\,{\boldsymbol{\mathbf{\beta}}}) gets closer to the empirical distribution at values sampled from q(β)q({\boldsymbol{\mathbf{\beta}}}). Letting q(xn)q({\boldsymbol{\mathbf{x}}}_{n}) be the empirical distribution means the ratio estimation problem will be less trivially solvable (thus more accurate) as q(β)q({\boldsymbol{\mathbf{\beta}}}) improves.

Note also this motivates why we do not subsume inference of p(βx)p({\boldsymbol{\mathbf{\beta}}}\,|\,{\boldsymbol{\mathbf{x}}}) in the ratio in order to enable implicit global variables and implicit global variational approximations. Namely, estimation requires comparing samples between the prior and the posterior; they rarely overlap for global variables.