Entropy, Cross-Entropy, and KL Divergence

Dive into Deep Learning · §37.1

Entropy, Cross-Entropy, and KL Divergence
self-information · Shannon entropy · Gibbs’ inequality · irreducible loss · label smoothing · distillation

What Do Numbers on a Loss Curve Actually Mean?

Motivation & Core Question

  • Untrained 10-class baseline (\ln 10 \approx 2.30 nats): Uniform guessing (q_j = 1/10) incurs 2.30 nats of surprise per example.
  • Clean vs. noisy floors (0 vs. 0.545 nats): Clean deterministic labels have floor 0, whereas 10\% symmetric label noise creates an irreducible floor H(Y \mid X) = 0.545 nats.
  • Diagnosing plateaus: A plateau at 0.60 nats is poor on clean labels, but within 0.055 nats of Bayes-optimal under 10\% label noise.

Self-Information Quantifies Event Surprisal

Self-Information

How much information do we gain by observing an outcome x of probability p(x)?

  • Shannon’s three requirements:
    1. A certain event (p = 1) carries zero surprise: I(1) = 0.
    2. Rarer events carry strictly more surprise: I(p) decreases with p.
    3. Independent events have additive surprise: I(p_1 p_2) = I(p_1) + I(p_2).
  • Unique mathematical solution: Up to a choice of scale (the logarithm base), the only function satisfying these axioms is the self-information (or surprisal): I(x) = -\log p(x)
  • Units: Base e measures information in nats; base 2 measures it in bits (1\text{ bit} = \ln 2 \approx 0.693\text{ nats}).
image/svg+xml Matplotlib v3.11.2, https://matplotlib.org/

Computing Surprisal Across Scales: 52! Cards

Self-Information in Practice

Surprisal scales logarithmically from single coin flips to vast combinatorial spaces without numerical overflow:

Observation from a Shuffled Deck Probability p(x) Surprisal in Nats (-\ln p) Surprisal in Bits (-\log_2 p)
“I see a card” (certain event) 1 0.00 0.00
“I see a heart” (1 of 4 suits) 1/4 \ln 4 \approx 1.39 2.00
“It is the three of spades” (1 of 52) 1/52 \ln 52 \approx 3.95 5.70
Full ordering of the entire 52-card deck 1/52! \ln \Gamma(53) \approx 156.36 225.58
deck_order = math.lgamma(53)          # ln 52! without forming 52!
print(f'the order of the deck: {deck_order:.2f} nats '
      f'= {deck_order / math.log(2):.1f} bits')
the order of the deck: 156.36 nats = 225.6 bits

Shannon Entropy Is Expected Self-Information

Discrete Entropy

For a discrete random variable X \sim P with probabilities p_i, Shannon entropy is the expected surprisal:

H(X) = H(P) = -\mathbb{E}_{x \sim P}[\log p(x)] = -\sum_i p_i \log p_i

  • Zero-probability rule (0\log 0 = 0): Impossible events contribute zero expected surprise.
  • Range & invariance: 0 \le H(P) \le \log k (0 iff deterministic, \log k iff uniform), depending only on \mathbf{p} and never on outcome values.

Operational Meaning: Optimal Yes/No Questions

Entropy & Binary Codes

On a finite set, H_2(P) in bits counts the average number of yes/no questions an optimal strategy needs to identify an outcome:

  • The dyadic source: Take P = (\tfrac12, \tfrac14, \tfrac18, \tfrac18) over four symbols \{a, b, c, d\}, whose surprisals are (1, 2, 3, 3) bits.
  • Adaptive questioning strategy: Ask “Is it a?” first (settling the game 50\% of the time in 1 question), then “Is it b?”, then “Is it c?” (yielding codewords 1, 01, 001, 000): \mathbb{E}[\text{questions}] = \tfrac12 \cdot 1 + \tfrac14 \cdot 2 + \tfrac18 \cdot 3 + \tfrac18 \cdot 3 = 1.75\text{ bits} = H_2(P)
def entropy(p):
    """Entropy of a probability vector, in nats (0 log 0 = 0 by masking)."""
    p = np.asarray(p, dtype=float)
    p = p[p > 0]
    return float(-np.dot(p, np.log(p)))

p_dyadic = np.array([1 / 2, 1 / 4, 1 / 8, 1 / 8])
h = entropy(p_dyadic)
print(f'H = {h:.3f} nats = {h / math.log(2):.2f} bits')
H = 1.213 nats = 1.75 bits

