Proposition 2I.13.P0245 of 100 in the corpus
The ELBO falls short of the log-evidence by exactly the divergence from the encoder's distribution to the posterior.
A bound that can be computed replaces an evidence that cannot. It splits into a reconstruction term and a price on the code, and it is tight only when the encoder returns the true posterior.
Two derivations of one bound
Let be any distribution over codes that is positive exactly where the posterior is; for Gaussian priors and decoders that is everywhere. Multiply and divide by it inside the evidence, then apply Jensen’s inequality to the concave logarithm (Jensen's inequality 0.IT.05):
The right-hand side is the evidence lower bound, the ELBO. Jensen’s inequality is an equality only when the ratio inside is the same for every , that is, when is proportional to , which makes it the posterior.
The second derivation gives the size of the gap. Since does not depend on , it equals its own average under . Write it as inside that average, and add and subtract :
The bound misses the evidence by the divergence to the posterior.
The second line splits into . Because a KL divergence is never negative (Kullback–Leibler divergence 0.IT.03), the first line is the bound, and it names the gap exactly. This is I.13.T1. With the model held fixed, the evidence is a constant, so raising the ELBO over and lowering the KL divergence from to the posterior are the same act.
Reading the two terms
The first term of the ELBO is a reconstruction term: the decoder’s log-likelihood of , averaged over codes drawn from the encoder. With a Gaussian decoder of variance it is plus a constant, the loss of I.12 with the code made random.
The second term is the price of the code: how far the encoder’s distribution sits from the prior. It is what I.12 lacked. It pulls every input’s distribution towards , so the distributions of different inputs overlap and the decoder is trained on a cloud of codes around each one, not on isolated points. Proposition 4 shows what happens when that price is set too high.
The price of a Gaussian code
For and the prior in one dimension, the KL divergence is the average under of . The log-densities are and . Under the first quadratic averages to and averages to . A diagonal Gaussian is a product, and its KL is the sum over coordinates:
The price of a Gaussian code, coordinate by coordinate.
Each coordinate costs nothing only at , , which is the prior. Its derivatives are with respect to and with respect to : the term pulls every mean to zero and every variance to one. As the cost grows like without limit, so a point code is infinitely expensive (I.13.X04).
One point, four bounds
Return to probabilistic PCA on the four points, with , and the point . Proposition 1 found and the posterior . For any Gaussian both terms of the ELBO have closed forms, so the figure can compare four encoders exactly:
| encoder’s | ELBO | gap |
|---|---|---|
| , the prior | ||
Each gap is the KL divergence from that to the posterior, as (I.13.4) says it must be. The prior pays the most. The right width with the wrong mean, or the right mean with the wrong width, each closes part of the gap. At the posterior the reconstruction term is and the price of the code is , and they add to the evidence exactly. I.13.B01 computes every entry.
What maximising over the model does
A VAE maximises the ELBO over the decoder’s parameters and the encoder’s together. Over , the bound tightens. Over , it rises in two ways: by raising the evidence, which is the intended effect, and by moving the true posterior towards distributions the encoder can represent, which shrinks the gap without improving the model. The trained model is therefore biased towards posteriors that look like diagonal Gaussians. And the encoder is shared: with one network for every input, the gap includes an amortisation part that a per-input optimisation would remove (Cremer, Li and Duvenaud 2018).
None of this needs the evidence itself. Each training step uses one draw of per example to estimate the reconstruction term, the closed form (I.13.5) for the price, and a gradient that proposition 3 explains.
Reproduce the four bounds
from math import log, pi, sqrt
x, w, var = (1.0, 2.0), (0.8*sqrt(3), 0.6*sqrt(3)), 1.0
wx, ww, xx = sum(a*b for a, b in zip(w, x)), sum(a*a for a in w), sum(a*a for a in x)
def elbo(m, v): # q = N(m, v); both terms in closed form
recon = -log(2*pi*var) - (xx - 2*m*wx + (m*m + v)*ww)/(2*var)
kl = 0.5*(m*m + v - 1 - log(v))
return recon - kl
for m, v in ((0, 1), (0, 0.25), (sqrt(3)/2, 1), (sqrt(3)/2, 0.25)):
print(f"q = N({m:.3f}, {v}): ELBO {elbo(m, v):.6f}")
It prints , , and . The reconstruction term uses , which holds for any with mean and variance .
Sources
Depends on
Used by
Problems using this
- I.13.B01 — One point, four boundsnumeric▲△△
- I.13.B02 — The bound, its gap and the price of a Gaussian codesymbolic▲▲▲
- I.13.B03 — When the code switches offlimit▲▲△
- I.13.X01 — A Gaussian KL by hand, both ways roundnumeric▲△△
- I.13.X03 — A factorised encoder misreports its uncertaintycounterexample▲▲△
- I.13.X04 — A point code has unbounded ratelimit▲▲△
- I.13.X05 — Where Jensen's inequality is tightsymbolic▲▲△
- I.13.X07 — A mean reduction weights the KL by the input widthshape▲▲△
- I.BOOK.B06 — Shapes through a convolutional VAEshape▲▲△