Notes on SUMO Unbiased Estimation of Log-Partition Function
In this note, I'll implement the Stochastically Unbiased Marginalization Objective (SUMO) to estimate the log-partition function of an energy funtion.
Estimation of log-partition function has many important applications in machine learning. Take latent variable models or Bayeisian inference. The log-partition function of the posterior distribution is the log-marginal likelihood of the data .
More generally, let be some energy function which induces some density function . The common practice is to look at a variational form of the log-partition function,
Plugging in an arbitrary would normally yield a strict lower bound, which means
for sampled i.i.d. from , would be a biased estimate for . In particular, it would be an underestimation.
To see this, lets define the energy function as follows:
It is not hard to see that is the energy function of a mixture of Gaussian distribution with a normalizing constant and .
To visualize the density corresponding to the energy
As a sanity check, lets also visualize the density of the mixture of Gaussians.
Now if we estimate the log-partition function by estimating the variational lower bound, we get
Estimate: 1.4595 / Ground true: 1.8379 Empirical variance: 0.9921
The lower bound can be tightened via [importance sampling):
This bound is tighter for larger partly due to the concentration of the average inside of the function: when the random variable is more deterministic, using a local linear approximation near its mean is more accurate as there's less "mass" outside of some neighborhood of the mean.
Now if we use this new estimator with
Estimate: 1.7616 / Ground true: 1.8379 Empirical variance: 0.1544
We see that both the bias and variance decrease.
Finally, we use the Stochastically Unbiased Marginalization Objective (SUMO), which uses the Russian Roulette estimator to randomly truncate a telescoping series that converges in expectation to the log partition function. Let be the importance-weighted estimator, and be the difference (which can be thought of as some form of correction). The SUMO estimator is defined as
where . To see why this is an unbiased estimator,
The inner expectation can be further expanded
which shows .
(N.B.) Some care needs to be taken care of for taking the limit. See the paper for more formal derivation.
A choice of proposed in the paper satisfy . We can sample such a easily using the inverse CDF, where is sampled uniformly from the interval .
Now putting things all together, we can estimate the log-partition using SUMO.
Estimate: 1.8359 / Ground true: 1.8379 Empirical variance: 4.1794
Indeed the empirical average is quite close to the true log-partition of the energy function. However we can also see that the distribution of the estimator is much more spread-out. In fact, it is very heavy-tailed. Note that I did not tune the proposal distribution based on the ELBO, or IWAE or SUMO. In the paper, the authors propose to tune to minimize the variance of the estimator, which might be an interesting trick to look at next.