Maths for ML / Notation

softmax⁡(z)i=ezi∑jezj\operatorname{softmax}(\mathbf{z})_i = \frac{e^{z_i}}{\sum_j e^{z_j}}

softmax

FunctionsBeginner

Say it “softmax of z”

Turns a vector of any scores into positive numbers that sum to 1 — a probability distribution.

Example

softmax⁡([1,1])=[0.5,0.5]\operatorname{softmax}([1,1]) = [0.5, 0.5]

In code

np.exp(z) / np.exp(z).sum()
torch.softmax(z, dim=-1)

Where you’ll see it in ML

Classifier outputs, attention weights, next-token probabilities.

Don’t confuse it with

Lessons that use it

← All 94 symbols