为什么要在CNN中使用softmax

数据挖掘 机器学习 深度学习
2021-10-02 12:15:34

在最后一层,CNNs通常MLPs使用 softmax 层或具有 sigmoid 激活函数的单元进行多类分类。我在某个地方看到过,我不记得在哪里,每当类互斥时使用 softmax,并且包含 sigmoid 激活函数的单元的层用于具有多个标签的任务,例如识别图像中可能包含许多动物的动物. 我对吗?是否有任何其他扣除来区分它们?

我在这里这里看到过,但它们不包含我想要的东西。

1个回答

是的,你是对的。soft-max 层输出一个概率分布,即输出总和为 1 的值。sigmoid 函数输出边际概率,因此当类不互斥时可用于多类分类。此外,soft-max 层是最大输出层的软版本,因此它是可微的,并且对异常值也有弹性。sigmoid 的一个问题是当你达到饱和(值接近 1 或 0)时,梯度消失。这对优化速度不利,soft-max 没有这个问题另一种解释是 soft-max 作为 sigmoid 的泛化,实际上当有两个类时它们是相同的。

最后,当类互斥时,您应该使用 soft-max,而当类相互独立时,您应该使用 sigmoid。这可以总结在下表中:

Soft-Max                            |                 Sigmoid
-------------------------------------------------------------------------
Used for multi-classification       |  Used for binary classification in 
in logistic regression model.       |  logistic regression model.
-------------------------------------------------------------------------
The probabilities sum will be 1     | The probabilities sum need not be 1
-------------------------------------------------------------------------
Used in the different layers of     | Used as activation function while 
neural networks.                    | building neural networks
-------------------------------------------------------------------------
The high value will have the higher | The high value will have the high 
probability than other values.      | probability but not the higher

有关 soft-max 的更多信息,请查看以下链接1、23有关分步指南,包括 Python 中的用法,请参阅此参考4

有关 soft-max 与 sigmoid 的更多信息,请查看5、67

如果您想要更可靠的来源来了解为什么对互斥类使用 soft-max 回归,您可以查看此处此页面是斯坦福大学无监督特征学习和深度学习教程的一部分,它包含由 Andrew Ng 和其他人提供的材料。