论文笔记 Focal Loss for Dense Object Detection - ICCV 2017

2017 RetinaNet Focal Loss for Dense Object Detection

Tsung-Yi Lin, Priya Goyal, Ross Girshick, Kaiming He ICCV, 2017 PDF

1. Contributions

提出 Focal Loss 损失函数,缓解前景和背景样本极度不均衡的问题。The Focal Loss is designed to address the one-stage object detection scenario in which there is an extreme imbalance between foreground and background classes during training (e.g., 1:1000). ( 在早期 Faster R-CNN,SSD,yolo 中均采用Hard Negative Ming,即使用两个规则筛选正负样本。)

2. Experiment

One-stage network 性能第一次超越 two-stage network.

3. Focal loss

Figure 1
3.1. Cross Entropy Loss

C E ( p , y ) = C E ( p t ) = − log ⁡ ( p t ) , where p t = { p  if  y = 1 1 − p  otherwise  CE(p, y)= CE(p_t) = - \log(p_t),\quad \text{where}\quad p_{\mathrm{t}}= \begin{cases}p & \text { if } y=1 \\ 1-p & \text { otherwise }\end{cases} CE(p,y)=CE(pt)=log(pt),wherept={p1p if y=1 otherwise 

The CE loss can be seen as the blue (top) curve in Figure 1. One notable property of this loss, which can be easily seen in its plot, is that even examples that are easily classified ( p t ≫ . 5 p_t \gg .5 pt.5) incur a loss with non-trivial magnitude. When summed over a large number of easy examples, these small loss values can overwhelm the rare class.

3.2. α \alpha α-Balanced CE Loss

解决样本不平衡的常用方法是对前景引入权重因子 α \alpha α ,对背景引入权重因子 1 − α 1-\alpha 1α. 在实现中,权重因子 α \alpha α 可通过反类频率 r a t e = n b a c k g r o u n d _ p r o p o s a l n a l l _ p r o p o s a l \displaystyle rate=\frac{n_{background\_proposal}}{n_{all\_proposal}} rate=nall_proposalnbackground_proposal 设置,也可作为超参数通过交叉验证来设置。在论文中,作者没有使用反类频率设置权重因子 α \alpha α ,通过作者的实验, α = 0.75 \alpha=0.75 α=0.75 m AP m\text{AP} mAP 值最高,而对于网络训练而言,反类频率 r a t e \displaystyle rate rate 通常要达到 0.999 0.999 0.999 甚至更高。
C E ( p t ) = − α t log ⁡ ( p t ) CE(p_t) = -\alpha_t \log(p_t) CE(pt)=αtlog(pt)

This loss is a simple extension to CE. 作者将 α \alpha α-Balanced CE Loss 视为 Focal Loss 的实验基线。

3.3. Focal Loss

在训练过程中,易分类的负样本构成的总损失的大部分,主导了梯度。虽然 α \alpha α-Balanced CE Loss 平衡了正负样本的重要性,但是没有区分易分样本和难分样本的重要性。因此,作者在 CE Loss 中引入了一个调制因子 ( 1 − p t ) γ \left(1-p_{\mathrm{t}}\right)^{\gamma} (1pt)γ , Focal Loss 定义如下:
F L ( p t ) = − ( 1 − p t ) γ log ⁡ ( p t ) \mathrm{FL}\left(p_{\mathrm{t}}\right)=-\left(1-p_{\mathrm{t}}\right)^{\gamma} \log \left(p_{\mathrm{t}}\right) FL(pt)=(1pt)γlog(pt)
在 Figure 1 中,对于几个 γ ∈ [ 0 , 5 ] \gamma \in [0,5] γ[0,5] 的值,可视化 Focal Loss。注意到 Focal Loss 的两个属性。

  • 当一个样本被错误分类并且 p t p_t pt 很小时,调制因子接近1,损失不受影响。当 p t → 1 p_t \rightarrow 1 pt1 时,因子变为 0,并且分类良好的示例的损失被降低权重。
  • Focal Loss 参数 γ \gamma γ 平滑地调整了简单示例被降低权重的速率。当 γ = 0 \gamma=0 γ=0 时,FL 等价于 CE,并且随着 γ \gamma γ 的增加,调制因子的影响同样增加(在作者的实验中 γ = 2 \gamma=2 γ=2 效果最好)。

In practice we use an α \alpha α-balanced variant of the focal loss:
F L ( p t ) = − α t ( 1 − p t ) γ log ⁡ ( p t ) \mathrm{FL}\left(p_{\mathrm{t}}\right)=-\alpha_{\mathrm{t}}\left(1-p_{\mathrm{t}}\right)^{\gamma} \log \left(p_{\mathrm{t}}\right) FL(pt)=αt(1pt)γlog(pt)

4. 缺点

Focal Loss 易受噪声干扰。Focal Loss 是给难分样本更高的权重,难分样本是那些分类效果不好的点。当 Label 存在 Noise 时,Focal Loss 将会给难分样本错误标签的样本更高的权重。因此如果有比较多样本标签打错了,Focal Loss 效果就会不好。

5. YOLO v3 使用 Focal Loss 之后 mAP 反而掉了?

Focal Loss 的使用也是个大坑,关于该问题,感觉不同的人看法也不太一样。因为我也没有具体跑代码对比结果,所以我也不知道那种说法是正确的,这里附上这个问题的一个讨论为什么 YOLOv3 用了 Focal Loss 后 mAP 反而掉了?

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值