Variational inference & the ELBO
Approximating an intractable posterior by optimizing a tractable family, bounded below by the evidence lower bound.
The exact posterior is usually impossible to compute — the integral in its denominator is intractable. Variational inference takes a different route: instead of solving for the posterior exactly, pick the closest match out of a family of simple, easy-to-handle distributions. “Computing the posterior” then becomes “tuning a few parameters until two distributions are as close as possible” — an optimization problem. The rest of this page makes that idea precise.
Variational inference turns posterior computation into optimization. Given a latent-variable model , the posterior
is usually intractable because the evidence requires marginalizing over all latents. Here is the observation (in Cryo-ET, a set of noisy, missing-wedge projections), is the latent we want to infer (the 3D structure to reconstruct, the pose, or a latent code), is the likelihood encoding the imaging physics, and is the prior. The trouble is that integral: is often a voxel grid with hundreds of thousands of dimensions, so marginalizing over it is numerically hopeless, and neither nor has a closed form.
Variational inference replaces the true posterior with a tractable approximation drawn from a chosen family, and fits by maximizing a lower bound on . “Tractable” means we can sample from and evaluate its density — the canonical choice is a mean-field Gaussian , one mean and variance per latent. Fitting is just optimizing those .
The expressiveness of the chosen family caps the quality of the approximation: when the true posterior is multimodal but is restricted to a single Gaussian, the two cannot coincide, and the fit settles on one region of the posterior. Concretely, minimizing — the direction variational inference uses by default — is mode-seeking: it would rather shrink into a single peak than straddle the valley between two, because placing -mass where is near zero blows up . So a single-Gaussian locks onto one mode rather than averaging the two.
The interactive panel below fixes a bimodal target distribution and exposes the mean and standard deviation of a single Gaussian , making the trade-off between the expected log target, the entropy, and the resulting ELBO concrete. Slide the mean onto either peak and shrink the standard deviation, and the ELBO rises; try to cover both peaks at once with a wide, high-variance Gaussian and the ELBO instead drops, because wastes probability mass in the low-density valley between the peaks.
A single Gaussian q cannot cover both peaks at once: spanning the low-density valley drags down the expected log target. Maximizing the ELBO drives q to lock onto one mode — the mode-seeking signature of reverse-KL variational inference.
That bound is the evidence lower bound (ELBO). Starting from Jensen’s inequality,
Term by term: the first, , averages the joint log-density under — estimate it by drawing a few from , plugging them into , and averaging, with no intractable integral in sight. The second, , is the entropy of , rewarding for staying spread out instead of collapsing to a point. Their difference is the ELBO, written — and the whole thing is estimable by sampling, which is exactly why it can serve as an optimization objective.
The gap between and the ELBO is exactly . Equivalently,
Since the left-hand side does not depend on , raising the ELBO and lowering the KL are two sides of one move: maximizing the bound drives toward the true posterior while simultaneously tightening an estimate of the evidence. When equals the true posterior the KL is zero, the bound is tight, and the ELBO reaches itself.
Rewriting the ELBO exposes its two competing terms:
The first term rewards latents that explain the observation: it asks “if I draw from and pass it through the imaging model , does it look like the I actually saw?” The second penalizes departures of from the prior, pulling back toward “what it should look like before seeing any data.” Turn the regularizer up and stays conservative, close to the prior; turn it down and fits this one observation more aggressively and overfits noise more easily. The objective balances fitting the data against staying close to the prior — which is exactly why it helps in Cryo-ET: a single tilt series carries limited information, and the prior term covers for what is missing.
Expectation–maximization (EM) is the special case in which is set to the exact posterior at each E-step, making the bound tight, followed by an M-step that maximizes over model parameters. Variational inference generalizes EM to settings where the exact posterior is unavailable: the E-step is itself an approximate optimization over a restricted family , and the same ELBO is ascended in both arguments.
When is parameterized by a neural network — mapping the observation straight to , known as amortized inference — differentiating the ELBO with respect to hits a snag: the expectation itself depends on the parameters being optimized, so the gradient cannot simply move inside it. The reparameterization trick sidesteps this by writing with , pushing the randomness into a -independent , so that
an unbiased gradient from a single sample that backpropagates through the whole network. This is the technical core that lets the variational autoencoder train end to end. One cost to keep in mind: the mean-field assumes the are posterior-independent, which systematically underestimates variance — it discards correlations between latents that the true posterior has, so the uncertainty it reports is typically too narrow.
The ELBO is the training objective behind the variational autoencoder, and the intractability of the posterior KL term motivates the distribution-matching view used in optimal transport and in CryoGEN.
Placing this machinery back in the reconstruction pipeline: solving for means “given noisy projections, infer the distribution over 3D structures.” Variational inference returns a single best approximation to that posterior — one settled, stable answer, matching the MAP point estimate of CryoGEN-I and the WAE/OT stable single answer of CryoGEN-II. But to characterize the whole family of posterior solutions — several plausible structures consistent with the same data — a single is not enough, and you switch to tools that genuinely sample the posterior. Energy-based models give the unnormalized posterior shape , and Langevin dynamics and SGLD sample it repeatedly using only its score , returning a family of structures rather than one — the inner loop of CryoWGEN (EVIA Monte-Carlo for CryoWGEN-I, EVIA Langevin for the CryoWGEN-II posterior family). The ELBO on this page and that sampling chain share one starting point: both are stuck with the same intractable posterior and both work from a tractable proxy for it; the only difference is whether the proxy is “one distribution ” or “a stream of samples.”