Focal Loss论文阅读笔记
版權(quán)聲明:本文為博主原創(chuàng)文章,未經(jīng)博主允許不得轉(zhuǎn)載。?? ?https://blog.csdn.net/qq_34564947/article/details/77200104
Focal Loss for Dense Object Detection
引入問題
目前目標(biāo)檢測的框架一般分為兩種:基于候選區(qū)域的two-stage的檢測框架(比如fast r-cnn系列),基于回歸的one-stage的檢測框架(yolo,ssd這種),two-stage的效果好,one-stage的快但是效果差一些。
本文作者希望弄明白為什么one-stage的檢測器準(zhǔn)確率不高的問題,作者給出的解釋是由于前正負樣本不均衡的問題(感覺理解成簡單-難分樣本不均衡比較好)
We discover that the extreme foreground-background class imbalance encountered during training of dense detectors is the central cause
樣本的類別不均衡會帶來什么問題
(1) training is inefficient as most locations are easy negatives that contribute no useful learning signal;?
(2) en masse,the easy negatives can overwhelm training and lead to degenerate models.
由于大多數(shù)都是簡單易分的負樣本(屬于背景的樣本),使得訓(xùn)練過程不能充分學(xué)習(xí)到屬于那些有類別樣本的信息;其次簡單易分的負樣本太多,可能掩蓋了其他有類別樣本的作用(這些簡單易分的負樣本仍產(chǎn)生一定幅度的loss,見下圖藍色曲線,數(shù)量多會對loss起主要貢獻作用,因此就主導(dǎo)了梯度的更新方向,掩蓋了重要的信息)
對于two-stage的檢測器而言,通常分為兩個步驟,第一個步驟即產(chǎn)生合適的候選區(qū)域,而這些候選區(qū)域經(jīng)過篩選,一般控制一個比例(比如正負樣本1:3),另外還通過hard negatiive mining(OHEM),控制難分樣本占據(jù)的比例,以解決樣本類別不均衡的問題。?
對于one-stage的檢測器來說,盡管可以采用同樣的策略(OHEM)控制正負樣本,但是還是有缺陷,文中的說法是:
Like the focal loss,OHEM puts more emphasis on misclassified examples, but unlike FL, OHEM completely discards easy examples?
While similar sampling heuristics may also be applied, they are inefficient as the training procedure is still dominated by easily classified background examples
OHEM這篇論文還沒看,所以不是特別理解。?
所以作者提出Focal loss,基于損失函數(shù)做出改進。
解決方案:Focal Loss
作者提出一種新的損失函數(shù),思路是希望那些hard examples對損失的貢獻變大,使網(wǎng)絡(luò)更傾向于從這些樣本上學(xué)習(xí)。
作者以二分類為例進行說明:?
首先是我們常使用的交叉熵損失函數(shù):?
要對類別不均衡問題對loss的貢獻進行一個控制,即加上一個控制權(quán)重即可,最初作者的想法即如下這樣,對于屬于少數(shù)類別的樣本,增大α即可?
但這樣有一個問題,它僅僅解決了正負樣本之間的平衡問題,并沒有區(qū)分易分/難分樣本,按作者的話說:
Easily classified negatives comprise the majority of the loss and dominate the gradient.?
While α balances the importance of positive/negative examples, it does not differentiate between easy/hard examples.
因此后面有了如下的形式:?
顯然,樣本越易分,pt越大,則貢獻的loss就越小,相對來說,難分樣本所占的比重就會變大,見如下原文中的一個例子:
For instance, with γ = 2, an example classified with pt = 0:9 would have 100× lower loss compared with CE and with pt ≈ 0:968 it would have 1000× lower loss. This in turn increases the importance of correcting misclassified examples (whose loss is scaled down by at most 4× for pt ≤ .5 and γ = 2)
因此,通過這個公式區(qū)分了易分/難分樣本,在實際中,作者采用如下公式,即綜合了上述兩個公式的形式:?
這里的兩個參數(shù)α和γ協(xié)調(diào)來控制,本文作者采用α=0.25,γ=2效果最好
另外:作者提到了類別不均衡和模型的初始化問題,即數(shù)量很多的某一類樣本會起主導(dǎo)作用,在開始訓(xùn)練的時候可能導(dǎo)致不穩(wěn)定,作者提出的解決方法是:
To counter this, we introduce the concept of a ‘prior’ for the value of p estimated by the model for the rare class (foreground) at the start of training.?
For the final conv?
layer of the classification subnet, we set the bias initialization to b = ? log((1 ? π)=π), where π specifies that at the start of training every anchor should be labeled as foreground with confidence of ~π.
π采用的是0.01,不太清楚為什么要這么做,留個問號,help
實驗框架
本文作者實驗時設(shè)計了一個叫RetinaNet的one-satge的網(wǎng)絡(luò)結(jié)構(gòu),以證明通過Focal Loss,one-stage的網(wǎng)絡(luò)結(jié)構(gòu)也能夠達到two-stage的準(zhǔn)確率,實際上采用的是基于resnet的FPN(特征金字塔網(wǎng)絡(luò),可自行查閱論文論文鏈接),網(wǎng)絡(luò)框架如下:?
實驗結(jié)果
最好能在coco test-dev上達到 39.1AP,5Fps?
由上圖可見,準(zhǔn)確率高于two-stage的方法,并且速度可以得到保持
上圖是各指標(biāo)的對比實驗結(jié)果,具體可查看論文?
上圖表明了該loss對負樣本的影響很明顯,使得負樣本的loss集中在少數(shù)的樣本上:
As can be seen, FL can effectively discount the effect of easy negatives, focusing all attention on the hard negative examples.
另外Focal loss的形式并不一定要是公式那樣的形式,只要能夠發(fā)揮相同的作用即可,作者有實驗證明,具體可查閱論文。
結(jié)論
本文從loss的角度闡述了one-stage檢測器準(zhǔn)確率低的問題,并給出了解決方案,很精彩。
參考
博客:參考博客?
論文:論文原文
---------------------?
作者:Arch學(xué)灰?
來源:CSDN?
原文:https://blog.csdn.net/qq_34564947/article/details/77200104?
版權(quán)聲明:本文為博主原創(chuàng)文章,轉(zhuǎn)載請附上博文鏈接!
總結(jié)
以上是生活随笔為你收集整理的Focal Loss论文阅读笔记的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: Light-Head R-CNN相关资料
- 下一篇: 搭建及训练py-R-FCN遇到的问题