25.8 Further Reading
The main sections of this chapter stick to results that we can prove cleanly and check on small examples. Each short note below picks up where a section left off, covering neighboring ideas that did not make the core path. If you are short on time, start with the three topics that show up most directly in everyday practice: model calibration, the irreducible-loss constant in scaling laws, and the bias--variance trade-off of mutual-information estimators. Bits-back coding is also well worth reading simply because the trick is so clever. Channel capacity and information geometry can easily wait, and nothing later in the book depends on this page.
25.8.1 Entropy and Losses#
25.8.1.1 Calibration after Training#
In principle, minimizing the population log-loss recovers the true conditional class probabilities (Section 25.1.3.1), which are automatically calibrated. Trained neural networks, however, rarely sit at that optimum. As Guo et al. (2017) famously observed, modern networks tend to err in one particular direction: they are overconfident. One-hot training labels are a major culprit. Because they reward pushing the winning logit infinitely far ahead of the rest (Section 25.1), once a network classifies the training set perfectly, the only way it can keep lowering the loss is to push its logits further and further apart. Late in training, the same authors see held-out log-loss begin to climb even while held-out classification error stays flat: the network is overfitting its probability estimates rather than its decisions. Temperature scaling (Section 3.4) fixes much of this with a single scalar fitted on a held-out validation set. It is the same temperature parameter used in distillation, repurposed here to soften overconfident predictions.
How far can a post-hoc recalibration like this go? Let denote the actual empirical class frequencies among all inputs for which the model outputs the probability vector . Since any cross-entropy decomposes into an entropy plus a KL divergence, applying that identity conditionally at each predicted vector splits the held-out log-loss into two pieces:
The first term measures miscalibration in nats: it vanishes if and only if events actually happen as often as the model's predicted probabilities claim. The second term is the uncertainty that still remains about the true label even after we know the model's prediction. Any post-hoc remapping of the predicted probabilities can drive the first term toward zero, but it can never reduce the second. Temperature scaling is simply a one-parameter family of such remappings, which makes it wonderfully simple, though a single scalar cannot fix a model that is overconfident on some classes and underconfident on others. More generally, every proper scoring rule admits an analogous decomposition into a divergence term and an entropy term (Gneiting and Raftery, 2007).
25.8.1.2 Entropy Relative to a Reference#
In Section 25.1.4.1, we saw an awkward quirk of differential entropy: switching units from meters to centimeters shifts it up by . A KL divergence, by contrast, does not budge, because both densities inside the ratio rescale by the same factor. We can give entropy the same coordinate invariance by measuring it against a reference density , defining . Ordinary differential entropy is just the special case in whatever units we happened to pick. Because a uniform density of one per meter is not the same measure as one per centimeter, that shift was really a hidden change of reference. Jaynes (1968) derives this relative form as the limit of discrete entropies on increasingly fine grids; with it, the maximum-entropy principle takes the natural form "stay as close to the reference measure as the constraints allow." Up to a sign, the KL penalty in a variational autoencoder (Section 25.6.4.3) is an entropy of this kind with the prior playing the role of , which is why it remains invariant under smooth reparameterizations of the latent space.
25.8.2 Codes and Compression#
25.8.2.1 Compression without a Model#
Every compressor in Section 25.2 relies on an explicit
probabilistic model to predict the next symbol. The Lempel–Ziv family does
away with that requirement altogether. LZ77 (Ziv and Lempel, 1977) replaces
any repeated substring with a short pointer back to an earlier occurrence,
while LZ78 (Ziv and Lempel, 1978) builds up a dictionary of phrases on the
fly as it scans the file. Remarkably, both algorithms are universal: for any
stationary ergodic source (roughly, one whose long-run statistics are revealed
by a single long sample), their average code length approaches the true entropy
rate as the file grows, even though nobody tells them anything about the
source in advance. In practice, however, convergence to that limit is slow. On
The Time Machine, zlib (which pairs LZ77 with Huffman coding) uses
bits per character, whereas the simple counting model of
Section 25.2.2.2, which predicts each character from the
three characters before it, already gets down to .
25.8.2.2 Bits-Back Coding#
A latent-variable model such as a variational autoencoder cannot directly drive the arithmetic coder of Section 25.2.2.1. The coder needs the exact marginal probability , whereas the model only gives us the ELBO (Section 24.7), a lower bound on built from an approximate posterior . Surprisingly, that lower bound still corresponds to an achievable file length, thanks to a clever duality: decoding a compressed stream is mathematically the same as sampling. If you feed random bits into a decoder designed for , it consumes roughly bits and outputs a latent sample drawn from .
Bits-back coding turns this observation into a practical scheme. Suppose the sender already has a compressed file holding earlier data points; because good compression removes redundancy, the bits at the end of that file look indistinguishable from random coin flips. To encode a new data point , the sender borrows bits from the end of the file and "decodes" them with to draw a latent . The sender then encodes using and using the prior , appending both to the file. To unpack , the receiver reverses the process: it decodes from the prior, decodes from , and then re-encodes using , which puts the borrowed bits right back where they came from. Overall, the file grew by bits and shrank by bits, so its expected net growth under is the negative ELBO. Because the receiver must undo the sender's operations in last-in, first-out order, the underlying coder has to behave like a stack. The bits-back argument itself goes back to Wallace (1990) and Hinton and van Camp (1993), and Frey and Hinton (1997) built the first working coder from it on top of traditional arithmetic coding, which behaves like a queue instead. Asymmetric numeral systems (Duda, 2013) are naturally stack-based, and using them Townsend et al. (2019) demonstrated compressing MNIST with a small variational autoencoder at rates right near its negative ELBO.
25.8.2.3 Description Length beyond Two-Part Codes#
The two-part code of Section 25.2.2.3 encodes the model parameters explicitly at some chosen precision, which makes the total description length sensitive to how finely we discretize the parameter space. A prequential code avoids sending any parameters at all. Instead, it encodes each data point using the model fitted to the points seen so far, just like the adaptive counting model in Section 25.2.2.2, so the cost of learning the model is absorbed directly into the data code length. Blier and Ollivier (2018) used prequential coding to compress the training labels of deep neural networks and obtained far shorter codes than either two-part codes or variational codes (which apply bits-back coding to the network weights). Even a heavily overparameterized network compresses its labels when measured this way. Grünwald (2007) develops both prequential codes and normalized maximum likelihood, the code that minimizes worst-case regret relative to the best model in the class chosen in hindsight. Pushing this compression viewpoint to its theoretical extreme leads to Kolmogorov complexity, the length of the shortest computer program that outputs the data, which unifies all of these ideas, though it is famously uncomputable (Li and Vitányi, 2019).
25.8.2.4 The Constant of a Scaling Law#
In Section 11.6, the held-out loss of language models across many scales is modeled as a constant plus two power-law terms, one decaying with the number of parameters and the other with the number of training tokens (Hoffmann et al., 2022). It is tempting to read as the true entropy of natural text, and in the best case does correspond to the entropy rate per token (Section 25.2.3.1), the floor below which no expected loss can fall. In practice, however, is only a fitted regression constant extrapolated from losses that all sit well above it, not a direct measurement of the entropy rate. Earlier work by Kaplan et al. (2020) fit similar scaling curves with no additive constant at all, an approximation that must eventually break down at large enough scale because the loss cannot fall below the entropy floor. Keep in mind, too, that is measured per token: constants fitted under different tokenizers cannot be compared directly until both are converted to bits per byte (Section 8.3.2.4).
25.8.3 Comparing Distributions#
25.8.3.1 Rényi Divergences and Privacy#
How much does a randomized algorithm leak about a single training record when we run it repeatedly? Differential privacy formalizes this leak as a divergence between the algorithm's output distributions on two datasets that differ in just that one record. Because differentially private SGD injects noise at every gradient step and runs for thousands of iterations, we need a divergence that composes cleanly across independent steps. The Rényi divergence of order (Rényi, 1961),
has this property. Notice that the logarithm sits outside the sum, whereas an f-divergence applies its convex function inside. Because the sum factorizes over independent coordinates, the logarithm turns that product into a sum, so adds cleanly over independent steps, just like KL divergence does and unlike or total variation distance. Rényi differential privacy (Mironov, 2017) bounds for a single noisy step and then sums that bound over the entire training run. While KL divergence also adds across steps, it only controls the log-density ratio on average. Because increases monotonically with , interpolating from KL divergence as to the worst-case log-ratio as , choosing a larger order protects against rare, high-leakage outputs as well. van Erven and Harremoës (2014) provide a thorough catalog of these limits and inequalities, and Exercise 1d of Section 25.3 connects to the -divergences.
25.8.3.2 Information Geometry#
In Section 25.3, a quick Taylor expansion showed that every smooth f-divergence between and reduces, to second order, to the quadratic form in the Fisher information matrix. That might look like an algebraic coincidence, yet Chentsov's theorem shows that it could not have turned out any other way. A positive-definite quadratic form assigns a length to every infinitesimal step , turning the space of distributions into a Riemannian manifold (measuring local steps, whereas the metrics of Section 25.3.1.1 measure global distances between two distributions). For distributions on finite sets, Chentsov proved that the Fisher information is, up to a positive constant, the only Riemannian metric that remains invariant when the raw data are replaced by a sufficient statistic (Čencov, 1982). Every f-divergence shares this invariance: since the data can be resampled from a sufficient statistic without knowing , the data-processing inequality of Section 25.3.3.3 applies in both directions, forcing equality. Consequently, the local quadratic approximation of any smooth f-divergence must be a multiple of the Fisher information. Taking gradient steps whose length is measured in this geometry yields the natural gradient, which K-FAC approximates with one Kronecker product per layer (Section 23.5.5), and the KL trust region of Section 15.2 is, to second order, a ball in this very metric. Amari (2016) develops this geometric perspective in full, showing how maximum likelihood and both steps of the EM algorithm (Section 24.7) can be understood as orthogonal projections.
25.8.3.3 Sinkhorn Divergences and Sliced Wasserstein#
Turning an optimal transport distance into a practical loss on high-dimensional minibatches runs into two obstacles: computational cost and statistical bias. Entropic regularization (Section 25.4.2.4) solves the computational problem, yet it introduces a subtle bias: the regularized transport cost from a distribution to itself is strictly nonzero, so a model trained to minimize it tends to shrink toward a narrower distribution than the data. The Sinkhorn divergence of Exercise 5 in Section 25.4 fixes this by subtracting the average of the two self-transport costs. Beyond that exercise lies the theorem that makes it a trustworthy training objective: on a bounded domain, using the Euclidean distance or its square as the ground cost, the Sinkhorn divergence is nonnegative, equals zero if and only if the two distributions agree, and converges to zero if and only if the model converges in distribution to the data (Feydy et al., 2019).
The sliced Wasserstein distance takes a completely different route. If we project two high-dimensional samples onto a single one-dimensional line, optimal transport reduces to simply sorting the projected values (Section 25.4.2). Averaging this one-dimensional cost over many random directions produces the sliced Wasserstein distance (Bonneel et al., 2015). The catch in high dimensions is that a random direction rarely aligns with the subspace where two distributions actually differ. To get around this, Deshpande et al. (2018) train a discriminator to extract informative features and compute the sliced Wasserstein distance in that learned feature space instead of raw pixels.
25.8.3.4 Lipschitz Critics in Wasserstein GANs#
The Kantorovich–Rubinstein dual in Section 25.4.2 optimizes over 1-Lipschitz functions, a constraint that an ordinary neural network does not satisfy out of the box. Section 16.2 compares the three main ways to enforce it (weight clipping, spectral normalization, and gradient penalties), while Section 16.4 examines gradient penalties in detail. In particular, the penalty of Gulrajani et al. (2017) nudges the critic's gradient norm toward one at random points interpolated between real and generated samples, reflecting the geometric fact that an optimal critic has unit slope along the transport rays connecting matched points (Exercise 3d of Section 25.4).
25.8.3.5 Stein Variational Gradient Descent#
Drawing samples from a distribution known only through its score ordinarily requires running a long stochastic random walk (Section 25.5). In Section 25.5.3, we saw that the kernel Stein discrepancy measures how far a sample distribution sits from such a model . Stein variational gradient descent (Liu and Wang, 2016) turns that discrepancy into a deterministic algorithm that actively transports a set of particles toward . Starting from any initial cloud of points with distribution , each particle moves in small steps along the velocity field
The two terms inside the expectation play complementary roles. The first is a kernel-weighted average of the scores near , which steers particles uphill toward regions of higher probability density. The second is a repulsive force that pushes away from its neighbors, taking over the role of random noise in Langevin dynamics; without it, every particle would collapse onto a single mode. When normalized to the unit ball of the reproducing kernel Hilbert space from Section 25.5.3, this velocity field is the steepest descent direction for , reducing the KL divergence at rate . Remarkably, the same Stein operator serves both as a goodness-of-fit test and as a particle transport rule. Although the particles still require many small steps, the updates are deterministic and the particles spread out cooperatively, which makes the method well suited to approximating a posterior with only a few dozen particles, such as the weights of a small neural network in the original paper.
25.8.4 Mutual Information#
25.8.4.1 Codes That Approach Capacity#
Shannon's channel coding theorem (Section 25.6.3.1) guarantees that reliable communication is possible at every rate below channel capacity, but his proof relies on random codebooks that take exponential time to decode. Bridging the gap between that existence theorem and practical hardware took decades. Low-density parity-check (LDPC) codes, decoded efficiently by passing messages along a sparse factor graph, come remarkably close to capacity in practice (Richardson and Urbanke, 2008). Polar codes (Arikan, 2009) go a step further: they are the first explicit code family provably shown to achieve capacity on symmetric binary-input channels, with both encoding and decoding running in operations for block length . Modern 5G wireless standards put both families to work.
25.8.4.2 Learned Lossy Compression#
In Section 25.6.3.2, we derived the exact rate--distortion curve for a Gaussian source. For natural photographs, no closed-form rate--distortion function is known, so any learned image codec represents a practical operating point somewhere above that unknown frontier. Ballé et al. (2017) train three components jointly: an encoder, a decoder, and an entropy model that defines a learned probability distribution over the quantized latent representation. Because rounding has zero gradient almost everywhere, they replace quantization with additive uniform noise during training. Their objective minimizes , where the rate is the arithmetic-coding length of the latent under the entropy model (Section 25.2) and is the reconstruction distortion of the decoded image; varying traces out the codec's rate--distortion curve by selecting the point with slope . In follow-up work, Ballé et al. (2018) condition the entropy model on a second, smaller latent called a hyperprior, which captures spatial variations in image complexity and substantially lowers the bit rate at the same visual quality.
25.8.5 Estimating Mutual Information#
25.8.5.1 Upper Bounds#
Every variational estimator developed in Section 25.7 is a lower bound on mutual information. That is useful when you want to maximize shared information, but it cannot certify that a learned representation keeps little information about a sensitive or protected attribute it is supposed to discard. Obtaining a genuine upper bound requires access to the conditional density , which a stochastic encoder provides. The variational information bottleneck (Section 25.6.4.3) is one such upper bound, using a fixed marginal approximation . The contrastive log-ratio upper bound, or CLUB (Cheng et al., 2020), removes the need for altogether: it averages over matched pairs in a minibatch and subtracts the average over mismatched pairs. When is the true encoder density, CLUB is an upper bound in expectation. Between a representation and a protected attribute, however, no analytic conditional density is available, so one must fit a neural network in its place. The upper bound then holds only if the fitted conditional is closer in KL divergence to the true joint distribution than to the product of the marginals, a condition that cannot be verified without the very density we were missing in the first place.
25.8.5.2 Bias and Variance of the Bounds#
Even when given the exact optimal critic, variational bounds face a sharp trade-off: NWJ is unbiased on average but suffers from high variance, whereas InfoNCE is low-variance but capped at (Section 25.7.4.4). Poole et al. (2019) introduce a single mixing parameter that smoothly interpolates between the two bounds, letting you dial along this trade-off. Worse still, Song and Ermon (2020) prove that the variance explosion is fundamental rather than an artifact of any one objective: for both NWJ and Donsker--Varadhan bounds, the estimator variance grows exponentially with the true mutual information, even with an exact critic. Their proposed fix clips the critic's density ratio, which tames the variance at the cost of introducing bias. In short, every available remedy shifts error between variance and bias rather than eliminating it.
Because ground-truth mutual information is rarely known on real data, the same authors suggest self-consistency sanity checks that require no known answer: a reliable estimator should remain unchanged when a deterministic function of one variable is appended to that variable, and it should double when a single pair is replaced by two independent copies of itself. On image datasets, the standard estimators they evaluate fail these basic tests. As a practical rule of thumb, always compare a reported mutual information estimate of several nats against the logarithm of the batch size, and trust an estimator on your own data only after verifying that it passes these consistency checks there.
25.8.5.3 Noisy Networks and the Bottleneck View#
The compression debate of Section 25.7.2.5 began when Tishby and Zaslavsky (2015) proposed plotting each layer of a neural network against the information bottleneck frontier (Section 25.6.4), which tracks the maximum achievable for a given . As we saw in that subsection, however, the idea runs into a mathematical snag: in a deterministic network fed continuous inputs, is formally infinite, leaving no finite compression curve to track. Goldfeld et al. (2019) make the question well posed by injecting small Gaussian noise into the hidden activations, which renders finite. Under this noisy model, can indeed decrease during training, and the authors trace that drop to geometric clustering as hidden representations from the same class pull closer together. This clustering, they argue, is what earlier binned mutual-information estimates on deterministic networks were really picking up all along.
25.8.6 General Information Theory Resources#
Books
- Elements of Information Theory — Cover & Thomas: the classic graduate reference that develops entropy, KL divergence (here called relative entropy), mutual information, and their chain rules from first principles, alongside source coding, channel capacity, and rate--distortion theory; accompanies Section 25.1, Section 25.2, and Section 25.6.
- Information Theory, Inference, and Learning Algorithms — David MacKay: freely available online; weaves information theory and machine learning together throughout, with chapters on symbol codes and stream codes (including arithmetic coding) that accompany Section 25.2.
- Information Theory: From Coding to Learning — Polyanskiy & Wu: a modern graduate text geared toward statistics and machine learning, whose treatment of f-divergences, variational representations, and data processing accompanies Section 25.3 and Section 25.6; the MIT 6.441 lecture notes from which the book grew are freely available.
- Computational Optimal Transport — Peyré & Cuturi: covers Wasserstein distances, entropic regularization, and Sinkhorn iterations for data science, supporting the transport half of Section 25.4; the full text is also on arXiv.
- The Minimum Description Length Principle — Peter Grünwald: develops statistical learning as data compression through two-part and universal codes, expanding on Section 25.2.2.3; the core ideas are also presented in a freely available tutorial.
Courses, tutorials, and software
- Stanford EE376A Information Theory — Tsachy Weissman: an accessible course with public, student-scribed lecture notes covering entropy, prefix codes, and typical sets, accompanying Section 25.1 and Section 25.2.
- Visual Information Theory — Christopher Olah: an intuitive visual introduction that builds from codeword lengths to entropy, cross-entropy, and mutual information; accompanies Section 25.1, Section 25.2, and Section 25.6.
- From GAN to WGAN — Lilian Weng: a clear walkthrough comparing the KL, Jensen--Shannon, and Wasserstein losses for generative models, paralleling Section 25.3 and Section 25.4.
- POT: Python Optimal Transport — Flamary et al.: an open-source Python library providing solvers for both exact optimal transport and entropically regularized Sinkhorn iterations, useful for computing the distances of Section 25.4.2 on your own datasets.
- Generative Modeling by Estimating Gradients of the Data Distribution — Yang Song: an accessible tutorial explaining why score functions avoid normalizing constants and how score matching fits them to data (covering Section 25.5) before moving on to sampling and diffusion models.
Foundational papers
- Language Modeling Is Compression — Delétang et al.: pairs an arithmetic coder with a language model's next-token probabilities, the exact idea demonstrated in Section 25.2.2.2.
- f-GAN: Training Generative Neural Samplers using Variational Divergence Minimization — Nowozin et al.: shows that any f-divergence yields an adversarial training objective via its Fenchel conjugate lower bound, as derived in Section 25.3.4.
- A Kernel Two-Sample Test — Gretton et al.: introduces the maximum mean discrepancy, its unbiased two-sample estimator, and the resulting hypothesis test from Section 25.4.1.
- Wasserstein GAN — Arjovsky et al.: replaces the Jensen--Shannon divergence with the Wasserstein-1 distance so that gradients remain informative even when supports do not overlap; accompanies Section 25.4.2.
- Estimation of Non-Normalized Statistical Models by Score Matching — Aapo Hyvärinen: fits unnormalized models by matching the gradient of the log-density to that of the data and eliminating the unknown data score via integration by parts, the two key steps of Section 25.5.
- A Kernelized Stein Discrepancy for Goodness-of-fit Tests — Liu, Lee & Jordan: tests whether a sample comes from a model known only through its score using pairwise kernel evaluations, as presented in Section 25.5.3.
- The Information Bottleneck Method — Tishby, Pereira & Bialek: formulates the problem of compressing while preserving information about , the framework studied in Section 25.6.4.
- Estimating Mutual Information — Kraskov, Stögbauer & Grassberger: estimates the mutual information of continuous variables from nearest-neighbor distances, the estimator of Section 25.7.2.2 on which scikit-learn's
mutual_info_regressionis built. - On Variational Bounds of Mutual Information — Poole et al.: unifies the Barber--Agakov, Donsker--Varadhan, NWJ, and InfoNCE bounds in a single framework and analyzes their bias--variance trade-offs, accompanying Section 25.7.3.
- Representation Learning with Contrastive Predictive Coding — van den Oord et al.: introduces the InfoNCE loss as a lower bound on mutual information for self-supervised representation learning, as developed in Section 25.7.4.