Softmax 概率

🎲 Softmax Probability Converter

Convert a set of logits into a probability distribution that sums to 1, the standard last step of a multi-class model.

📐 计算公式 / 原理
Softmax 概率 P_i = e^{z_i} ÷ Σ(e^{z_j}) ×100%(z 为各分类得分)。校验:至少输入一个有效实数。判据:将任意实数得分归一化为 0–100% 的概率分布,最大得分对应类别概率最高;常用于多分类输出层。
Softmax 把 logits 变成和为 1 的概率分布,指数放大差距使最大值更突出。实现上通常先减去 max(z) 再取指数以避免上溢;输出概率并不等于模型置信度,未经校准的模型常过度自信。

📐 计算公式与说明

Softmax 概率 P_i = e^{z_i} ÷ Σ(e^{z_j}) ×100%(z 为各分类得分)。校验:至少输入一个有效实数。判据:将任意实数得分归一化为 0–100% 的概率分布,最大得分对应类别概率最高;常用于多分类输出层。

Softmax 输出概率之和为 1。

📚 深度解析:Softmax 概率

💡 常见使用场景

概率归一化
logits=[2,1,0.1],减最大值 2 得 [0,−1,−1.9],exp=[1,0.368,0.149],Σ=1.517 → 概率=[0.659,0.243,0.098],和为 1。

❓ 常见问题(FAQ)

为什么要减去最大值?
exp 大数会溢出。softmax 具平移不变性,先减最大值不改变结果却把所有指数压到 ≤0,避免 exp 上溢、数值稳定。
softmax 和 sigmoid 在二分类下等价吗?
等价。二分类 softmax 两维概率互为补数,与对单 logit 用 sigmoid 一致;多分类才必须用 softmax 归一化。

Formula & Standard References

Item Formula / Note Source / Standard
Function definition softmax exponentiates each logit then divides by the sum of all exponentials Bridle 1990, Neural Computation
Probability property each component is nonnegative and the total sums to one Bishop, Pattern Recognition and Machine Learning
Shift invariance adding a constant to all logits leaves outputs unchanged so the maximum is subtracted for stability Goodfellow et al., Deep Learning