sigmoid 和 softmax 的区别

Posted by:

|

On:

|

🔁 sigmoid vs softmax

特性sigmoidsoftmax
📌 定义σ(x)=11+e−x\sigma(x) = \frac{1}{1 + e^{-x}}σ(x)=1+e−x1​softmax(xi)=exi∑jexj\text{softmax}(x_i) = \frac{e^{x_i}}{\sum_j e^{x_j}}softmax(xi​)=∑j​exj​exi​​
📊 输出范围每个值在 [0,1][0, 1][0,1],互相 独立所有输出加起来为 1(形成 概率分布
🔢 输出总和不固定恒为 1
用在哪二分类或多标签(二分类)多分类(互斥)
🧠 用的损失函数BCEWithLogitsLoss(或 BCELoss + sigmoid)CrossEntropyLoss(自动带 softmax)
⚠️ 类别之间的关系无竞争,非互斥标签有竞争,互斥类别
📦 PyTorch 中是否需要显式调用?是的(除非用了 BCEWithLogitsLoss否,CrossEntropyLoss 自带 softmax