Visual walkthrough — Softmax for output layers
Before we begin, let us fix the vocabulary in the plainest possible words.
Our whole job: take a list of logits and turn it into a distribution. Let us call the logits (the letter is standard for "raw score"; the little number is which class). Throughout we use the running example
Step 1 — Draw the raw logits and see the problem
WHAT. Plot the three raw scores as bars on a number line.
WHY. Before fixing anything we must see what is broken. We want probabilities (positive, summing to ). Look at the bars and ask: do these numbers already behave like probabilities?
PICTURE. In the figure below, one bar dips below zero territory in spirit (logits are allowed to be negative — imagine were instead), and their total is , not .

Two problems, stated exactly:
- Problem A — sign: a logit is allowed to be negative, and a probability can never be negative.
- Problem B — total: the bars add to , not .
We will kill Problem A in Step 2 and Problem B in Step 4.
Step 2 — Why we bend the numbers through
WHAT. Pass every logit through the exponential function . Here is a fixed number, and means " raised to the power ."
WHY this tool and not another? We need a function that:
- turns any real input into a strictly positive output (kills Problem A — the sign problem), and
- preserves order — a bigger logit must stay bigger — so the winner stays the winner, and
- is smooth (differentiable) so we can later train by gradient descent.
The exponential does all three. Look at its graph: it lives entirely above the horizontal axis (always positive), it only ever climbs (order preserved), and it has no corners (smooth). A straight line fails #1 (goes negative); squaring fails #2 (it maps and to the same , scrambling order). Exponential is the natural pick.
PICTURE. The red curve is . Trace each logit up to the curve and across: negatives land just above zero, positives shoot up high.

Read that as: the input (a raw score) becomes (a positive weight). Every weight is now above zero — Problem A is gone.
Step 3 — See how amplifies the gap
WHAT. Compare the spacing of the bars before and after exponentiating.
WHY. Softmax is meant to be a soft argmax — a smooth way of "picking the biggest." For that we want the leader to pull ahead, not just barely lead. The exponential stretches gaps: equal steps in become multiplied steps in , because going from to multiplies the output by .
PICTURE. On the left, the raw gaps between are modest. On the right, towers over — the same gaps, exaggerated. The tallest bar (red) is now dramatically dominant.

The point: exponentiating gives a confident-but-still-smooth winner. Nobody is crushed to exactly zero (every ), so the loser still gets some share — crucial for learning.
Step 4 — Normalize: divide by the total
WHAT. Add up all the positive weights to get the normalizer , then divide each weight by .
WHY. After Step 2 we have positive weights, but they still total , not (Problem B). Dividing every weight by the same total shrinks the whole pile so it sums to exactly , without changing any ratios — the winner stays the winner, just measured as a slice of the whole.
PICTURE. Think of a pizza. The total weight is the whole pizza; each is one person's claim; is the slice they actually get. Slices are drawn as a pie — they must fill the circle exactly once.

Term by term: the top is how loud class shouted; the bottom is how loud everyone shouted together; the fraction is class 's share of the noise. For our numbers:
Check: . ✔️ Both problems solved. This fraction is the softmax.
Step 5 — Edge case: what if all logits are equal?
WHAT. Set for any constant (say all zero, or all ).
WHY. A good formula must behave sensibly at its degenerate inputs. If the network has no preference — all scores equal — the only fair answer is "totally unsure": every class equally likely. Does softmax do that?
PICTURE. Three equal bars in, three equal slices out — a perfectly even pie of each.

The cancels top and bottom, leaving (here ). So equal logits uniform distribution — exactly the "maximally uncertain" answer. This is the maximum-entropy behaviour: with no information distinguishing the classes, spread the probability evenly.
Step 6 — Edge case: giant logits and the shift trick
WHAT. Take huge logits . Computing directly overflows to infinity on a real computer.
WHY. The formula is mathematically fine but numerically dangerous. Rescue: subtract the largest logit from every logit before exponentiating. This works because softmax is shift-invariant — adding (or subtracting) the same constant to every logit changes nothing.
PICTURE. The three bars slide left together (a rigid shift). Their relative heights — and therefore the pie slices — are untouched. Only the danger of overflow moves away.

Why the shift is free, shown symbol by symbol:
The common factor pulls out of every term and cancels. Choose so the biggest shifted logit is and — the largest exponential is now a safe , never infinity. For our example, shifted logits are , giving — identical to the honest answer, but with no overflow.
Step 7 — The payoff: the gradient becomes
WHAT. Pair softmax with the cross-entropy loss , where is the target: for the true class, otherwise (a "one-hot" list). The gradient of the loss with respect to each logit collapses to a stunningly simple form.
WHY show it here. This is the reason softmax is the standard output layer. When you push the loss back through softmax and the log (see Backpropagation), all the messy pieces cancel and you are left with just prediction minus target.
PICTURE. For each class, an arrow shows which way its logit is pushed. True class: prediction below , so the arrow points up (raise this logit). Wrong classes: prediction above , arrows point down.

Take with true class so :
Read the signs: negative on the true class means "push its logit up"; positive on the wrong classes means "push them down." Exactly what learning should do — and there is no vanishing factor hiding in the softmax, because the and the perfectly cancel. That clean cancellation is the whole magic.
The one-picture summary

The entire pipeline in one flow: raw logits → exponentiate (positive + gap-amplified) → sum & divide (normalize to a pie of total ) → probabilities; and when trained, the backward signal is simply .
Recall Feynman: the whole walkthrough in plain words
Three friends shout how much they want their restaurant, on a "loudness" scale where the number can even go negative (grumbling). Step 1: those raw shouts are not fair shares yet — some are negative, and they don't add to a whole. Step 2–3: we run each shout through a machine () that (a) makes every number positive, so nobody has a negative claim, and (b) makes loud shouts much louder, so the leader clearly leads. Step 4: we bake one pizza whose size is the total of all shouts, and give each friend a slice equal to their share — now the slices fill exactly one pizza. Step 5: if everyone shouts the same, everyone gets an equal slice — perfect fairness under total ignorance. Step 6: if everyone shouts insanely loudly, we quietly subtract the loudest shout from all of them first — the slices don't change, but the computer stops choking. Step 7: to teach the network, we compare each predicted slice to the true answer ; the correction is just "slice minus truth," nudging the true class up and the rest down.
Active Recall
Two problems with raw logits?
Why exponential and not squaring?
Effect of dividing by the sum?
Softmax of all-equal logits?
Why is the max-subtraction free?
Gradient of softmax + cross-entropy?
Connections
- Parent: Softmax for output layers — the topic this page derives visually.
- Cross-Entropy Loss — the partner giving the clean gradient in Step 7.
- Sigmoid Activation — the 2-class / multi-label sibling.
- Logits and Log-Odds — the raw inputs of Step 1.
- Maximum Entropy Distributions — why the exponential form (Steps 2, 5).
- Backpropagation — where flows backward.
- Temperature Scaling — sharpening/softening the pie by scaling logits.