原论文:《T.-Y. Lin, P. Goyal, R. Girshick, K. He, and P. Doll´ar. Focal loss for dense object detection[C]. In ICCV, 2017.》

  • 特意设计了专门的目标检测网络 RetinaNet 进行实验验证。
  • 论文中经过实验得到 RetinaNet 中损失函数超参数的 一对最佳值γ=2\gamma=2α=0.25\alpha=0.25

目的:解决目标检测模型中存在的正负样本不平衡问题
方法:通过损失函数,抑制分类正确的样本在权重更新中的作用。样本被正确分类的得分越高,其作用越低

比如:一个得分为0.99的正样本比得分0.70的正样本作用小;一个得分为0.01的负样本比一个得分为0.40的负样本作用小。

1. Focal Loss 损失函数

首先介绍 交叉熵损失函数(Cross Entropy)以及 平衡交叉熵损失函数(Balanced Cross Entropy),这两个函数对提出 Focal Loss 损失函数 有启发作用。

yy 为正负类别,1 为正 0 为负;pp 是模型对正类别的预测值,1p1-p 是对负类别的预测值。

  • 交叉熵损失函数
    CE(p,y)={log(p)           if y=1log(1p)    if y=0CE(p,y)=\begin{cases} &-log(p)\ \ \ \ \ \ \ \ \ \ \ if\ y=1 \\ &-log(1-p)\ \ \ \ if\ y=0 \\ \end{cases}

    pt={p         if y=11p  if y=0p_t=\begin{cases} &p\ \ \ \ \ \ \ \ \ if\ y=1\\ &1-p\ \ if\ y=0\\ \end{cases}

    CE(p,y)=CE(pt)=log(pt)CE(p,y)=CE(p_t)=-log(p_t)
  • 平衡交叉熵损失函数
    CE(pt)=αtlog(pt)CE(p_t)=-\alpha_t log(p_t)
    其中,α[0,1]\alpha\in [0,1],且
    αt={α         if y=11α  if y=0\alpha_t=\begin{cases} &\alpha\ \ \ \ \ \ \ \ \ if\ y=1\\ &1-\alpha\ \ if\ y=0\\ \end{cases}

1.1 Focal Loss 损失函数

FL(pt)=(1pt)γlog(pt)FL(p_t)=-(1-p_t)^\gamma log(p_t)
γ0\gamma\ge 0 是超参数,被称为可调焦点参数(Tunable Focusing Parameter),下面是不同值控制下的损失函数曲线。论文的实验中,γ=2\gamma=2 的效果最好。
Focal Loss 论文学习笔记

1.2 基于 α\alpha 的 Focal Loss 损失函数

这个是实际使用的损失函数。
FL(pt)=αt(1pt)γlog(pt)FL(p_t)=-\alpha_t (1-p_t)^\gamma log(p_t)

2. RetinaNet 网络

结构图:
Focal Loss 论文学习笔记
不再详细介绍该网络。

最后是实验数据:

Focal Loss 论文学习笔记
Focal Loss 论文学习笔记

相关文章: