§18.7 When you actually need Z
The methods so far avoid the partition function. But sometimes we genuinely need its value — to report a normalized likelihood, monitor training, or compare models. Comparing two models is the gentlest case: it needs only the ratio of their partition functions, not either value.
Model comparison needs only the ratio (eq 18.39)
| the per-example unnormalized log-ratio — Z-free and cheap to evaluate | scalar | |
| the only Z-dependent term, and it needs just the RATIO Z_A/Z_B — not either absolute value. m = test-set size | scalar |
Why a ratio is so much easier than the value
An absolute is a sum over every state — hopeless. But a ratio only asks “how much bigger is one normalizer than another,” and if the two distributions overlap you can answer that from a handful of samples. Every method below — importance sampling, annealed importance sampling, bridge sampling — estimates a ratio, never an absolute value. To get an actual , estimate one ratio against a reference distribution whose you already know.
The simplest estimator is plain importance sampling: draw from a tractable proposal (known ) and reweight,
Importance-sampling estimate of Z (eq 18.44)
| the importance weight — how much more probable each proposal sample is under the target than the proposal | scalar | |
| the KNOWN partition function of the proposal; the sum estimates Z₁/Z₀, then multiply by Z₀ | scalar |
This works only if . When they differ, most proposal samples land where is negligible, a few carry enormous weight, and the variance (eq 18.46) explodes — exactly the failure you met in §17.2:
At μ = 0 (naive Monte Carlo) almost no samples land in the tail, so the variance is enormous. Slide μtoward the tail and q overlaps p·f — the estimator's variance collapses. The dashed q\* ∝ p·|f| is the optimal (zero-variance) choice of eq 17.13; overshoot μ and the error creeps back up.
§18.7.1 Annealed importance sampling
When is large, annealed importance sampling annealed importance sampling (ais) Estimate Z₁/Z₀ by bridging p₀ to p₁ with intermediate distributions p_η ∝ p₁^η p₀^{1−η} and chaining their partition-function ratios; the standard method for RBM/DBN partition functions. defined in ch. 18 — open in glossary (AIS) inserts a chain of intermediate distributions between them, so no single hop is a big jump:
Chain the ratios through intermediates (eqs 18.49–18.50)
| telescope the target ratio into many small ratios; each small ratio is estimated by simple importance sampling | product of n hops | |
| the standard intermediate: a weighted GEOMETRIC average of target and proposal — η sweeps from 0 (p₀) to 1 (p₁) | unnormalized | |
| the annealing schedule; more/closer intermediates → each hop's distributions overlap → each ratio is low-variance | [0, 1] |
Sampling walks with transition operators (any MCMC — Gibbs, Metropolis–Hastings) that leave each invariant, chaining the per-hop importance weights (eq 18.52). It is provably valid — simple importance sampling on an extended state space (eqs 18.54–18.61). Add bridges and watch the estimator’s variance collapse:
At 1 hop (simple importance sampling) p₀ barely overlaps the far target p₁, so the importance weights vary wildly and the estimate is useless. Each added bridge p_η ∝ p̃₁^η p̃₀^(1−η) makes consecutive distributions overlap, so every hop's ratio is easy — and the chained Z₁/Z₀ (a product of the small hop-ratios) becomes reliable.
AIS (Jarzynski 1997; Neal 2001) is the standard method for estimating the partition function of RBMs and deep belief networks, popularized by Salakhutdinov & Murray (2008).
§18.7.2 Bridge sampling
Bridge sampling bridge sampling Estimate Z₁/Z₀ using a single bridge distribution p_* overlapping both p₀ and p₁ (optimal p_* ∝ p̃₀p̃₁/(r p̃₀+p̃₁)) instead of AIS's chain of intermediates. defined in ch. 18 — open in glossary takes the opposite tack: instead of a chain of intermediates, use a single bridge distribution that overlaps both and :
Bridge sampling (eq 18.62)
| sample from BOTH distributions; the bridge weighs the two sample sets against each other | two sample sets | |
| the bridge; optimal p_* ∝ p̃₀p̃₁/(r p̃₀ + p̃₁) with r = Z₁/Z₀ — circular, but solvable by starting from a coarse r and iterating | distribution |
The two are complementary: if and are reasonably close, a single bridge beats AIS; if they are far, AIS’s many intermediates span the distance. Linked importance sampling (Neal 2005) uses bridges between AIS’s intermediates to get the best of both. AIS is too costly to run during training, but combining bridge sampling, short-chain AIS, and parallel tempering, Desjardins et al. (2011) tracked an RBM’s partition function throughout learning.
That closes the partition-function problem. But intractable is only one obstacle to training generative models; the other is intractable inference — the hard positive phase — which is the next chapter.
Check yourself — estimating Z, AIS & bridge sampling
1.To decide which of two models assigns higher test likelihood, what do you actually need to know about their partition functions?
2.Why does simple importance sampling fail to estimate Z when the proposal p₀ is far from the target p₁?
3.How does annealed importance sampling overcome the distant-proposal problem?
4.How does bridge sampling differ from AIS, and when is each preferred?
5.Predict the outcome — in AISLab you raise the '# bridges' slider from 1 (simple IS) upward. What happens to the estimator's relative variance?