t = 1 时变量 y(水平方向)的铰链损失(蓝色,垂直方向)与0/1损失(垂直方向;绿色为 y < 0 ,即分类错误)。注意铰接损失在 abs(y) < 1 时也会给出惩罚,对应于支持向量机中间隔的概念。
在机器学习中,铰链损失是一个用于训练分类器的损失函数。铰链损失被用于“最大间格分类”,因此非常适合用于支持向量机 (SVM)。[1]
对于一个预期输出
,分类结果
的铰链损失定义为
![{\displaystyle \ell (y)=\max(0,1-t\cdot y)}](https://wikimedia.org/api/rest_v1/media/math/render/svg/a5f42d461f1a28b27438e8f1641e042ff2e40102)
特别注意:以上式子的
应该使用分类器的“原始输出”,而非预测标签。例如,在线性支持向量机当中,
,其中
是超平面参数,
是输入资料点。
当
和
同号(意即分类器的输出
是正确的分类),且
时,铰链损失
。但是,当它们异号(意即分类器的输出
是错误的分类)时,
随
线性增长。套用相似的想法,如果
,即使
和
同号(意即分类器的分类正确,但是间隔不足),此时仍然会有损失。
扩展
二元支持向量机经常通过一对多(winner-takes-all strategy,WTA SVM)或一对一(max-wins voting,MWV SVM)策略来扩展为多元分类,[2]
铰接损失也可以做出类似的扩展,已有数个不同的多元分类铰接损失的变体被提出。[3] 例如,Crammer 和 Singer [4]
将一个多元线性分类的铰链损失定义为[5]
![{\displaystyle \ell (y)=\max(0,1+\max _{y\neq t}\mathbf {w} _{y}\mathbf {x} -\mathbf {w} _{t}\mathbf {x} )}](https://wikimedia.org/api/rest_v1/media/math/render/svg/81d2483d6d6511dc0fce3afb627f0c58c84a205d)
其中
为目的标签,
和
该模型的参数。
Weston 和 Watkins 提出了一个类似的定义,但使用求和代替了最大值:[6][3]
![{\displaystyle \ell (y)=\sum _{y\neq t}\max(0,1+\mathbf {w} _{y}\mathbf {x} -\mathbf {w} _{t}\mathbf {x} )}](https://wikimedia.org/api/rest_v1/media/math/render/svg/f4ecfffb75eba0c8368d3542b91778009fb2513c)
在结构预测中,铰接损失可以进一步扩展到结构化输出空间。支持间隔调整的结构化支持向量机 可以使用如下所示的铰链损失变体,其中 w 表示SVM的参数, y 为SVM的预测结果,φ 为联合特征函数,Δ 为汉明损失:
![{\displaystyle {\begin{aligned}\ell (\mathbf {y} )&=\max(0,\Delta (\mathbf {y} ,\mathbf {t} )+\langle \mathbf {w} ,\phi (\mathbf {x} ,\mathbf {y} )\rangle -\langle \mathbf {w} ,\phi (\mathbf {x} ,\mathbf {t} )\rangle )\\&=\max(0,\max _{y\in {\mathcal {Y}}}\left(\Delta (\mathbf {y} ,\mathbf {t} )+\langle \mathbf {w} ,\phi (\mathbf {x} ,\mathbf {y} )\rangle \right)-\langle \mathbf {w} ,\phi (\mathbf {x} ,\mathbf {t} )\rangle )\end{aligned}}}](https://wikimedia.org/api/rest_v1/media/math/render/svg/3d33faf87d61823bedfb567943aa105462bf1743)
优化算法
铰链损失是一种凸函数,因此许多机器学习中常用的凸优化器均可用于优化铰链损失。 它不是可微函数,但拥有一个关于线性 SVM 模型参数 w 的次导数
![{\displaystyle {\frac {\partial \ell }{\partial w_{i}}}={\begin{cases}-t\cdot x_{i}&{\text{if }}t\cdot y<1\\0&{\text{otherwise}}\end{cases}}}](https://wikimedia.org/api/rest_v1/media/math/render/svg/6f0568f082317ebfd07b2e701f93306d05034ea5)
其评分函数为
三个铰链损失的变体 z = ty:“普通变体”(蓝色),平方变体(绿色),以及 Rennie 和 Srebro 提出的分段平滑变体(红色)。
然而,由于铰接损失在
处不可导, Zhang 建议在优化时可使用平滑的变体建议,[7] 如Rennie 和 Srebro 提出的分段平滑[8]
![{\displaystyle \ell (y)={\begin{cases}{\frac {1}{2}}-ty&{\text{if}}~~ty\leq 0,\\{\frac {1}{2}}(1-ty)^{2}&{\text{if}}~~0<ty\leq 1,\\0&{\text{if}}~~1\leq ty\end{cases}}}](https://wikimedia.org/api/rest_v1/media/math/render/svg/b6c47c68539b8a5f00ee00bab28ac45742180421)
或平方平滑。
![{\displaystyle \ell _{\gamma }(y)={\begin{cases}{\frac {1}{2\gamma }}\max(0,1-ty)^{2}&{\text{if}}~~ty\geq 1-\gamma \\1-{\frac {\gamma }{2}}-ty&{\text{otherwise}}\end{cases}}}](https://wikimedia.org/api/rest_v1/media/math/render/svg/a28b695abbbc9089281a5f2705a0194044e31e06)
Modified Huber loss
是
时损失函数的特例,此时
中。
参考文献
- ^ Rosasco, L.; De Vito, E. D.; Caponnetto, A.; Piana, M.; Verri, A. Are Loss Functions All the Same? (PDF). Neural Computation. 2004, 16 (5): 1063–1076 [2019-06-04]. PMID 15070510. doi:10.1162/089976604773135104. (原始内容存档 (PDF)于2020-01-11).
- ^ Duan, K. B.; Keerthi, S. S. Which Is the Best Multiclass SVM Method? An Empirical Study (PDF). Multiple Classifier Systems. LNCS 3541. 2005: 278–285 [2019-06-04]. ISBN 978-3-540-26306-7. doi:10.1007/11494683_28. (原始内容存档 (PDF)于2017-08-08).
- ^ 3.0 3.1 Doğan, Ürün; Glasmachers, Tobias; Igel, Christian. A Unified View on Multi-class Support Vector Classification (PDF). Journal of Machine Learning Research. 2016, 17: 1–32 [2019-06-04]. (原始内容存档 (PDF)于2018-05-05). 引用错误:带有name属性“unifiedview”的
<ref>
标签用不同内容定义了多次
- ^ Crammer, Koby; Singer, Yoram. On the algorithmic implementation of multiclass kernel-based vector machines (PDF). Journal of Machine Learning Research. 2001, 2: 265–292 [2019-06-04]. (原始内容存档 (PDF)于2015-08-29).
- ^ Moore, Robert C.; DeNero, John. L1 and L2 regularization for multiclass hinge loss models (PDF). Proc. Symp. on Machine Learning in Speech and Language Processing. 2011 [2019-06-04]. (原始内容存档 (PDF)于2017-08-28).
- ^ Weston, Jason; Watkins, Chris. Support Vector Machines for Multi-Class Pattern Recognition (PDF). European Symposium on Artificial Neural Networks. 1999 [2019-06-04]. (原始内容存档 (PDF)于2018-05-05).
- ^ Zhang, Tong. Solving large scale linear prediction problems using stochastic gradient descent algorithms (PDF). ICML. 2004 [2019-06-04]. (原始内容存档 (PDF)于2019-06-04).
- ^ Rennie, Jason D. M.; Srebro, Nathan. Loss Functions for Preference Levels: Regression with Discrete Ordered Labels (PDF). Proc. IJCAI Multidisciplinary Workshop on Advances in Preference Handling. 2005 [2019-06-04]. (原始内容存档 (PDF)于2015-11-06).