A post by Jack Simons, PhD student on the Compass programme.
I began my PhD with my supervisors, Dr Song Liu and Professor Mark Beaumont with the intention of combining their respective fields of research; Density Ratio Estimation (DRE), and Simulation Based Inference (SBI):
- DRE is a rapidly growing paradigm in machine learning which (broadly) provides efficient methods of comparing densities without the need to compute each density individually. For a comprehensive yet accessible overview of DRE in Machine Learning see .
- SBI is a group of methods which seek to solve Bayesian inference problems when the likelihood function is intractable. If you wish for a concise overview of the current work, as well as motivation then I recommend .
Last year we released a paper, Variational Likelihood-Free Gradient Descent  which combined these fields. This blog post seeks to condense, and make more accessible, the contents of the paper.
Motivation: Likelihood-Free Inference
Let’s begin by introducing likelihood-free inference. We wish to do inference on the posterior distribution of parameters for a specific observation , i.e. we wish to infer which can be decomposed via Bayes’ rule as
The likelihood-free setting is that, additional to the usual intractability of the normalising constant in the denominator, the likelihood, , is also intractable. In lieu of this, we require an implicit likelihood which describes the relation between data and parameters in the form of a forward model/simulator (hence simulation based inference!).
This setting broadens the range of problems which we can perform posterior inference on. If we introduce fewer restrictions on the models scientists can perform inference on then we allow for more general models. There are other groups of methods which perform posterior inference in the likelihood-free setting, but generally these are hand-crafted for the model at hand. Consequently, SBI has seen a great success in many scientific fields since its inception, to name a few:
- Population Dynamics – e.g. Lotka-Volterra
- Epidemiology – e.g. Compartmental Models
- Particle Physics – e.g. Particle Interactions in the Large Hadron Collider
( Left, Lotka Volterra Simulation LMaclean, A.D.A.M., CELSO, C.L. and STUMPF, M.P., Stem Cell Population Biology: Insights from Haematopoiesis. Middle, SIR Simulation Macal, C.M., 2010, December. To agent-based simulation from system dynamics. In Proceedings of the 2010 winter simulation conference (pp. 371-382). IEEE. Right, Large Hadron Collider Simulation CERN: https://cds.cern.ch/record/2646378))
We conclude our brief introduction to SBI, but would once again point readers to  if you would like to see an overview of the recent advances in the literature.
Our idea, as in variational inference, is to minimize some divergence between our variational distribution and the target distribution . Specifically, we choose the reverse Kullback-Leibler (KL) divergence which is defined by
where we have introduced the density ratio . Due to the intractability of some of the constituent densities of we must estimate it using some . With this density ratio estimator we could estimate the above KL divergence using samples
Our procedure is comprised of repeating the following steps:
- Estimate the density ratio with via DRE
- Perform a step of gradient descent w.r.t. the parameters of our variational distribution on our estimate of the KL
We name our method Variational Likelihood-Free Gradient Descent (VLFGD), and will explain exactly how we achieve these steps in subsequent sections.
Choice of Variational Family
We first specify exactly what form our variational distribution, , takes.
We select our variational distribution to be an empirical distribution on particles . To be clear, , which is interpreted as the parameters of , are exactly the set of particles constituting the empirical distribution: . Consequently, when we write we actually mean sampling uniformly at random from .
Our choice of perturbing particles via gradient descent to closer resemble the posterior is inspired by a popular Variational Inference method, Stein Variational Gradient Descent (SVGD) . We note that VLFGD and SVGD have significant differences, i.e. SVGD is not applicable to the likelihood-free setting, and is based on the Kernelised Stein discrepancy not the KL.
We wish to estimate the density ratio
which we achieve with samples from the constituent densities. Samples from the denominator density, the joint distribution , are given by . Samples from the numerator are attained by pairing the samples from the denominator with samples .
There is a well-established connection between binary classification and density ratio estimation . We follow this connection and reframe our density ratio estimation problem as a binary classification problem.
Let’s label our numerator samples 1, and denominator samples 0. Once we have an estimate of the class probabilities via some binary classification algorithm, then an estimate of the density ratio is recovered via
if the class proportions are equal. The binary classification algorithm we use is logistic regression. Specifically, the class probabilities are estimated by a function wrapped in the logistic function
which is paired with the cross-entropy loss defined by
So, if we denote the solution to the above optimization problem as then we have our estimate of given by
via some simple algebra. We select the function to be a neural network.
Gradient of the KL
We are now in the position to estimate our global objective function
We want to take the gradient of the above w.r.t. (the parameters of our variational distribution and also the particles). Recalling that we defined as an empirical distribution on particles , we see that
Thus the gradient descent update is given by
where is some learning rate.
Alternating between the density ratio estimation and gradient descent steps will drive the empirical distribution (our particles) towards the target posterior. Demonstration of our algorithm can be seen below
As intended, our particles more closely resemble samples from the posterior.
 Sugiyama, M., Suzuki, T. and Kanamori, T., 2012. Density ratio estimation in machine learning. Cambridge University Press.
 Cranmer, K., Brehmer, J. and Louppe, G., 2020. The frontier of simulation-based inference. Proceedings of the National Academy of Sciences, 117(48), pp.30055-30062.
 Simons, J., Liu, S. and Beaumont, M., 2021, November. Variational Likelihood-Free Gradient Descent. In Fourth Symposium on Advances in Approximate Bayesian Inference.
 Liu, Q. and Wang, D., 2016. Stein variational gradient descent: A general purpose bayesian inference algorithm. Advances in neural information processing systems, 29.