Joint Entropy, Conditional Entropy, Chain Rule

Pairs & Sequences

Because \log p(x, y) = \log p(x) + \log p(y \mid x), taking expectations decomposes joint uncertainty additively:

H(X, Y) = H(X) + H(Y \mid X)

  • Autoregressive sequence chain rule: H(X_1, \ldots, X_n) = \sum_{i=1}^n H(X_i \mid X_{<i}).
  • Dyadic check: Asking “Is it a?” uses H_2(X) = 1.00 bit and leaves H_2(Y \mid X) = \tfrac12(0) + \tfrac12(1.5) = 0.75 bits, totaling 1.75 bits.

Binary Entropy and the Uniform Upper Bound

Maximum Discrete Entropy

How uncertain can a discrete random variable over k outcomes possibly be?

  • Binary entropy function: For a Bernoulli coin with heads probability p \in [0, 1]: H_b(p) = -p \log p - (1-p)\log(1-p)
  • Strict concavity and peak: H_b(p) vanishes at the deterministic endpoints p \in \{0, 1\} and peaks uniquely at a fair coin p = \tfrac12, where H_b(\tfrac12) = \ln 2 \approx 0.693 nats (1 bit).
  • General k-outcome ceiling: Any distribution P on k outcomes satisfies H(P) \le \log k, with equality if and only if P is uniform (p_i = 1/k).
image/svg+xml Matplotlib v3.11.2, https://matplotlib.org/

KL Divergence Measures Average Extra Surprisal

Kullback–Leibler Divergence

Suppose data are drawn from the true distribution P, but we evaluate probabilities using a model Q. The KL divergence (or relative entropy) averages our extra surprisal under P:

D_{\textrm{KL}}(P \| Q) = \mathbb{E}_{x \sim P}\!\left[\log \frac{p(x)}{q(x)}\right] = \mathbb{E}_{x \sim P}\big[(-\log q(x)) - (-\log p(x))\big]

  • Operational meaning in bits: D_{\textrm{KL}}^{(2)}(P \| Q) is the expected number of extra yes/no questions per symbol incurred by designing a questioning strategy for Q when outcomes actually follow P.
  • Worked calculation on the running pair: For P = (0.6, 0.3, 0.1) and Q = (0.2, 0.5, 0.3): D_{\textrm{KL}}(P \| Q) = 0.6 \ln\frac{0.6}{0.2} + 0.3 \ln\frac{0.3}{0.5} + 0.1 \ln\frac{0.1}{0.3} = 0.659 - 0.153 - 0.110 = 0.396\text{ nats}
  • Inherent asymmetry: Reversing the roles of truth and model yields D_{\textrm{KL}}(Q \| P) = 0.365\text{ nats} \neq D_{\textrm{KL}}(P \| Q).

KL Asymmetry and the Zero-Probability Penalty

KL Divergence in Code

