Softmax

Activation · node type · Softmax, LogSoftmax

Turns a vector of scores into probabilities that are positive and add up to one.

Also called LogSoftmax, Normalized exponential

Softmax turns scores into probabilities. Dividing by a temperature first makes the choice sharper (below 1) or flatter (above 1), the knob text generators use for sampling.

Entropy 1.63 bits of 2.32

cat2.056.7%
dog1.225.5%
fox0.411.4%
owl-0.54.7%
eel-1.51.7%
Figure 1. Try it: every number is computed in your browser from the formula below.

What it does

Softmax exponentiates every score and divides by the sum. The largest score gets the largest share, and adding the same constant to every score changes nothing, so only differences between scores matter. Dividing the scores by a temperature before the softmax controls how peaked the result is: a low temperature sharpens it toward the top class, a high one flattens it toward uniform. Classifiers end with it, attention uses it to turn match scores into mixing weights, and generative models sample from it. LogSoftmax returns the logarithm directly, which is numerically safer for training and CTC decoding.

Formula

softmax(z)i = ezi / τ / Σj ezj / τsoftmax(z + c) = softmax(z)logsoftmax(z)i = zi − log Σj ezj

Shapes and parameters

Shapes
Any shape in, the same shape out; each slice along the chosen axis sums to one.
Parameters
None. The temperature τ is a setting chosen at run time, not a learned parameter.
Used for
The output of classifiers (plants, expressions, emotions, voice commands, sound events), attention weights, next-token and next-note sampling, CTC transcription.

Figure 2. Softmax inside Continue a melody, a real model in WeightSpace. The outlined node is Softmax; select any node for its shapes and parameters.

Figure 3. The typed ports of Softmax, in the same format as every model drawing. Letters such as N or C stand for any size.

In WeightSpace

No parameters of its own, but it is where most WeightSpace edits show up. Adding δ to one class bias multiplies that class’s unnormalized probability by e^δ before renormalizing, so +2 makes it about 7.4 times more likely relative to the others.