Skip to content
Lambdian

Softmax

A function that turns a list of scores into probabilities that add up to one.

softmax⁡(z)k=ezk∑jezj\operatorname{softmax}(\mathbf{z})_k = \frac{e^{z_k}}{\sum_j e^{z_j}}

Exponentiating makes every score positive and exaggerates the largest; dividing by the sum normalises them. Softmax is the output layer of almost every multi-class classifier. Subtract the largest score before exponentiating to avoid overflow; the result is unchanged. Dividing scores by a temperature makes the distribution sharper or flatter.

See it in action