If q'(x) = 0 where p(x) > 0, the surprisal -\log q'(x) is infinite and D_{\textrm{KL}}(P \| Q') = +\infty:

def kl_divergence(p, q):
    """KL(P || Q) for two probability vectors, in nats; inf where q = 0 < p."""
    p, q = np.asarray(p, dtype=float), np.asarray(q, dtype=float)
    m = p > 0
    if np.any(q[m] == 0):
        return float('inf')
    return float(np.dot(p[m], np.log(p[m] / q[m])))

p = np.array([0.6, 0.3, 0.1])
q = np.array([0.2, 0.5, 0.3])
print(f'KL(P||Q) = {kl_divergence(p, q):.4f} nats, '
      f'KL(Q||P) = {kl_divergence(q, p):.4f} nats')
print(f"KL(P||Q') = {kl_divergence(p, [0.5, 0.5, 0.0])}")
KL(P||Q) = 0.3961 nats, KL(Q||P) = 0.3653 nats
KL(P||Q') = inf

Why Softmax Never Outputs Zero: Because e^{z_j} > 0 for all finite logits z_j, a softmax classifier guarantees q_j > 0 everywhere and avoids infinite KL loss.

Gibbs’ Inequality: No Model Beats the Truth

Fundamental Theorem

For any distributions P and Q, Gibbs’ inequality states D_{\textrm{KL}}(P \| Q) \ge 0, with equality iff P = Q:

D_{\textrm{KL}}(P \| Q) = -\mathbb{E}_{P}\!\left[\log\frac{q(x)}{p(x)}\right] \ge -\log Q(\textrm{supp}\,P) \ge 0

  • Jensen step: Strictly concave \log bounds -\mathbb{E}_P[\log(q/p)] \ge -\log\mathbb{E}_P[q/p] = -\log Q(\textrm{supp}\,P) \ge 0.
  • Equality certificate: Strict concavity forces q(x)/p(x) = 1 across \textrm{supp}\,P, so P = Q.

Two Immediate Corollaries of Gibbs’ Inequality

Uniform Bound & Conditioning

Gibbs’ inequality settles two foundational properties of entropy in a single line each:

  • 1. The uniform distribution maximizes discrete entropy (H(P) \le \log k): Compare any distribution P on k outcomes against the uniform distribution U = (1/k, \ldots, 1/k): 0 \le D_{\textrm{KL}}(P \| U) = \sum_{i=1}^k p_i \log\frac{p_i}{1/k} = \log k - H(P) \implies H(P) \le \log k
  • 2. Conditioning never increases entropy on average (H(Y \mid X) \le H(Y)): Compare the joint distribution p_{X,Y} against the independent product of marginals p_X p_Y: H(Y) - H(Y \mid X) = \mathbb{E}_{p_{X,Y}}\!\left[\log\frac{p(x, y)}{p(x)p(y)}\right] = D_{\textrm{KL}}(p_{X,Y} \,\|\, p_X p_Y) \ge 0 (Note: A single realization X = x can still have H(Y \mid X = x) > H(Y), as when a rare indicator X=1 reveals that an otherwise deterministic coin is fair.)

Cross-Entropy Decomposes into Entropy Plus KL

The Loss Decomposition

The cross-entropy from P to Q is the average surprisal experienced by Q on data drawn from P:

  • Exact additive split: Adding and subtracting \log p(x) inside \textrm{CE}(P, Q) = -\mathbb{E}_P[\log q(x)] yields: \textrm{CE}(P, Q) = H(P) + D_{\textrm{KL}}(P \| Q)
  • Why MLE minimizes KL: Because data entropy H(P) does not depend on model parameters \boldsymbol{\theta}, minimizing \textrm{CE}(P, Q_{\boldsymbol{\theta}}) is identical to minimizing D_{\textrm{KL}}(P \| Q_{\boldsymbol{\theta}}).
  • Running examples: On (P, Q), 1.294 = 0.898 + 0.396 nats; on the dyadic source vs. uniform U, 2.00 = 1.75 + 0.25 bits.
image/svg+xml Matplotlib v3.11.2, https://matplotlib.org/

One-Hot Classification and Stable Log-Softmax

Supervised Classification Loss

In k-class classification, how does the general cross-entropy formula become our training loss?

  • Single-example loss: For a recorded label y \in \{1, \ldots, k\}, the empirical target is the one-hot vector \mathbf{e}_y, so \textrm{CE}(\mathbf{e}_y, \mathbf{q}) = -\sum_{j=1}^k \mathbf{1}(j = y)\log q_j = -\log q_y.
  • Dataset empirical NLL: Averaging over n training examples \{(\mathbf{x}_i, y_i)\}_{i=1}^n gives: \mathcal{L}_{\textrm{CE}} = -\frac{1}{n}\sum_{i=1}^n \log q_{i, y_i}
  • Numerical stability via LogSumExp: Forming q_j = e^{z_j}/\sum_\ell e^{z_\ell} first overflows for large logits and underflows to \log 0 = -\infty for negative logits. Frameworks shift by m = \max_\ell z_\ell directly inside log-space: \log q_y = (z_y - m) - \log \sum_{\ell=1}^k e^{z_\ell - m}

The Irreducible Classification Loss Floor

Population Loss Decomposition

On fresh test examples (\mathbf{x}, y) \sim P, population cross-entropy splits into conditional label entropy plus expected KL:

\mathbb{E}_{(\mathbf{x}, y)}\big[-\log q(y \mid \mathbf{x})\big] = H(Y \mid X) + \mathbb{E}_{\mathbf{x}}\big[D_{\textrm{KL}}\big(p(\cdot \mid \mathbf{x}) \,\|\, q(\cdot \mid \mathbf{x})\big)\big]

  • Unique global optimum: Attains H(Y \mid X) iff q(\cdot \mid \mathbf{x}) = p(\cdot \mid \mathbf{x}) almost everywhere.
  • Symmetric noise floor (rate \rho, k classes): H(Y \mid X) = H_b(\rho) + \rho\log(k - 1).

Symmetric Label Noise and Overconfidence Cost

Worked Example: 10% Label Noise

With k = 10 classes and \rho = 0.1 label noise, the floor is H_b(0.1) + 0.1 \ln 9 = 0.325 + 0.220 = 0.545 nats. Compare three predictors on this noisy test distribution:

floor = H(p) = 0.545 nats
uniform         CE = 2.303 nats
confident 0.99  CE = 0.689 nats
Bayes q = p     CE = 0.545 nats

Why Overconfidence Hurts: A classifier predicting 0.99 on the clean class achieves the maximum possible 90\% accuracy, yet suffers 0.689 nats loss because each 10\% flipped label inflicts -\ln(0.01/9) = 6.80 nats of surprise.

Strictly Proper Scoring Rules and Calibration

Decision Theory & Calibration

  • Strictly proper scoring rule: A penalty S(\mathbf{q}, y) whose expected score \mathbb{E}_{y \sim \mathbf{p}}[S(\mathbf{q}, y)] is uniquely minimized by reporting \mathbf{q} = \mathbf{p} (guaranteeing calibrated probabilities).
  • Log score (-\log q_y): Excess over truth is D_{\textrm{KL}}(\mathbf{p} \| \mathbf{q}) \ge 0; diverges as q_y \to 0, heavily punishing confident errors.
  • Brier score (\sum_j(q_j - \mathbf{1}_{j=y})^2): Excess over truth is \|\mathbf{q} - \mathbf{p}\|_2^2 \ge 0; bounded by 2 even when q_y = 0.

Label Smoothing Creates a Finite Optimal Gap

Softened Targets

With one-hot targets (\mathbf{e}_y), reaching q_y = 1 requires an infinite logit gap z_y - z_j \to \infty, causing unbounded weight growth and overconfidence. Label smoothing mixes \mathbf{e}_y with uniform mass \epsilon \in (0, 1):

\mathbf{p}^\epsilon = (1 - \epsilon)\mathbf{e}_y + \frac{\epsilon}{k}\mathbf{1}

  • Finite optimal logit gap: Minimizing \textrm{CE}(\mathbf{p}^\epsilon, \mathbf{q}) sets q_y = 1 - \epsilon + \epsilon/k and q_j = \epsilon/k (j \neq y), which softmax achieves at a finite gap: z_y - z_j = \log\frac{1 - \epsilon + \epsilon/k}{\epsilon/k} = \log\!\left(1 + \frac{k(1 - \epsilon)}{\epsilon}\right)
  • Concrete numbers (k = 10, \epsilon = 0.1): The optimal logit gap is \ln 91 \approx 4.51, the maximum predicted probability is capped at 0.91, and training loss plateaus at H(\mathbf{p}^\epsilon) = 0.500 nats instead of 0.

Logit Drift Under One-Hot vs. Smoothed Targets

Gradient Dynamics

Under gradient descent on one example (\nabla_{\mathbf{z}} \textrm{CE} = \mathbf{q} - \mathbf{p}^\epsilon), a one-hot target (\epsilon = 0) widens the logit gap g_t by \approx k e^{-g_t} per step, causing logarithmic drift g_t \approx \ln(kt), whereas \epsilon = 0.1 arrests the gap at \ln 91 = 4.51:

eps = 0.0  step    10  gap =  4.29  loss = 0.1158
eps = 0.0  step   100  gap =  6.87  loss = 0.0093
eps = 0.0  step  1000  gap =  9.21  loss = 0.0009
eps = 0.0  step 10000  gap = 11.51  loss = 0.0001
eps = 0.1  step    10  gap =  3.81  loss = 0.5243
eps = 0.1  step   100  gap =  4.51  loss = 0.5003
eps = 0.1  step  1000  gap =  4.51  loss = 0.5003
eps = 0.1  step 10000  gap =  4.51  loss = 0.5003
optimum for eps = 0.1: gap = ln 91 = 4.51, loss = H(p_eps) = 0.5003

Knowledge Distillation and Temperature Scaling

Teacher-Student Distillation

In knowledge distillation, a compact student network \mathbf{z}^{\textrm{stu}} trains to match the dark knowledge in a teacher’s wrong-class probabilities by softening both with temperature \tau > 0:

p_j^{(\tau)} = \mathrm{softmax}(\mathbf{z}^{\textrm{tea}}/\tau)_j, \qquad q_j^{(\tau)} = \mathrm{softmax}(\mathbf{z}^{\textrm{stu}}/\tau)_j, \qquad \mathcal{L}_{\textrm{distill}} = \tau^2 D_{\textrm{KL}}\!\left(\mathbf{p}^{(\tau)} \,\|\, \mathbf{q}^{(\tau)}\right)

  • Why multiply by \tau^2? The gradient of unscaled D_{\textrm{KL}}(\mathbf{p}^{(\tau)} \| \mathbf{q}^{(\tau)}) with respect to student logit z_j^{\textrm{stu}} is \frac{1}{\tau}(q_j^{(\tau)} - p_j^{(\tau)}).
  • High-temperature Taylor expansion (\tau \gg 1): Expanding \mathrm{softmax}(\mathbf{z}/\tau)_j \approx \frac{1}{k}(1 + \frac{z_j - \bar{z}}{\tau}) shows that the probability gap shrinks like 1/\tau, so the unscaled gradient decays like 1/\tau^2: \frac{\partial}{\partial z_j^{\textrm{stu}}} D_{\textrm{KL}}\!\left(\mathbf{p}^{(\tau)} \,\|\, \mathbf{q}^{(\tau)}\right) \approx \frac{1}{k\tau^2}\Big(\big(z_j^{\textrm{stu}} - \bar{z}^{\textrm{stu}}\big) - \big(z_j^{\textrm{tea}} - \bar{z}^{\textrm{tea}}\big)\Big)

Verifying the τ² Gradient Scaling in Code

Distillation Numerics

Without the \tau^2 factor, raising \tau from 1 to 20 shrinks the distillation gradient norm 300\times (from 0.64 to 0.0021); multiplying by \tau^2 keeps the gradient magnitude steady near the zero-mean logit-matching limit:

 tau  |grad|  |tau^2 grad|  tau^2 grad
   1  0.6391         0.639  [-0.462  0.441  0.022]
   2  0.2190         0.876  [-0.672  0.549  0.123]
   5  0.0368         0.920  [-0.741  0.478  0.263]
  10  0.0088         0.884  [-0.719  0.413  0.306]
  20  0.0021         0.854  [-0.697  0.374  0.322]
limit                0.816  [-0.667  0.333  0.333]

Differential Entropy Shifts with Coordinate Units

Continuous Random Variables

For a continuous random variable X with density p(x), the differential entropy is h(X) = -\int p(x)\log p(x)\,dx. Unlike discrete entropy H(X), differential entropy is neither non-negative nor scale-invariant:

  • Negative values and unit sensitivity: For X \sim \mathrm{Unif}[0, a], p(x) = 1/a gives h(X) = \log a. At a = \tfrac12\text{ m}, h(X) = -\ln 2 \approx -0.693 nats; recording the same length in centimetres (a = 50\text{ cm}) adds \ln 100 \approx 4.61 nats.
  • Change-of-variables law: Under any smooth bijection \mathbf{y} = g(\mathbf{x}), the Jacobian shifts h: h(g(\mathbf{X})) = h(\mathbf{X}) + \mathbb{E}\big[\log |\det Dg(\mathbf{X})|\big]
  • Quantization limit and KL invariance: Binning X into cells of width \Delta gives H(X_\Delta) + \log \Delta \to h(X) as \Delta \to 0. In D_{\textrm{KL}}(P \| Q) = \int p(x)\log\frac{p(x)}{q(x)}\,dx, the Jacobian factors cancel in the ratio p/q, so KL divergence is completely invariant to coordinate rescaling.

KL Divergence Between Univariate Gaussians

Closed Form & Tail Asymmetry

Comparing two Gaussian distributions P = \mathcal{N}(\mu_1, \sigma_1^2) and Q = \mathcal{N}(\mu_2, \sigma_2^2) yields an exact closed form:

  • Exact Gaussian KL formula: D_{\textrm{KL}}(P \| Q) = \log\frac{\sigma_2}{\sigma_1} + \frac{\sigma_1^2 + (\mu_1 - \mu_2)^2}{2\sigma_2^2} - \frac{1}{2}
  • Wide model vs. narrow data: D_{\textrm{KL}}(\mathcal{N}(0, 1) \| \mathcal{N}(0, 4)) = \ln 2 + \tfrac18 - \tfrac12 \approx 0.318 nats.
  • Narrow model vs. wide data: D_{\textrm{KL}}(\mathcal{N}(0, 4) \| \mathcal{N}(0, 1)) = -\ln 2 + 2 - \tfrac12 \approx 0.807 nats (2.5\times larger due to heavy tail surprisal for |x| > 1.36).

Monte Carlo KL Estimation and Maximum Entropy

Sampling Variance & Gaussian Optimality

Estimating D_{\textrm{KL}}(P \| Q) from n = 2 \times 10^5 samples is 4\times noisier when sampling the wide Gaussian (16\times more samples needed for equal precision) because the divergence lives in the sparse tails:

P || Q              closed  sampled  std err
N(0,1) || N(1,1)    0.5000   0.5010   0.0022
N(0,1) || N(0,4)    0.3181   0.3169   0.0012
N(0,4) || N(0,1)    0.8069   0.8017   0.0047

Gaussian Maximum Entropy Theorem: Because the Gaussian surprisal -\log \varphi(x) = \tfrac12\log(2\pi\sigma^2) + \frac{(x-\mu)^2}{2\sigma^2} is quadratic, \textrm{CE}(P, \varphi) = \tfrac12\log(2\pi e\sigma^2) = h(\varphi) for every density P with mean \mu and variance \sigma^2. Thus h(P) = h(\varphi) - D_{\textrm{KL}}(P \| \varphi) \le \tfrac12\log(2\pi e\sigma^2), with equality if and only if P = \mathcal{N}(\mu, \sigma^2).

Concept Check: Entropy, Noise Floors, Units

Check Your Understanding

Work through these three diagnostic calculations:

  1. Untrained baseline: What cross-entropy loss does a freshly initialized uniform classifier report on 3 classes in nats, and on 10 classes in bits?
  2. Suspicious validation loss: On a 10-class dataset where every split has 20\% symmetric label noise, what is the irreducible population loss floor? What must you conclude if a colleague reports a validation loss of 0.40 nats?
  3. Rescaling continuous targets: Adult heights are roughly Gaussian with standard deviation \sigma = 0.07\text{ m}. What happens to their differential entropy h(X) and to D_{\textrm{KL}}(P \| Q) when heights are converted to centimetres?

Answers:

  1. Untrained baseline: \ln 3 \approx 1.10\text{ nats} for 3 classes; \log_2 10 = \frac{\ln 10}{\ln 2} \approx 3.32\text{ bits} (2.30\text{ nats}) for 10 classes.
  2. Noise floor: H_b(0.2) + 0.2\ln 9 = 0.500 + 0.439 = 0.940\text{ nats} (max accuracy 80\%). A validation loss of 0.40 < 0.940 cannot come from a better model—it signals data leakage or cleaned validation labels.
  3. Units: In metres, h = \tfrac12\ln(2\pi e) + \ln 0.07 = 1.42 - 2.66 = -1.24\text{ nats}. Converting to centimetres multiplies \sigma by 100, adding \ln 100 = 4.61\text{ nats} to give +3.36\text{ nats}, while D_{\textrm{KL}}(P \| Q) is completely unchanged.

Summary: Information-Theoretic Quantities

Key Takeaways

Quantity Mathematical Definition Range & Invariance Deep Learning Role
Self-Information I(x) = -\log p(x) [0, \infty]; additive on independent events Single-example negative log-likelihood loss
Discrete Entropy H(P) = -\sum_{i=1}^k p_i \log p_i [0, \log k]; peaks at uniform U Irreducible loss floor H(Y \mid X); expected questions
Differential Entropy h(P) = -\int p(x)\log p(x)\,dx (-\infty, \infty); shifts by \mathbb{E}[\log|\det Dg|] Gaussian max-entropy \tfrac12\log(2\pi e\sigma^2) at fixed variance
KL Divergence D_{\textrm{KL}}(P \| Q) = \mathbb{E}_P[\log(p/q)] [0, \infty]; 0 \iff P = Q; scale-invariant Extra surprisal; penalty for model mismatch
Cross-Entropy \textrm{CE}(P, Q) = H(P) + D_{\textrm{KL}}(P \| Q) [H(P), \infty]; strictly proper log score Standard training objective for classifiers & LLMs
Label Smoothing \mathbf{p}^\epsilon = (1-\epsilon)\mathbf{e}_y + (\epsilon/k)\mathbf{1} Optimal logit gap \log(1 + k(1-\epsilon)/\epsilon) Prevents unbounded logit drift and overconfidence
Distillation Loss \tau^2 D_{\textrm{KL}}(\mathbf{p}^{(\tau)} \| \mathbf{q}^{(\tau)}) \mathcal{O}(1) gradient scale across all \tau > 0 Transfers wrong-class dark knowledge from teacher