Formula Bro

Math and physics formulas, explained like you are new.


Softmax

In one sentence: Softmax takes a list of scores, any numbers at all, and turns them into percentages that add up to 100%.

softmax⁡(z)i=ezi∑j=1Kezj\operatorname{softmax}(z)_i = \frac{e^{z_i}}{\sum_{j=1}^{K} e^{z_j}}

Read it out loud: “The softmax of score number i equals e to the power of that score, divided by the sum of e to the power of every score.”

What each symbol means

SymbolMeaning

zz

The list of raw scores (also called logits). A model produces one score per possible answer. They can be any real numbers, even negative.

ziz_i

One score from the list, the one for answer number ii.

KK

How many scores are in the list, so how many possible answers there are.

ee

Euler’s number, about 2.718. Raising ee to a power makes every number positive.

∑j=1K\sum_{j=1}^{K}

“Add up for every jj from 1 to KK”: go through the whole list and total it.

softmax⁡(z)i\operatorname{softmax}(z)_i

The result for answer ii: a number between 0 and 1, read as the probability of that answer.

What the formula is doing

A classifier, for example a model that looks at a photo and decides between cat, dog and bird, first produces one raw score per answer. The scores are not probabilities yet: they can be negative, they can be huge, and they do not add up to anything in particular.

Softmax fixes that in two moves. First it raises ee to the power of every score. That turns every number positive, and it stretches the gaps: a score that is a bit bigger becomes a lot bigger after eze^{z}.

Second, it divides each of those positive numbers by their total. Dividing by the total is what makes the results add up to exactly 1, the same way you turn counts into percentages by dividing by the overall count.

The order never changes: the biggest score always gets the biggest probability. Only the sizes change. Adding the same number to every score changes nothing at all, because that factor appears on the top and the bottom and cancels out.

An everyday picture

Think of a talent show where judges hand out raw points. Softmax is the host who converts those points into each act’s share of the audience vote. Everybody gets a slice, the slices fill the whole pie, and the act with the most points gets the biggest slice, a little bigger than the raw points alone would suggest.

Worked example: A photo classifier choosing between cat, dog and bird

The model gives the scores z=(2.0,1.0,0.1)z = (2.0,\ 1.0,\ 0.1) for cat, dog and bird.

  1. Raise ee to each score: e2.0≈7.389e^{2.0} \approx 7.389, e1.0≈2.718e^{1.0} \approx 2.718, e0.1≈1.105e^{0.1} \approx 1.105.
  2. Add them up: 7.389+2.718+1.105=11.2137.389 + 2.718 + 1.105 = 11.213.
  3. Divide each one by the total: 7.38911.213≈0.659,2.71811.213≈0.242,1.10511.213≈0.099\frac{7.389}{11.213} \approx 0.659, \quad \frac{2.718}{11.213} \approx 0.242, \quad \frac{1.105}{11.213} \approx 0.099
  4. Check: 0.659+0.242+0.099=1.0000.659 + 0.242 + 0.099 = 1.000.

Answer: The model says cat with about 65.9% confidence, dog 24.2% and bird 9.9%. The cat score was only twice the dog score, but its probability is almost three times bigger: that is the stretching effect of eze^{z}.

The numbers in this example are recomputed by script every time the site is built.

Common mistakes

Where you will meet it

Questions people ask

Why use e and not 2 or 10?

Any base above 1 would turn scores into positive numbers and keep their order. Base ee is used because its derivative is itself, which makes the math of training (gradients) short and clean.

What is the difference between softmax and sigmoid?

Sigmoid squeezes one score into a number between 0 and 1. Softmax handles a whole list and makes the results add up to 1. With exactly two answers, softmax gives the same result as a sigmoid of the difference between the two scores.

What is temperature in softmax?

Dividing every score by a number TT before softmax. TT above 1 flattens the percentages (more random choices), TT below 1 sharpens them toward the top answer. Chatbots expose this as the temperature setting.

Why is it called softmax?

A hard max would put 100% on the biggest score and 0% on the rest. Softmax does a soft version of that: the biggest score wins most, but every answer keeps a share.

Sources

  1. Softmax function, Wikipedia
  2. Goodfellow, Bengio and Courville, Deep Learning, chapter 6.2.2.3 (Softmax units)

| All AI & ML formulas |

Published 2026-10-22. Plain-text copy for AI agents and readers: ai-ml/softmax.md.