x
表示模型的预测,y
表示真实值,z=x-y
表示预测值与真实值之间的差异
L1_loss
L L 1 = ∣ x − y ∣ = ∣ z ∣ L_{L1}=|x-y|=|z| LL1=∣x−y∣=∣z∣
L2_loss
L L 2 = 1 / 2 ( x − y ) 2 = 0.5 z 2 L_{L2}=1/2(x-y)^2=0.5z^2 LL2=1/2(x−y)2=0.5z2
分别对z求导
这样会导致一些问题
** L 1 l o s s : L_1 loss: L1loss:**在训练末期,z
很小的情况下,如果不调整learning rate
,这个导数的值会使损失函数在稳定值附近波动,难以继续收敛下去。
** L 2 l o s s : L_2loss: L2loss:**在训练初期,z
较大的情况下,会导致损失函数不稳定。
Smooth L1 loss
L s m o t t h L 1 = { 0.5 ( x − y ) 2 = 0.5 z 2 , i f ∣ x − y ∣ < 1 ∣ x − y ∣ − 0.5 = ∣ z ∣ − 0.5 , o t h e r w i s e L_{smotthL1}=\left\{ \begin{aligned}0.5(x-y)^2=0.5z^2,&& if|x-y|<1 \\ |x-y|-0.5=|z|-0.5, &&otherwise \end{aligned} \right. LsmotthL1={ 0.5(x−y)2=0.5z