What softmax calculates
For K mutually exclusive classes and finite dimensionless scores zi, exponentials are jointly normalized. The function alone learns no parameters. This calculator handles exactly three scores between −1000 and 1000, returning proportions and their directly computed logarithms.[1][5]
Definition and normalization[1]
Outputs form a model distribution. A sum of one proves neither correct labels nor calibration. Binary logistic regression is a related but distinct starting point.[2]
Related starting point: logistic regression.
Shared denominator and stable calculation
Normalization follows from the same positive denominator.[1]
The common factor e^c cancels. Choosing m=max z makes every exponent nonpositive. The largest exponential is 1, and with three classes their sum lies between 1 and 3. This prevents exponential overflow without eliminating every underflow of tiny proportions.[3]
Maximum shift for exponentials[3]
For true class y, one-hot loss is −ln py=LSE(z)−zy. Library calls must distinguish proportions from logits: some loss functions explicitly expect unnormalized logits.[2][6]
Classes are discrete categories
Two fully worked examples
A three-class ratio
- Given
- Three dimensionless scores z=(0,ln 2,ln 3).
- Find
- Calculate all class proportions and check their sum.
First obtain exponentials from the symbolic scores.
Divide every value by the same total, without early rounding.
Check both the ratio and normalization.
Result: p=(1/6,1/3,1/2)≈(0.166667,0.333333,0.5). Class 3 has the largest proportion.
Check: Every value is strictly between 0 and 1. Their ratio is 1:2:3 and the exact sum is 1.
Normalize large scores without overflow
- Given
- z=(999,999,999+ln 2). Direct exp(999) exceeds ordinary binary64 range.
- Find
- Compute proportions and log proportions using a maximum shift.
Subtract the maximum from every score, making the largest exponent 0.
Shifted exponentials are 1/2,1/2,1, totaling 2.
Compute log proportions directly from shifted scores rather than logging tiny computed proportions.
Logsumexp retains the common absolute shift; only softmax itself is shift-invariant.
Result: p=(0.25,0.25,0.5), log p≈(−1.386294,−1.386294,−0.693147).
Check: Subtracting 999 gives (0,0,ln 2) with identical proportions. exp(log pi) reproduces the three values.
Recall the method later with the formula’s flashcards.
10 flashcards · English materials
Already have an account? Sign in for flashcardsAvailable from Essential. A ready-made formula set, no AI credits required. Article exercises are not all included.
Five exercises with solutions
Calculate · Foundation
Calculate softmax for (ln 2,0,0).
Show hint
Exponentiate symbolically first.
Learning goal: Convert scores into proportions using a shared normalizer.
Rearrange · Application
Two class proportions satisfy p2/p1=4. What follows for z2−z1? Are both scores determined?
Show hint
First take the ratio of the softmax fractions.
Learning goal: Identify relative scores and recognize common-shift freedom.
Interpret · Foundation
All three scores equal −2. What proportions result, and does that establish a good prediction?
Show hint
All exponentials are equal.
Learning goal: Distinguish equal scores from model quality.
Error analysis · Application
A solution independently applies sigmoid to three zeros and reports (1/2,1/2,1/2) as softmax. Locate the error.
Show hint
Check the sum and shared denominator.
Learning goal: Separate multiclass normalization from independent binary outputs.
Transfer · Application
The true class is 3. Compare one-hot cross-entropy loss for scores (0,0,0) and (0,0,ln 2).
Show hint
Use L=−log p3=logsumexp(z)−z3.
Learning goal: Connect softmax output to an explicit class loss.
Check your understanding with the formula’s reference test.
7 test questions · English materials
Already have an account? Sign in for the testAvailable from Essential. A ready-made formula set, no AI credits required. Article exercises are not all included.
Retained extension: interpreting underflow
Distinguish mathematical positivity from numerical representation limits.[1][2]
For scores (−1000,0,1000), p1 is stored as 0. Does this prove the class is mathematically impossible? How can its finite log proportion be obtained?[1][2]
Use a maximum shift and calculate log p before exp.[1][2]
No. Mathematically p1=exp(−2000)/(1+exp(−1000)+exp(−2000))>0. Floating-point 0 is underflow. Directly log p1=−2000−log(1+exp(−1000)+exp(−2000)), numerically about −2000. Taking log of stored 0 would yield −∞ and lose this information.[1][2]
Limits and next steps
A requested proportion that numerically underflows to zero for finite scores is rejected with a range issue. Select its direct log proportion, which remains finite in this bounded model. Masks using −∞, batch axes, temperature models and training are outside this three-score calculator.[3][5]
Cross-entropy compares target and prediction distributions. Shannon entropy instead describes uncertainty in one distribution.[2]
Sources for this explanation
Quanta · Updated November 21, 2026
- SciPy: scipy.special.softmax — Definition, axis, Notes
- Dive into Deep Learning:4.1.1.2 The Softmax;4.1.2.2 Softmax and Cross-Entropy Loss
- Blanchard, Higham and Higham: Accurately Computing the Log-Sum-Exp and Softmax Functions,§1 and§4
- SciPy: scipy.special.logsumexp — Definition and Notes
- PyTorch: torch.nn.Softmax — Definition, dim and Note
- PyTorch: torch.nn.CrossEntropyLoss — Unnormalized logits and class-index targets
Editorial responsibility: Quanta Study editorial team
Review scope
This explanation, 2 worked examples and 5 exercises are available in German and English. Structure, source references and mathematical notation undergo automated checks. Calculations, model assumptions and both language versions receive a separate AI review.
An independent, named human subject review has not yet been documented. Our exercise numbers are worked examples, rather than measurements published by the cited sources.
Editorial responsibility, sources and methodsChange history
- Aligned five material exercises with the learning guide; retained the sixth underflow question with learning goal, hint and complete solution as an extension.
- Created a DE/EN draft with maximum-shift reasoning, two original examples, six solved exercises and a discrete class graphic.
Cite this reference page
Quanta. Softmax function. Updated November 21, 2026. https://quanta-study.de/en/formula-sheet/softmax-funktion
When citing a specific scientific statement, also cite the specialist source linked to that statement.