Softmax & Multiclass
Softmax & Multiclass — Softmax converts a vector of raw class scores (logits) into probabilities that sum to 1 by exponentiating and normalizing. A temperature parameter sharpens it toward a hard argmax or flattens it toward uniform.
Three or more classes carve the space into colored regions. A bar panel shows raw scores becoming probabilities — and a temperature dial slides softmax from a confident winner-take-all to a flat shrug.
- Class 0
- Class 1
- Class 2
- Prototype μ (drag me)
Softmax controls
The idea in plain words
Softmax turns a handful of raw class scores into probabilities that sum to one, by exponentiating and normalizing. It’s the multiclass generalization of the sigmoid, and it powers the output layer of nearly every neural network classifier.
A temperature dial controls how peaked it is. Near zero it becomes a hard argmax — one class takes everything — so tiny changes flip the winner. Turn it up and the probabilities flatten toward a uniform shrug.
Now, the math
Softmax with temperature T:
- the raw score (logit) for class i.
- temperature — low sharpens toward argmax, high flattens toward uniform.
▸ Show the derivation
Dividing logits by T before exponentiating rescales the gaps between them. As T → 0 the largest logit dominates completely (probability 1); as T → ∞ all scaled logits approach 0 and the probabilities become equal. This same knob is used to calibrate confidence and to soften targets in model distillation.
Trace it by hand
Three classes with logits z = (2.0, 1.0, 0.1), starting at temperature T = 1. Exponentials and probabilities rounded to 3 decimal places.
Exponentiate each logit
Normalize into probabilities
A logit gap of 1.0 became a probability ratio of e, about 2.72 — softmax works on differences, not absolute values.
Sharpen with T = 0.5
Halving T doubles every logit gap before exponentiating, so the leader pulls away.
Flatten with T = 5
The ranking never changes with temperature — only the confidence does.
What just happened: The same logits (2.0, 1.0, 0.1) produced a 66 percent, an 86 percent, or a 40 percent favorite purely by rescaling with temperature — softmax preserves the winner but T sets how much the winner takes.
Now Break It
Try this: Temperature near zero makes the classifier brittle — the winner flips on tiny changes.
Control: Temperature slider (set very low)
What happens: Winner-take-all! At near-zero temperature softmax becomes a hard argmax that flips on the slightest change.
Where softmax & multiclass is used
The softmax function converts a vector of raw model scores, called logits, into a set of probabilities that are all positive and sum to one, which is exactly what you need to pick among several mutually exclusive classes. It is the standard output layer for multiclass classifiers, from the final layer of neural networks recognizing thousands of object categories to multinomial logistic regression. Every image classifier that reports a most-likely label with a confidence, every language model choosing the next token from a vocabulary, and every speech recognizer selecting among phonemes ends in a softmax. Because the outputs form a proper probability distribution, they plug directly into the cross-entropy loss used to train these models and into downstream decisions like ranking or thresholding.
A frequent misconception is that softmax probabilities measure true confidence or real-world likelihood; they are relative scores that always sum to one, so a model can be completely wrong yet assign 99 percent to the incorrect class, especially on inputs unlike anything it trained on. Another pitfall is confusing softmax with the sigmoid: softmax is for choosing one class among several that compete, whereas independent sigmoids suit multi-label problems where several labels can be true at once. People also forget that softmax is shift-invariant, meaning adding a constant to every logit leaves the output unchanged, which is why stable implementations subtract the maximum logit first to avoid numerical overflow. Finally, a temperature parameter can sharpen or soften the distribution without changing which class ranks highest.
Frequently asked questions
How is softmax different from the sigmoid function?
Do softmax outputs represent true confidence?
What are logits?
Why do stable implementations subtract the maximum logit?
What does the temperature parameter do?
How does softmax connect to cross-entropy loss?
Written & reviewed by the ML Visualization team · Last updated .