Information Theory and Divergences

Dive into Deep Learning · §37

Information Theory and Divergences
entropy · cross-entropy · source coding · f-divergences · optimal transport · scores · mutual information

Why Do We Train Models with Cross-Entropy?

Central Questions of Chapter 37

  • What does a loss number measure? Every cross-entropy loss splits into an irreducible data floor plus a non-negative divergence gap: \textrm{CE}(P, Q) = H(P) + D_{\textrm{KL}}(P \| Q) \ge H(P).
  • Why is log-loss literally a file size? Arithmetic coding compresses n symbols under q(x_i \mid x_{<i}) into n\,\textrm{CE}_2(P, Q) + 2 bits.
  • What when KL blows up? Optimal transport (W_1), kernel MMD, and score matching compare distributions from samples or slopes alone.

Three Core Theorems Every Practitioner Needs

Core Mathematical Pillars

  • Gibbs’ inequality (§37.1): D_{\textrm{KL}}(P \| Q) \ge 0 (= 0 \iff P = Q), so no classifier can beat the conditional label entropy H(Y \mid X).
  • Source coding (§37.2): Kraft’s inequality (\sum_i 2^{-\ell_i} \le 1) and arithmetic coding turn any causal LLM into a lossless compressor.
  • Variational critics (§§37.3–37.7): f-GAN and InfoNCE lower-bound divergences and MI from samples; the InfoNCE bound is capped at \log N nats for batch size N.

Chapter 37 Roadmap: Seven Connected Sections

Chapter Architecture

  • Track 1: Log-Loss, Coding & Perplexity (§§37.1–37.2): Surprisal, Shannon entropy, Gibbs’ floor, label smoothing, distillation, Kraft’s inequality, arithmetic coding, MDL, AEP, and perplexity.
  • Track 2: Divergences, Transport & Scores (§§37.3–37.5): f-divergences, Pinsker’s inequality, f-GAN, IPMs, kernel MMD, Wasserstein W_1, Sinkhorn OT, Stein’s identity, score matching, and KSD.
  • Track 3: Dependence & Contrastive Bounds (§§37.6–37.7): Mutual information, DPI, Fano’s inequality, Information Bottleneck, KSG neighbors, McAllester–Stratos ceiling, and InfoNCE.

Choosing a Distribution Comparison by Access

Practical Decision Guide

  • Normalized density q_{\boldsymbol{\theta}}(\mathbf{x}) > 0: Minimize forward KL D_{\textrm{KL}}(P \| Q_{\boldsymbol{\theta}}) via maximum likelihood (mode-covering).
  • Unnormalized target \tilde{p}(\mathbf{z}, \mathbf{x}) with tractable q_{\boldsymbol{\theta}}: Minimize reverse KL D_{\textrm{KL}}(Q_{\boldsymbol{\theta}} \| P) via variational inference / ELBO (mode-seeking).
  • Implicit sample generator or EBM: Use kernel MMD / Wasserstein W_1 for sample-only generators, or Fisher divergence / KSD when only the score -\nabla_{\mathbf{x}}E_{\boldsymbol{\theta}} is tractable.

Running Benchmarks and Study Paths

How to Navigate This Chapter

Every theoretical bound in this chapter is tested on concrete, reproducible benchmarks:

  • Discrete benchmarks: The dyadic source (\tfrac12, \tfrac14, \tfrac18, \tfrac18), the asymmetric pair P = (0.6, 0.3, 0.1) vs. Q = (0.2, 0.5, 0.3), the flipped bit (\delta = 0.1), and character-level compression of The Time Machine.
  • Continuous benchmarks: Shifted and variance-scaled Gaussians \mathcal{N}(0, 1) vs. \mathcal{N}(d, \sigma^2), bimodal Gaussian mixtures (70/30 split), and the correlated bivariate Gaussian pair at \rho = 0.9 and \rho = 0.99.
  • Three modular tracks:
    1. Log-loss & language models (§§37.1–37.2): Read straight through for supervised learning and perplexity.
    2. Generative modeling comparisons (§§37.3–37.5): Essential background for GANs, flow matching, and diffusion models.
    3. Dependence & contrastive learning (§§37.6–37.7): Self-contained after §37.1; read directly for VAEs, SimCLR, and CLIP.