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)檢測(cè)的框架一般分為兩種:基于候選區(qū)域的two-stage的檢測(cè)框架(比如fast r-cnn系列),基于回歸的one-stage的檢測(cè)框架(yolo,ssd這種),two-stage的效果好,one-stage的快但是效果差一些。
本文作者希望弄明白為什么one-stage的檢測(cè)器準(zhǔn)確率不高的問題,作者給出的解釋是由于前正負(fù)樣本不均衡的問題(感覺理解成簡(jiǎn)單-難分樣本不均衡比較好)
We discover that the extreme foreground-background class imbalance encountered during training of dense detectors is the central cause
樣本的類別不均衡會(huì)帶來什么問題
(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ù)都是簡(jiǎn)單易分的負(fù)樣本(屬于背景的樣本),使得訓(xùn)練過程不能充分學(xué)習(xí)到屬于那些有類別樣本的信息;其次簡(jiǎn)單易分的負(fù)樣本太多,可能掩蓋了其他有類別樣本的作用(這些簡(jiǎn)單易分的負(fù)樣本仍產(chǎn)生一定幅度的loss,見下圖藍(lán)色曲線,數(shù)量多會(huì)對(duì)loss起主要貢獻(xiàn)作用,因此就主導(dǎo)了梯度的更新方向,掩蓋了重要的信息)
對(duì)于two-stage的檢測(cè)器而言,通常分為兩個(gè)步驟,第一個(gè)步驟即產(chǎn)生合適的候選區(qū)域,而這些候選區(qū)域經(jīng)過篩選,一般控制一個(gè)比例(比如正負(fù)樣本1:3),另外還通過hard negatiive mining(OHEM),控制難分樣本占據(jù)的比例,以解決樣本類別不均衡的問題。?
對(duì)于one-stage的檢測(cè)器來說,盡管可以采用同樣的策略(OHEM)控制正負(fù)樣本,但是還是有缺陷,文中的說法是:
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ù)做出改進(jìn)。
解決方案:Focal Loss
作者提出一種新的損失函數(shù),思路是希望那些hard examples對(duì)損失的貢獻(xiàn)變大,使網(wǎng)絡(luò)更傾向于從這些樣本上學(xué)習(xí)。
作者以二分類為例進(jìn)行說明:?
首先是我們常使用的交叉熵?fù)p失函數(shù):?
要對(duì)類別不均衡問題對(duì)loss的貢獻(xiàn)進(jìn)行一個(gè)控制,即加上一個(gè)控制權(quán)重即可,最初作者的想法即如下這樣,對(duì)于屬于少數(shù)類別的樣本,增大α即可?
但這樣有一個(gè)問題,它僅僅解決了正負(fù)樣本之間的平衡問題,并沒有區(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越大,則貢獻(xiàn)的loss就越小,相對(duì)來說,難分樣本所占的比重就會(huì)變大,見如下原文中的一個(gè)例子:
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)
因此,通過這個(gè)公式區(qū)分了易分/難分樣本,在實(shí)際中,作者采用如下公式,即綜合了上述兩個(gè)公式的形式:?
這里的兩個(gè)參數(shù)α和γ協(xié)調(diào)來控制,本文作者采用α=0.25,γ=2效果最好
另外:作者提到了類別不均衡和模型的初始化問題,即數(shù)量很多的某一類樣本會(huì)起主導(dǎo)作用,在開始訓(xùn)練的時(shí)候可能導(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,不太清楚為什么要這么做,留個(gè)問號(hào),help
實(shí)驗(yàn)框架
本文作者實(shí)驗(yàn)時(shí)設(shè)計(jì)了一個(gè)叫RetinaNet的one-satge的網(wǎng)絡(luò)結(jié)構(gòu),以證明通過Focal Loss,one-stage的網(wǎng)絡(luò)結(jié)構(gòu)也能夠達(dá)到two-stage的準(zhǔn)確率,實(shí)際上采用的是基于resnet的FPN(特征金字塔網(wǎng)絡(luò),可自行查閱論文論文鏈接),網(wǎng)絡(luò)框架如下:?
實(shí)驗(yàn)結(jié)果
最好能在coco test-dev上達(dá)到 39.1AP,5Fps?
由上圖可見,準(zhǔn)確率高于two-stage的方法,并且速度可以得到保持
上圖是各指標(biāo)的對(duì)比實(shí)驗(yàn)結(jié)果,具體可查看論文?
上圖表明了該loss對(duì)負(fù)樣本的影響很明顯,使得負(fù)樣本的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ā)揮相同的作用即可,作者有實(shí)驗(yàn)證明,具體可查閱論文。
結(jié)論
本文從loss的角度闡述了one-stage檢測(cè)器準(zhǔn)確率低的問題,并給出了解決方案,很精彩。
參考
博客:參考博客?
論文:論文原文
---------------------?
作者:Arch學(xué)灰?
來源:CSDN?
原文:https://blog.csdn.net/qq_34564947/article/details/77200104?
版權(quán)聲明:本文為博主原創(chuàng)文章,轉(zhuǎn)載請(qǐng)附上博文鏈接!
總結(jié)
以上是生活随笔為你收集整理的Focal Loss论文阅读笔记的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: Light-Head R-CNN相关资料
- 下一篇: 搭建及训练py-R-FCN遇到的问题