The softmax function #
Real.softmax s i = exp (s i) / ∑ j, exp (s j), the normalized exponential of a
score vector over a finite type: Luce's choice rule with exponential scores
([Luc59]), the multinomial logit of [McF74], and the
Boltzmann–Gibbs distribution. An inverse temperature enters by scaling the
argument, softmax (α • s). With two alternatives it is Real.sigmoid of the
score difference, and Real.logit inverts Real.sigmoid.
softmax s is the density of the exponentially tilted counting measure
Measure.count.tilted s; that face — the partition function as mgf,
log-sum-exp as cgf — is Core.Probability.SoftmaxTheory.
Main definitions #
Real.softmax— the normalized exponential of a score vector.Real.logit— the inverse ofReal.sigmoid.
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— translation invariance.Real.softmax_fin_two— two alternatives giveReal.sigmoid.Real.tendsto_softmax_nhds_zero,Real.tendsto_softmax_atTop,Real.tendsto_softmax_atTop_pi,Real.tendsto_softmax_atBot— softmax in the inverse temperature: uniform at0, a point mass on a strict maximizer (minimizer) asα → ∞(α → -∞).Real.tendsto_sum_negMulLog_softmax_atTop— its entropy vanishes in the hard limit.Real.softmax_sum_apply,Real.sum_softmax_eval_eq— a separable score on a product type gives a product distribution, with coordinate marginals.Real.rpow_div_sum_rpow— Luce's power rule is softmax of log-scores.
The softmax function softmax s i = exp (s i) / ∑ j, exp (s j). An inverse
temperature enters by scaling the argument, 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.
Odds are exponentiated score differences: independence of irrelevant alternatives.
Alias of the reverse direction of Real.softmax_le_softmax_iff.
Alias of the reverse direction of Real.softmax_lt_softmax_iff.
softmax (update s i x) i is strictly increasing in the score x.
Limits in the inverse temperature #
softmax (α • s) is continuous in the inverse temperature α: uniform at
α = 0, concentrating on a strict maximizer as α → ∞ and on a strict
minimizer as α → -∞, with its entropy vanishing in the limit.
At inverse temperature 0, softmax is uniform.
As the inverse temperature grows, softmax concentrates on a strict maximizer.
As the inverse temperature grows, a strictly dominated alternative vanishes.
Softmax converges to the point mass on a strict maximizer.
As the inverse temperature tends to -∞, softmax concentrates on a strict
minimizer.
The entropy of softmax vanishes as it concentrates on a strict maximizer.
Two alternatives and the logit #
With two alternatives, softmax is the logistic function of the score difference.
The logit function log (p / (1 - p)), the inverse of Real.sigmoid.
Equations
- p.logit = Real.log (p / (1 - p))
Instances For
With two alternatives, the log-odds are the score difference.
Luce's power rule f i ^ α / ∑ j, f j ^ α is the softmax of the scaled
log-scores.
Product types #
A separable score s f = ∑ i, c i (f i) on assignments f : ι → V gives a
softmax that factorizes into the coordinate softmaxes, so marginalizing the joint
distribution at coordinate i recovers softmax (c i).
Marginalizing the softmax of a separable score at coordinate i recovers the
coordinate softmax softmax (c i).