Stochastic Backpropagation and Approximate Inference in Deep Generative Models
Danilo Jimenez Rezende, Shakir Mohamed, Daan Wierstra
Appendix A Additional Model Details
In equation (LABEL:eq:LogLike) we showed an alternative form of the joint log likelihood that explicitly separates the deterministic and stochastic parts of the generative model and corroborates the view that the generative model works by applying a complex non-linear transformation to a spherical Gaussian distribution \mathcal{N}(\mbox{\mbox{}}|\mbox{\mbox{}},\mbox{\mbox{}}) such that the transformed distribution best matches the empirical distribution. We provide more details on this view here for clarity.
From the model description in equations (LABEL:eq:HiddenGen) and (LABEL:eq:Visible), we can interpret the variables as deterministic functions of the noise variables \mbox{\mbox{}}_{l}. This can be formally introduced as a coordinate transformation of the probability density in equation (LABEL:eq:LogLikeStandard): we perform a change of coordinates \mathbf{h}_{l}\rightarrow\mbox{\mbox{}}_{l}. The density of the transformed variables \mbox{\mbox{}}_{l} can be expressed in terms of the density (LABEL:eq:LogLikeStandard) times the determinant of the Jacobian of the transformation p(\mbox{\mbox{}}_{l})=p(\mathbf{h}_{l}(\mbox{\mbox{}}_{l}))|\frac{\partial\mathbf{h}_{l}}{\partial\mbox{\mbox{}}_{l}}|. Since the co-ordinate transformation is linear we have |\frac{\partial\mathbf{h}_{l}}{\partial\mbox{\mbox{}}_{l}}|=|\mbox{\mbox{}}_{l}| and the distribution of \mbox{\mbox{}}_{l} is obtained as follows:
Combining this equation with the distribution of the visible layer we obtain equation (LABEL:eq:LogLike).
Below we provide simple, explicit examples of generative and recognition models.
In the case of a two-layer model the activation \mathbf{h}_{1}(\mbox{\mbox{}}_{1,2}) in equation (LABEL:eq:LogLike) can be explicitly written as
Similarly, a simple recognition model consists of a single deterministic layer and a stochastic Gaussian layer with the rank-one covariance structure and is constructed as:
where the function is a rectified linearity (but other non-linearities such as tanh can be used).
Appendix B Proofs for the Gaussian Gradient Identities
Here we review the derivations of Bonnet’s and Price’s theorems that were presented in section LABEL:sec:stochBP.
Let f(\mbox{\mbox{}}):R^{d}\mapsto R be a integrable and twice differentiable function. The gradient of the expectation of f(\mbox{\mbox{}}) under a Gaussian distribution \mathcal{N}(\mbox{\mbox{}}|\mbox{\mbox{}},\mbox{\mbox{}}) with respect to the mean can be expressed as the expectation of the gradient of f(\mbox{\mbox{}}).
in moving from step 1 to 2. From step 2 to 3 we have used the product rule for integrals with the first term evaluating to zero. ∎
Under the same conditions as before. The gradient of the expectation of f(\mbox{\mbox{}}) under a Gaussian distribution \mathcal{N}(\mbox{\mbox{}}|\mbox{\mbox{}},\mbox{\mbox{}}) with respect to the covariance can be expressed in terms of the expectation of the Hessian of f(\mbox{\mbox{}}) as
In moving from steps 1 to 2, we have used the identity
which can be verified by taking the derivatives on both sides and comparing the resulting expressions. From step 2 to 3 we have used the product rule for integrals twice. ∎
Appendix C Deriving Stochastic Back-propagation Rules
In section LABEL:sec:stochBP we described two ways in which to derive stochastic back-propagation rules. We show specific examples and provide some more discussion in this section.
We can derive rules for stochastic back-propagation for many distributions by finding a appropriate non-linear function that allows us to express the gradient with respect to the parameters of the distribution as a gradient with respect to the random variable directly. The approach we described in the main text was:
where we have introduced the non-linear function to allow for the transformation of the gradients and have applied the product rule for integrals (rule for integration by parts) to rewrite the integral in two parts in the second line, and the supp indicates that the term is evaluated at the boundaries of the support. To use this approach, we require that the density we are analysing be zero at the boundaries of the support to ensure that the first term in the second line is zero.
As an alternative, we can also write this differently and find an non-linear function of the form:
Consider general exponential family distributions of the form:
where is the base measure, is the set of mean parameters of the distribution, is the set of natural parameters, and is the log-partition function. We can express the non-linear function in (9) using these quantities as:
This can be derived for a number of distributions such as the Gaussian, inverse Gamma, Log-Normal, Wald (inverse Gaussian) and other distributions. We show some of these below:
The corresponding to the second formulation can also be derived and may be useful in certain situations, requiring the solution of a first order differential equation. This approach of searching for non-linear transformations leads us to the second approach for deriving stochastic back-propagation rules.
C.2 Using Alternative Coordinate Transformations
There are many distributions outside the exponential family that we would like to consider using. A simpler approach is to search for a co-ordinate transformation that allows us to separate the deterministic and stochastic parts of the distribution. We described the case of the Gaussian in section LABEL:sec:stochBP. Other distributions also have this property. As an example, consider the Levy distribution (which is a special case of the inverse Gamma considered above). Due to the self-similarity property of this distribution, if we draw from a Levy distribution with known parameters , we can obtain any other Levy distribution by rescaling and shifting this base distribution: .
Many other distributions hold this property, allowing stochastic back-propagation rules to be determined for distributions such as the Student’s t-distribution, Logistic distribution, the class of stable distributions and the class of generalised extreme value distributions (GEV). Examples of co-ordinate transformations and the resulsting distributions are shown below for variates drawn from the standard distribution listed in the first column.
Appendix D Variance Reduction using Control Variates
An alternative approach for stochastic gradient computation is commonly based on the method of control variates. We analyse the variance properties of various estimators in a simple example using univariate function. We then show the correspondence of the widely-known REINFORCE algorithm to the general control variate framework.
where is a baseline typically chosen to reduce the variance of the estimator.
The assumption of weakly correlated terms is relevant for variational learning in larger generative models where independence assumptions and structure in the variational distribution result in free energies that are summations over weakly correlated or independent terms.
D.2 Univariate variance analysis
In analysing the variance properties of many estimators, we discuss the general scaling of likelihood ratio approaches in appendix D. As an example to further emphasise the high-variance nature of these alternative approaches, we present a short analysis in the univariate case.
Consider a random variable and a simple quadratic function of the form
For this function we immediately obtain the following variances
Equations (15), (16) and (17) correspond to the variance of the estimators based on (LABEL:eq:bonnet), (LABEL:eq:price), (LABEL:eq:gradR) respectively whereas equation (18) corresponds to the variance of the REINFORCE algorithm for the gradient with respect to .
From these relations we see that, for any parameter configuration, the variance of the REINFORCE estimator is strictly larger than the variance of the estimator based on (LABEL:eq:bonnet). Additionally, the ratio between the variances of the former and later estimators is lower-bounded by . We can also see that the variance of the estimator based on equation (LABEL:eq:price) is zero for this specific function whereas the variance of the estimator based on equation (LABEL:eq:gradR) is not.
Appendix E Estimating the Marginal Likelihood
We compute the marginal likelihood by importance sampling by generating samples from the recognition model and using the following estimator:
Appendix F Missing Data Imputation
Image completion can be approximatively achieved by a simple iterative procedure which consists of (i) initializing the non-observed pixels with random values; (ii) sampling from the recognition distribution given the resulting image; (iii) reconstruct the image given the sample from the recognition model; (iv) iterate the procedure.
We denote the observed and missing entries in an observation as , respectively. The observed is fixed throughout, therefore all the computations in this section will be conditioned on . The imputation procedure can be written formally as a Markov chain on the space of missing entries with transition kernel given by
where .
Provided that the recognition model constitutes a good approximation of the true posterior , (20) can be seen as an approximation of the kernel
The kernel (21) has two important properties: (i) it has as its eigen-distribution the marginal ; (ii) . The property (i) can be derived by applying the kernel (21) to the marginal and noting that it is a fixed point. Property (ii) is an immediate consequence of the smoothness of the model.
We apply the fundamental theorem for Markov chains (Neal, 1993, pp. 38) and conclude that given the above properties, a Markov chain generated by (21) is guaranteed to generate samples from the correct marginal .
In practice, the stationary distribution of the completed pixels will not be exactly the marginal , since we use the approximated kernel (20). Even in this setting we can provide a bound on the norm of the difference between the resulting stationary marginal and the target marginal
If the recognition model is such that for all
then the marginal is a weak fixed point of the kernel (20) in the following sense:
where we apply the condition (22) to obtain the last statement. ∎
That is, if the recognition model is sufficiently close to the true posterior to guarantee that (22) holds for some acceptable error than (23) guarantees that the fixed-point of the Markov chain induced by the kernel (20) is no further than from the true marginal with respect to the norm.
Appendix G Variational Bayes for Deep Directed Models
In the main test we focussed on the variational problem of specifying an posterior on the latent variables only. It is natural to consider the variational Bayes problem in which we specify an approximate posterior for both the latent variables and model parameters.
Following the same construction and considering an Gaussian approximate distribution on the model parameters \mbox{\mbox{}}^{g}, the free energy becomes:
which now includes an additional term for the cost of using parameters and their regularisation. We must now compute the additional set of gradients with respect to the parameter’s mean and variance are:
Appendix H Additional Simulation Details
We use training data of various types including binary and real-valued data sets. In all cases, we train using mini-batches, which requires the introduction of scaling terms in the free energy objective function (LABEL:eq:FEsimp) in order to maintain the correct scale between the prior over the parameters and the remaining terms (Ahn et al., 2012; Welling & Teh, 2011). We make use of the objective:
where is an index over observations in the mini-batch and is equal to the ratio of the data-set and the mini-batch size. At each iteration, a random mini-batch of size 200 observations is chosen.
All parameters of the model were initialized using samples from a Gaussian distribution with mean zero and variance ; the prior variance of the parameters was . We compute the marginal likelihood on the test data by importance sampling using samples from the recognition model; we describe our estimator in appendix E.