3.1.6 · D3Neural Network Fundamentals

Worked examples — Softmax for output layers

2,009 words9 min readBack to topic

This is the hands-on companion to Softmax for output layers. The parent note built the machine; here we run it on every kind of input it could ever see — big numbers, tiny numbers, negatives, ties, a single class, extreme gaps, a word problem, and an exam twist. Nothing here contradicts the parent; we only go deeper and cover the corners.

Before line one, a promise: you never need to have seen , a "distribution," or a "gradient" before. We rebuild each as it appears.


What we are actually computing (from zero)

Figure — Softmax for output layers

The scenario matrix

Every case softmax can be handed. Each later example is tagged with the cell it covers.

Cell Input class What is special Example
A All small positive logits ordinary, no tricks Ex 1
B Mixed signs (negative logits) must not give negative "probabilities" Ex 2
C Huge logits (overflow) needs the max-subtraction shift Ex 3
D An exact tie between logits equal slices — symmetry Ex 4
E Extreme gap (one logit dominates) limiting behaviour → argmax Ex 5
F Single class () degenerate: must output Ex 6
G Word problem (real-world) translate a story into logits Ex 7
H Exam twist: temperature scaling dividing by sharpens/softens Ex 8
I Gradient sanity () check the learning signal's sign Ex 9
Recall Why these cells and not others?

Cell E ::: The limiting case: as gaps grow, softmax approaches the hard argmax — proves it is a soft max. Cell F ::: The degenerate case : one class must always get probability ; a formula that failed here would be broken. Cell D ::: The symmetry case: identical inputs must give identical outputs, or the function is unfair.


Cell A — ordinary small logits


Cell B — negative logits (mixed signs)


Cell C — overflow, needs the shift


Cell D — an exact tie (symmetry)

Figure — Softmax for output layers

Cell E — extreme gap, the limiting case


Cell F — single class, the degenerate case


Cell G — a real-world word problem


Cell H — exam twist: temperature scaling


Cell I — gradient sanity



Active Recall

What does the exponential guarantee for negative logits?
The output is still positive (), so no probability is ever negative.
Is max-subtraction exact or an approximation?
Exact — shift-invariance means the ratio is unchanged.
Softmax of equal logits gives what?
The uniform distribution on every class.
Does softmax ever output exactly for one class (with )?
No — only in the limit; losers keep an infinitesimal positive slice.
Higher temperature does what to the distribution?
Softens it toward uniform.

Connections