Entropy and cross-entropy
H(p) is the entropy of a distribution: its average surprise. H(p, q) is the cross-entropy.
In ML papers
or is the entropy: the expected value of , so it measures how uncertain or spread out a distribution is. It is 0 for a distribution that always gives the same outcome and largest for a uniform one. With it is in bits, with the natural log in nats.
is the cross-entropy: the average surprise when outcomes come from but you score them with . The usual classification loss is the cross-entropy between the one-hot label and the model's softmax output, which reduces to for the true class . It splits as (KL divergence).
is the conditional entropy: the uncertainty left in once is known.
Other meanings, by context
- Bold or upright H. is often a matrix of hidden states, or the Hessian (Hessian matrix).
- Calligraphic H. is a hypothesis class or a Hilbert space; soft actor-critic also writes the policy's entropy as .
How to type it
| LaTeX | Shows |
|---|---|
H(X) | |
H(p, q) cross-entropy | |
\mathbb{H}[p] some papers |
A worked example
A fair coin has 1 bit of entropy; a coin that lands heads 90% of the time has about bits.
Common confusions
- with a comma is the cross-entropy; with random variables is the joint entropy. Check whether the arguments are distributions or variables.