Backto ML Index
Loss function 损失函数 | description 描述 | Scenes 使用问题 |
---|---|---|
MAE | Mean Absolute Error | Regression |
MSE | Mean Squared Error | Regression |
Entropy Loss | classification | |
Hinge Loss | classification |
Cross Entropy Loss
交叉熵损失函数,完整形式为 . 当真实 label 的值 的情况下,前半部分消失,当 的情况下,后半部分消失。
Cross Entropy Loss
有两个特性:
- 非负性。我们的目标是最小化 L, 也就是逼近 0
- 当网络输出 与 事实label 很接近的时候,即准确性很高的时候,L 的值都接近 0. 非常理想的情况。
这两个特性也是我们设计 Cross Entropy Loss
的初衷。
再看BP 中的导数计算,已知
对于单个神经元而言,
(TODO: 待补充,with Andrew Ng)
Hinge Loss
hinge loss 常用于最大间隔分类(maximum-margin classification),最常用的是SVM。
基本思路是 :在一定的安全间隔内(通常是 1),正确类别的分数应高于所有错误类别的分数之和。
Hinge Loss不可微,但它是一个凸函数,因此可以轻而易举地使用机器学习领域中常用的凸优化器。
举例:
以下是分类器在三个样本(Image #1,#2, #3)上对于三个类别(Dog/Cat/Horse)预测的结果,哪个好,哪个坏呢?通过 Hinge Loss 计算一哈
## 1st training example
max(0, (1.49) - (-0.39) + 1) + max(0, (4.21) - (-0.39) + 1)
max(0, 2.88) + max(0, 5.6)
2.88 + 5.6
8.48 (High loss as very wrong prediction)
## 2nd training example
max(0, (-4.61) - (3.28)+ 1) + max(0, (1.46) - (3.28)+ 1)
max(0, -6.89) + max(0, -0.82)
0 + 0
0 (Zero loss as correct prediction)
## 3rd training example
max(0, (1.03) - (-2.27)+ 1) + max(0, (-2.37) - (-2.27)+ 1)
max(0, 4.3) + max(0, 0.9)
4.3 + 0.9
5.2 (High loss as very wrong prediction)
Ref
- 机器学习中常用的损失函数你知多少?
- 交叉熵代价函数:说的很详细