Softmax · 把分数挤进同一个杯子Softmax · Squeeze Scores into One Shared Cup
arbitrary logits → exponentiate → divide by total → Σp = 1
Softmax 把一组任意分数转成总和为 1 的概率分布。每项变大都会挤占其他项的份额,因此候选之间始终在竞争。Softmax turns arbitrary scores into probabilities that sum to one. Raising one item takes share from the others, so candidates always compete.
01 · 先想一块固定大小的蛋糕01 · Picture one fixed-size cake
三个人的胃口分数想写多大都行,怎样把它们变成恰好分完一整块蛋糕的份额?Three appetite scores can be any size. How do you turn them into shares that divide exactly one whole cake?
Σ1
02归一化压舱:分数柱原地变成概率柱Normalization Press: Scores Become Probability Bars
分数 → 概率 · 2/3score → probability · 2/3
当前视图Current view
z
logits
柱子总和Bar total
6.5
任意arbitrary
头部份额Top share
—
先执行 softmaxapply softmax first
03一次 softmax 的 4 个动作Four Moves Inside Softmax
Σpi = 1
PART 01
减去最大值Subtract the maximum
数值更稳定,同时保留所有分数差。Keeps the calculation stable without changing score gaps.
PART 02
Exponentiate
用 ez 把任意实数变成正数。Uses ez to turn every real score positive.
PART 03
求总量Add the total
把所有正数份额加成共同分母。Adds all positive weights into one shared denominator.
PART 04
按总量分杯Divide by the total
每项除以总量,最后严格加到 1。Divides each item by the total so the result sums exactly to one.
04最小公式:每一项都在同一个分母里竞争Minimal Formula: Every Item Competes in One Denominator
softmax(z)
pi = ezi / Σjezj
上方调高一个 zi,分子变大,同时总分母也变大,所以其他 pj 会被挤小。Raise one zi above: its numerator grows, and so does the shared denominator, squeezing every other pj.
一项 +1One score +1ez 放大ez grows
共同分母变大Shared total grows全体重新分配all shares reallocate
总和仍为 1Total stays at one竞争不会溢出competition cannot overflow
05边界实验:把最高分拉到 12Boundary Test: Push the Top Score to 12
主动制造失败Create a failure
显示成 0.0% 不等于数学上为零Displaying 0.0% does not mean mathematical zero
制造极端分数差,尾部概率会小到显示精度以下,但 softmax 仍给每项正概率。Create an extreme score gap. Tail probabilities fall below display precision, but softmax still assigns every item a positive probability.
尚未执行。注意 0.0% 只是四舍五入。Not run yet. Remember that 0.0% may only be rounding.
✗ softmax 只把每项除以 logits 总和。Softmax simply divides by the sum of logits. → ✓ 先取指数,再除以指数和。It exponentiates first, then divides by the exponential total.
✗ 调高一项只影响它自己。Raising one item affects only itself. → ✓ 共同分母让所有候选一起变化。The shared denominator moves every candidate.
✗ 显示 100% 就是绝对确定。A displayed 100% means absolute certainty. → ✓ 先检查显示精度和尾部非零值。Check display precision and nonzero tail values first.
06 · 一句话带走06 · One line to keep
Softmax 把任意 logits 挤成总和为 1 的概率:调高一根柱会让它抢到更多份额,也会同时挤小所有其他候选。Softmax squeezes arbitrary logits into probabilities summing to one: raise one bar and it gains share while every competing candidate shrinks.