The softmax function #
This file defines the softmax function Real.softmax s i = exp (s i) / ∑ j, exp (s j), which
normalizes the exponentials of a score vector over a finite type. It is Luce's choice rule with
exponential scores, McFadden's multinomial logit, and the Boltzmann–Gibbs distribution. An
inverse temperature enters by scaling the argument, as in softmax (α • s). With two
alternatives softmax is Real.sigmoid of the score difference.
Log-sum-exp x ↦ log (∑ i, exp (x i)), the logarithm of the normalizer, is convex, and its
derivative is the softmax expectation of the derivative of the scores.
Main definitions #
Real.softmax: the normalized exponential of a score vector.
Main results #
Real.sum_softmax,Real.softmax_pos:softmax sis a probability distribution.Real.softmax_div_softmax,Real.log_softmax_div_softmax: odds are exponentiated score differences (independence of irrelevant alternatives).Real.softmax_le_softmax_iff,Real.softmax_update_strictMono: monotonicity in the scores.Real.softmax_add_const,Real.softmax_const: translation invariance, and the uniform distribution for constant scores.Real.convexOn_log_sum_exp,HasFDerivAt.log_sum_exp: log-sum-exp is convex, and its derivative is the softmax-weighted derivative of the scores.Real.tendsto_softmax_atTop: softmax concentrates on a strict maximizer as the inverse temperature grows.Real.softmax_eq_sigmoid_of_univ_eq_pair,Real.softmax_fin_two: two alternatives giveReal.sigmoid.Real.softmax_sum_apply: a separable score on a product type gives a product distribution.
References #
The softmax function sends a score vector s to i ↦ exp (s i) / ∑ j, exp (s j). An
inverse temperature enters by scaling the argument, as in softmax (α • s).
Equations
- Real.softmax s i = Real.exp (s i) / ∑ j : ι, Real.exp (s j)
Instances For
Softmax is invariant under translating every score by the same constant.
Equal scores give the uniform distribution.
The odds of two alternatives are their exponentiated score difference, whatever the other alternatives are.
Convexity #
Log-sum-exp, the logarithm of softmax's normalizer, is convex. Hölder's inequality with
exponents a⁻¹ and b⁻¹ bounds ∑ i, exp (a * s i + b * t i) by
(∑ i, exp (s i)) ^ a * (∑ i, exp (t i)) ^ b.
The derivative of log-sum-exp #
The derivative of log-sum-exp of a family of scores is the softmax-weighted sum of their derivatives.
softmax (update s i x) i is strictly increasing in the score x.
The limit of low temperature #
As the inverse temperature grows, softmax concentrates on a strict maximizer.
Two alternatives #
With two alternatives, softmax is the logistic function of the score difference.
Product types #
The softmax of a separable score ∑ i, c i (g i) on assignments g : ι → V is the product
of the coordinate softmaxes.