回归任务:均方误差
M
S
E
=
∑
i
=
1
n
(
y
i
−
y
i
^
)
2
n
MSE = \frac{\sum^n_{i=1}{(y_i-\hat{y_i})^2}}{n}
MSE=n∑i=1n(yi−yi^)2
回归任务:L2范数
M
S
E
=
∑
i
=
1
n
(
y
i
−
y
i
^
)
2
MSE = \sqrt{\sum^n_{i=1}{(y_i-\hat{y_i})^2}}
MSE=i=1∑n(yi−yi^)2
分类任务:CrossEntropy交叉熵
分类任务:focal loss 这个是何凯明大佬的作品,是解决多分类任务中样本不平衡的现象的。公式中,预测结果为output,真实值为true,output是模型的直接输出打分情况,true是onehot编码:
L
f
o
c
a
l
l
o
s
s
(
o
u
t
p
u
t
,
t
r
u
e
)
=
−
1
n
∑
i
=
1
n
t
r
u
e
∗
θ
∗
(
1
−
s
o
f
t
m
a
x
(
o
u
t
p
u
t
)
)
γ
∗
l
o
g
(
s
o
f
t
m
a
x
(
o
u
t
p
u
t
)
)
L_{focal_loss}(output,true)=-\frac{1}{n}\sum_{i=1}^ntrue*\theta*(1-softmax(output))^{\gamma}*log(softmax(output))
Lfocalloss(output,true)=−n1i=1∑ntrue∗θ∗(1−softmax(output))γ∗log(softmax(output)) 论文中
θ
=
0.25
,
γ
=
2
\theta=0.25,\gamma=2
θ=0.25,γ=2