Introduction
在目標檢測中,從圖片上預測出一些region proposals,這些region proposals會與預先設置好的anchors進行匹配,匹配的方式是nms,超過給定IoU閾值就匹配,否則不匹配。這種通過IoU指標進行匹配有缺點:在空間上對齊的region proposal,從它提取出來的特徵不一定能夠很好地預測object的類別和位置。論文給出了例子,對於長條形狀的物體,非中心化的物體,比如牙刷,空間上對齊的region proposal包含許多背景信息,導致特徵的表徵能力變弱,而牙刷的最具表徵的部位是牙刷頭部。針對這個問題,有許多論文研究嘗試去掉anchor,這些方法稱爲anchor free方法。論文方法沒有去掉anchor,而是能夠讓物體靈活地匹配anchor,從而能夠學習到對分類和定位最具有表徵能力的特徵。
什麼樣的匹配方式是最好的呢?首先保證算法有高的召回率。檢測器要保證對於每個object,至少有一個anchor對應的預測接近gt。或者說每個gt對應的anchor都要有一個proposal與之匹配。第二,算法要有高的預測精度。檢測器需要把定位錯誤的proposal分類成背景類。定位錯誤的proposal預測的結果一般預測的不準,把false position去掉,能夠提高預測精度。第三,anchor的匹配預測要與最後一步NMS兼容,例如,分類分數越高,定位要越準確。否則,定位準確但分類分數低的proposal會在nms中拋棄掉。
論文把object-anchor匹配問題定義成最大似然估計問題。具體的描述請看下文。
Detector Training as Maximum Likelihood Estimation
檢測問題可以設計成極大似然估計問題,具體如下。
以一階CNN-based目標檢測算法爲例。給定一張圖片I I I ,gt是B B B ,其中一個gt box b i ∈ B b_i \in B b i ∈ B ,對應類別b i c l s b_i^{cls} b i c l s 和位置b i l o c b_i^{loc} b i l o c 。在網絡中,每個anchor a j ∈ A a_j \in A a j ∈ A 有類別預測a j c l s ∈ R k a_j^{cls} \in \mathcal{R}^k a j c l s ∈ R k 和位置預測a j l o c ∈ R 4 a_j^{loc} \in \mathcal{R}^4 a j l o c ∈ R 4 ,k表示有k個分類類別。
在訓練過程,nms方法會把anchors與objects對齊,如下圖
有一個矩陣C i j ∈ { 0 , 1 } C_{ij} \in \{0, 1\} C i j ∈ { 0 , 1 } ,定義object b i b_i b i 是否匹配anchor a j a_j a j 。當b i b_i b i 和a j a_j a j 的IoU大於一個閾值時,b i b_i b i 和b j b_j b j 匹配,C i j = 1 C_{ij}=1 C i j = 1 ,否則C i j = 0 C_{ij}=0 C i j = 0 。特別地,當多個object的IoU大於閾值時,有最大IoU的object匹配這個anchor,保證每個anchor只和最匹配的一個object配對,例如∑ i C i j ∈ 0 , 1 , ∀ a j ∈ A \sum_{i}C_{ij} \in {0, 1}, \forall a_j \in A ∑ i C i j ∈ 0 , 1 , ∀ a j ∈ A 。
假設有3個box b 1 , b 2 , b 3 b_1, b_2, b_3 b 1 , b 2 , b 3 ,有4個anchor a 1 , a 2 , a 3 , a 4 a_1, a_2, a_3, a_4 a 1 , a 2 , a 3 , a 4 ,兩兩配對的IoU值如下
a 1 a_1 a 1
a 2 a_2 a 2
a 3 a_3 a 3
a 4 a_4 a 4
b 1 b_1 b 1
0.3
0.2
0.7
0.1
b 2 b_2 b 2
0.8
0.4
0.2
0.7
b 3 b_3 b 3
0.1
0.3
0.2
0.9
假設IoU閾值設置爲0.5,則可以去掉一些匹配選項
a 1 a_1 a 1
a 2 a_2 a 2
a 3 a_3 a 3
a 4 a_4 a 4
b 1 b_1 b 1
0
0
0.7
0
b 2 b_2 b 2
0.8
0
0
0.7
b 3 b_3 b 3
0
0
0
0.9
對於a 4 a_4 a 4 那列,只選擇最匹配的一項,即b 3 b_3 b 3
a 1 a_1 a 1
a 2 a_2 a 2
a 3 a_3 a 3
a 4 a_4 a 4
b 1 b_1 b 1
0
0
1
0
b 2 b_2 b 2
1
0
0
0
b 3 b_3 b 3
0
0
0
1
所以∑ i C i j ∈ 0 , 1 , ∀ a j ∈ A \sum_{i}C_{ij} \in {0, 1}, \forall a_j \in A ∑ i C i j ∈ 0 , 1 , ∀ a j ∈ A 。定義A + ⊆ A A_{+} \subseteq A A + ⊆ A 爲{ a j ∣ ∑ i C i j = 1 } \{a_j | \sum_i C_{ij} = 1\} { a j ∣ ∑ i C i j = 1 } ,A − ⊆ A A_{-} \subseteq A A − ⊆ A 爲{ a j ∣ ∑ i C i j = 0 } \{a_j | \sum_i C_{ij} = 0\} { a j ∣ ∑ i C i j = 0 } 。看上例,則a 1 , a 3 , a 4 ∈ A + a_1, a_3, a_4 \in A_{+} a 1 , a 3 , a 4 ∈ A + ,a 2 ∈ A − a_2 \in A_{-} a 2 ∈ A − 。
算法(一階算法)的損失函數是
L ( θ ) = ∑ a j ∈ A + ∑ b i ∈ B C i j L ( θ ) i j c l s + β ∑ a j ∈ A + ∑ b i ∈ B C i j L ( θ ) i j l o c + ∑ a j ∈ A − L ( θ ) j b g
\mathcal{L}(\theta) = \sum_{a_j \in A_+} \sum_{b_i \in B} C_{ij} \mathcal{L}(\theta)_{ij}^{cls} + \beta \sum_{a_j \in A_+} \sum_{b_i \in B} C_{ij} \mathcal{L}(\theta)_{ij}^{loc} + \sum_{a_j \in A_-} \mathcal{L}(\theta)_j^{bg}
L ( θ ) = a j ∈ A + ∑ b i ∈ B ∑ C i j L ( θ ) i j c l s + β a j ∈ A + ∑ b i ∈ B ∑ C i j L ( θ ) i j l o c + a j ∈ A − ∑ L ( θ ) j b g
上式3項分別表示objects的分類損失,objects的定位損失和背景類的分類損失。沒和object匹配的anchors都劃分爲背景類。θ \theta θ 表示模型參數。L ( θ ) i j c l s = B C E ( a j c l s , b i c l s , θ ) \mathcal{L}(\theta)_{ij}^{cls} = BCE(a_j^{cls}, b_i^{cls}, \theta) L ( θ ) i j c l s = B C E ( a j c l s , b i c l s , θ ) ,L ( θ ) i j l o c = S m o o t h L 1 ( a j l o c , b i l o c , θ ) \mathcal{L}(\theta)_{ij}^{loc} = SmoothL1(a_j^{loc}, b_i^{loc}, \theta) L ( θ ) i j l o c = S m o o t h L 1 ( a j l o c , b i l o c , θ ) ,L ( θ ) j b g = B C E ( a j c l s , 0 ⃗ , θ ) \mathcal{L}(\theta)_{j}^{bg} = BCE(a_j^{cls}, \vec{0}, \theta) L ( θ ) j b g = B C E ( a j c l s , 0 , θ ) 。BCE表示二元交叉熵損失。β \beta β 表示正則化參數。
損失L ( θ ) \mathcal{L}(\theta) L ( θ ) 可以轉成最大似然問題
P ( θ ) = e − L ( θ ) = e − ∑ a j ∈ A + ∑ b i ∈ B C i j L ( θ ) i j c l s − β ∑ a j ∈ A + ∑ b i ∈ B C i j L ( θ ) i j l o c − ∑ a j ∈ A − L ( θ ) j b g = e − ∑ a j ∈ A + ∑ b i ∈ B C i j L ( θ ) i j c l s e − β ∑ a j ∈ A + ∑ b i ∈ B C i j L ( θ ) i j l o c e − ∑ a j ∈ A − L ( θ ) j b g = ∏ a j ∈ A + e − ∑ b i ∈ B C i j L ( θ ) i j c l s ∏ a j ∈ A + e − ∑ b i ∈ B C i j L ( θ ) i j l o c ∏ a j ∈ A − e − L ( θ ) j b g
\begin{aligned}
\mathcal{P}(\theta) & = e^{-\mathcal{L}(\theta)} \\
& = e^{-\sum_{a_j \in A_+} \sum_{b_i \in B} C_{ij} \mathcal{L}(\theta)_{ij}^{cls} - \beta \sum_{a_j \in A_+} \sum_{b_i \in B} C_{ij} \mathcal{L}(\theta)_{ij}^{loc} - \sum_{a_j \in A_-} \mathcal{L}(\theta)_j^{bg} } \\
& = e^{-\sum_{a_j \in A_+} \sum_{b_i \in B} C_{ij} \mathcal{L}(\theta)_{ij}^{cls}} e^{- \beta \sum_{a_j \in A_+} \sum_{b_i \in B} C_{ij} \mathcal{L}(\theta)_{ij}^{loc} } e^{ -\sum_{a_j \in A_-} \mathcal{L}(\theta)_j^{bg} } \\
& = \prod_{a_j \in A_+} e^{-\sum_{b_i \in B} C_{ij} \mathcal{L}(\theta)_{ij}^{cls}} \prod_{a_j \in A_+} e^{-\sum_{b_i \in B} C_{ij} \mathcal{L}(\theta)_{ij}^{loc}} \prod_{a_j \in A_-} e^{- \mathcal{L}(\theta)_{j}^{bg}}
\end{aligned}
P ( θ ) = e − L ( θ ) = e − ∑ a j ∈ A + ∑ b i ∈ B C i j L ( θ ) i j c l s − β ∑ a j ∈ A + ∑ b i ∈ B C i j L ( θ ) i j l o c − ∑ a j ∈ A − L ( θ ) j b g = e − ∑ a j ∈ A + ∑ b i ∈ B C i j L ( θ ) i j c l s e − β ∑ a j ∈ A + ∑ b i ∈ B C i j L ( θ ) i j l o c e − ∑ a j ∈ A − L ( θ ) j b g = a j ∈ A + ∏ e − ∑ b i ∈ B C i j L ( θ ) i j c l s a j ∈ A + ∏ e − ∑ b i ∈ B C i j L ( θ ) i j l o c a j ∈ A − ∏ e − L ( θ ) j b g
因爲C i j ∈ { 0 , 1 } C_{ij} \in \{0, 1\} C i j ∈ { 0 , 1 } ,而且A + ⊆ A A_{+} \subseteq A A + ⊆ A 爲{ a j ∣ ∑ i C i j = 1 } \{a_j | \sum_i C_{ij} = 1\} { a j ∣ ∑ i C i j = 1 } ,所以可以把C i j C_{ij} C i j 移動e的外面
P ( θ ) = e − L ( θ ) = ∏ a j ∈ A + e − ∑ b i ∈ B C i j L ( θ ) i j c l s ∏ a j ∈ A + e − ∑ b i ∈ B C i j L ( θ ) i j l o c ∏ a j ∈ A − e − L ( θ ) j b g = ∏ a j ∈ A + ( ∑ b i ∈ B C i j e − L ( θ ) i j c l s ) ∏ a j ∈ A + ( ∑ b i ∈ B C i j e − L ( θ ) i j l o c ) ∏ a j ∈ A − e − L ( θ ) j b g
\begin{aligned}
\mathcal{P}(\theta) & = e^{-\mathcal{L}(\theta)} \\
& = \prod_{a_j \in A_+} e^{-\sum_{b_i \in B} C_{ij} \mathcal{L}(\theta)_{ij}^{cls}} \prod_{a_j \in A_+} e^{-\sum_{b_i \in B} C_{ij} \mathcal{L}(\theta)_{ij}^{loc}} \prod_{a_j \in A_-} e^{- \mathcal{L}(\theta)_{j}^{bg}} \\
& = \prod_{a_j \in A_+} (\sum_{b_i \in B} C_{ij} e^{-\mathcal{L}(\theta)_{ij}^{cls}} )\prod_{a_j \in A_+} (\sum_{b_i \in B} C_{ij} e^{-\mathcal{L}(\theta)_{ij}^{loc}}) \prod_{a_j \in A_-} e^{- \mathcal{L}(\theta)_{j}^{bg}}
\end{aligned}
P ( θ ) = e − L ( θ ) = a j ∈ A + ∏ e − ∑ b i ∈ B C i j L ( θ ) i j c l s a j ∈ A + ∏ e − ∑ b i ∈ B C i j L ( θ ) i j l o c a j ∈ A − ∏ e − L ( θ ) j b g = a j ∈ A + ∏ ( b i ∈ B ∑ C i j e − L ( θ ) i j c l s ) a j ∈ A + ∏ ( b i ∈ B ∑ C i j e − L ( θ ) i j l o c ) a j ∈ A − ∏ e − L ( θ ) j b g
考慮上例的a 1 a_1 a 1
e − C 01 L ( θ ) 01 c l s − C 11 L ( θ ) 11 c l s − C 21 L ( θ ) 21 c l s = e − 0 L ( θ ) 01 c l s − 1 L ( θ ) 11 c l s − 0 L ( θ ) 21 c l s = e − L ( θ ) 11 c l s = 0 e − L ( θ ) 01 c l s + 1 e − L ( θ ) 11 c l s + e − L ( θ ) 21 c l s = ∑ b i ∈ B C i 1 e − L ( θ ) i 1 c l s
\begin{aligned}
& e^{-C_{01} \mathcal{L}(\theta)_{01}^{cls} -C_{11} \mathcal{L}(\theta)_{11}^{cls} -C_{21} \mathcal{L}(\theta)_{21}^{cls}} \\
&= e^{-0 \mathcal{L}(\theta)_{01}^{cls} -1 \mathcal{L}(\theta)_{11}^{cls} -0 \mathcal{L}(\theta)_{21}^{cls}} \\
&= e^{-\mathcal{L}(\theta)_{11}^{cls}} \\
&= 0 e^{-\mathcal{L}(\theta)_{01}^{cls}} + 1e^{-\mathcal{L}(\theta)_{11}^{cls}} + e^{-\mathcal{L}(\theta)_{21}^{cls}} \\
& = \sum_{b_i \in B} C_{i1} e^{-\mathcal{L}(\theta)_{i1}^{cls}}
\end{aligned}
e − C 0 1 L ( θ ) 0 1 c l s − C 1 1 L ( θ ) 1 1 c l s − C 2 1 L ( θ ) 2 1 c l s = e − 0 L ( θ ) 0 1 c l s − 1 L ( θ ) 1 1 c l s − 0 L ( θ ) 2 1 c l s = e − L ( θ ) 1 1 c l s = 0 e − L ( θ ) 0 1 c l s + 1 e − L ( θ ) 1 1 c l s + e − L ( θ ) 2 1 c l s = b i ∈ B ∑ C i 1 e − L ( θ ) i 1 c l s
令P ( θ ) i j c l s = e − L ( θ ) i j c l s \mathcal{P}(\theta)_{ij}^{cls} = e^{-\mathcal{L}(\theta)_{ij}^{cls}} P ( θ ) i j c l s = e − L ( θ ) i j c l s 爲類別的置信度。L \mathcal{L} L 公式中有log函數,與外面的e函數抵消後,就是類別的置信度(概率)。對定位損失套用相同的公式,P ( θ ) i j l o c = e − L ( θ ) i j l o c \mathcal{P}(\theta)_{ij}^{loc} = e^{-\mathcal{L}(\theta)_{ij}^{loc}} P ( θ ) i j l o c = e − L ( θ ) i j l o c 表示爲定位的置信度。那麼
P ( θ ) = e − L ( θ ) = ∏ a j ∈ A + ( ∑ b i ∈ B C i j e − L ( θ ) i j c l s ) ∏ a j ∈ A + ( ∑ b i ∈ B C i j e − L ( θ ) i j l o c ) ∏ a j ∈ A − e − L ( θ ) i j b g = ∏ a j ∈ A + ( ∑ b i ∈ B C i j P ( θ ) i j c l s ) ∏ a j ∈ A + ( ∑ b i ∈ B C i j P ( θ ) i j l o c ) ∏ a j ∈ A − P ( θ ) j b g
\begin{aligned}
\mathcal{P}(\theta) & = e^{-\mathcal{L}(\theta)} \\
& = \prod_{a_j \in A_+} (\sum_{b_i \in B} C_{ij} e^{-\mathcal{L}(\theta)_{ij}^{cls}} )\prod_{a_j \in A_+} (\sum_{b_i \in B} C_{ij} e^{-\mathcal{L}(\theta)_{ij}^{loc}}) \prod_{a_j \in A_-} e^{- \mathcal{L}(\theta)_{ij}^{bg}} \\
& = \prod_{a_j \in A_+} (\sum_{b_i \in B} C_{ij} \mathcal{P}(\theta)_{ij}^{cls}) \prod_{a_j \in A_+} (\sum_{b_i \in B} C_{ij} \mathcal{P}(\theta)_{ij}^{loc}) \prod_{a_j \in A_-} \mathcal{P}(\theta)_{j}^{bg}
\end{aligned}
P ( θ ) = e − L ( θ ) = a j ∈ A + ∏ ( b i ∈ B ∑ C i j e − L ( θ ) i j c l s ) a j ∈ A + ∏ ( b i ∈ B ∑ C i j e − L ( θ ) i j l o c ) a j ∈ A − ∏ e − L ( θ ) i j b g = a j ∈ A + ∏ ( b i ∈ B ∑ C i j P ( θ ) i j c l s ) a j ∈ A + ∏ ( b i ∈ B ∑ C i j P ( θ ) i j l o c ) a j ∈ A − ∏ P ( θ ) j b g
上述公式就是極大似然估計的公式。目標檢測就轉成了極大似然估計問題。
考慮如何把通過nms得到的匹配矩陣C i j C_{ij} C i j 去掉,通過學習得到匹配矩陣C i j C_{ij} C i j 。
Detection Customized Likelihood
現在的目標是讓網絡自己學到最優的object-anchor匹配,保證算法具有高的召回率和精度,同時和預測後的NMS操作兼容。論文的做法首先是構造 a bag of candidate anchors for each object b i b_i b i by selecting (n) top-ranked anchors A i ⊂ A A_i \subset A A i ⊂ A in terms of their IoU with the object. 根據IoU爲每個object選擇top-n個anchor。接着,通過最大化自定義的似然來學習匹配的最佳的anchor。
爲了優化召回率,對於每個object b i ∈ B b_i \in B b i ∈ B ,首先要保證至少有一個anchor a j ∈ A i a_j \in A_i a j ∈ A i ,它的預測(a j c l s a_j^{cls} a j c l s 和a j l o c a_j^{loc} a j l o c )接近gt。這個目標可以通過下面的公式來實現
P r e c a l l = ∏ i max a j ∈ A i ( P ( θ ) i j c l s P ( θ ) i j l o c )
\mathcal{P}_{recall} = \prod_i \max_{a_j \in A_i} (\mathcal{P}(\theta)_{ij}^{cls} \mathcal{P}(\theta)_{ij}^{loc})
P r e c a l l = i ∏ a j ∈ A i max ( P ( θ ) i j c l s P ( θ ) i j l o c )
爲了提升檢測的精度,檢測器需要把定位差的anchor分類成背景類。令P { a j → b i } P\{a_j \to b_i\} P { a j → b i } 表示anchor a j a_j a j 正確預測object b i b_i b i 的概率。anchor a j a_j a j 最後匹配的是object b i , i = arg max P { a j → b i } b_i, i = \arg \max P\{a_j \to b_i\} b i , i = arg max P { a j → b i } 。因此,anchor a j a_j a j 有匹配object的概率是max i P { a j → b i } \max_i P\{a_j \to b_i\} max i P { a j → b i } , 而P { a j ∈ A − } = 1 − max i P { a j → b i } P\{a_j \in A_-\} = 1 - \max_i P\{a_j \to b_i\} P { a j ∈ A − } = 1 − max i P { a j → b i } 表示a j a_j a j 沒有與任何object匹配的概率。如果anchor a j a_j a j 沒有與任何object匹配,那麼anchor a j a_j a j 的類別是背景類,它的背景類的預測置信度要高。論文的公式是
P ( θ ) p r e c i s i o n = ∏ j ( 1 − P { a j ∈ A − } ( 1 − P ( θ ) j b g ) )
\mathcal{P}(\theta)_{precision} = \prod_j (1 - P\{a_j \in A_-\}(1-\mathcal{P}(\theta)_j^{bg}))
P ( θ ) p r e c i s i o n = j ∏ ( 1 − P { a j ∈ A − } ( 1 − P ( θ ) j b g ) )
我認爲是這樣的,匹配爲背景的anchor的預測類別不是背景類的概率要低。這個公式是爲了提高精度,精度的定義是precision = TP/(TP + FP)。這個公式的作用是通過降低FP來提高精度。FP是指沒有與任何一個gt box匹配,但是預測出其他類別(非背景類)的概率卻很高的anchor。只要預測出其他類別(非背景類)的概率變低(這個公式的目的),這些沒有和任何一個gt box匹配的anchor就不會是FP。
對於P { a j → b i } P\{a_j \to b_i\} P { a j → b i } ,它應該具備以下性質。(1)P { a j → b i } P\{a_j \to b_i\} P { a j → b i } 對於a j l o c a_j^{loc} a j l o c 和b i b_i b i ,或者說I o U i j l o c IoU_{ij}^{loc} I o U i j l o c ,是一個單調遞增函數。(2)當I o U i j l o c IoU_{ij}^{loc} I o U i j l o c 小於閾值t t t ,P { a j → b i } P\{a_j \to b_i\} P { a j → b i } 要接近0。(3)對於一個object b i b_i b i ,存在並且只存在一個a j a_j a j 滿足P { a j → b i } = 1 P\{a_j \to b_i\} = 1 P { a j → b i } = 1 。滿足這些性質的公式是
Saturated linear ( x , t 1 , t 2 ) = { 0 , x ≤ t 1 x − t 1 t 2 − t 1 , t 1 < x < t 2 1 , x ≥ t 2
\text{Saturated linear}(x, t_1, t_2) = \begin{cases} 0, & x \le t_1 \\ \frac{x - t_1}{t_2 - t_1}, & t_1 \lt x \lt t_2 \\ 1, & x \ge t_2 \end{cases}
Saturated linear ( x , t 1 , t 2 ) = ⎩ ⎪ ⎨ ⎪ ⎧ 0 , t 2 − t 1 x − t 1 , 1 , x ≤ t 1 t 1 < x < t 2 x ≥ t 2
如下圖所示
因此P { a j → b i } = Saturated linear ( x , t , max j ( I o U i j l o c ) ) P\{a_j \to b_i\} = \text{Saturated linear}(x, t, \max_j (IoU_{ij}^{loc})) P { a j → b i } = Saturated linear ( x , t , max j ( I o U i j l o c ) ) 。
最終,目標檢測的自定義似然定義爲
P ( θ ) = P ( θ ) r e c a l l × P ( θ ) p r e c i s i o n
\mathcal{P}(\theta) = \mathcal{P}(\theta)_{recall} \times \mathcal{P}(\theta)_{precision}
P ( θ ) = P ( θ ) r e c a l l × P ( θ ) p r e c i s i o n
Anchor Matching Mechanism
上述的自定義依然轉換成損失函數爲
L = − log P ( θ ) = − ∑ i log ( max a j ∈ A i ( P ( θ ) i j c l s P ( θ ) i j l o c ) ) − ∑ j log ( 1 − P { a j ∈ A − } ( 1 − P ( θ ) j b g ) )
\begin{aligned}
\mathcal{L} &= -\log \mathcal{P}(\theta) \\
&= -\sum_{i} \log (\max_{a_j \in A_i}(\mathcal{P}(\theta)_{ij}^{cls} \mathcal{P}(\theta)_{ij}^{loc})) - \sum_j \log (1 - P\{a_j \in A_-\}(1 - \mathcal{P}(\theta)_j^{bg}))
\end{aligned}
L = − log P ( θ ) = − i ∑ log ( a j ∈ A i max ( P ( θ ) i j c l s P ( θ ) i j l o c ) ) − j ∑ log ( 1 − P { a j ∈ A − } ( 1 − P ( θ ) j b g ) )
其中max \max max 函數用來爲每個object選擇最好的anchor。
在訓練早期,對於隨機初始化網絡參數,所有的anchors的置信度很小。高置信度的anchor對於檢測器的訓練來說不充足。論文提出了Mean-max函數
Mean-max X = ∑ x j ∈ X x j 1 − x j ∑ x j ∈ X 1 1 − x j
\text{Mean-max}{X} = \frac{\sum_{x_j \in X} \frac{x_j}{1 - x_j}}{\sum_{x_j \in X} \frac{1}{1 - x_j}}
Mean-max X = ∑ x j ∈ X 1 − x j 1 ∑ x j ∈ X 1 − x j x j
用來選擇anchors。但訓練不充分時,Mean-max函數表現的像mean函數,意味着所有anchors都用來訓練。隨着訓練增加,一些anchors的置信度增加,Mean-max函數表現像max函數,如下圖
然後,損失函數變成
L ′ ( θ ) = − w 1 ∑ i log ( Mean-max ( X i ) ) + w 2 ∑ j FL_ ( P { a j ∈ A } ( 1 − P ( θ ) j b g ) )
\mathcal{L}'(\theta) = - w_1 \sum_{i} \log(\text{Mean-max}(X_i)) + w_2 \sum_j \text{FL\_}(P\{a_j \in A_\}(1 - \mathcal{P}(\theta)_j^{bg}))
L ′ ( θ ) = − w 1 i ∑ log ( Mean-max ( X i ) ) + w 2 j ∑ FL_ ( P { a j ∈ A } ( 1 − P ( θ ) j b g ) )
其中X i = { P ( θ ) i j c l s P ( θ ) i j l o c ∣ a j ∈ A i } X_i = \{\mathcal{P}(\theta)_{ij}^{cls}\mathcal{P}(\theta)_{ij}^{loc} | a_j \in A_i\} X i = { P ( θ ) i j c l s P ( θ ) i j l o c ∣ a j ∈ A i } 。繼承focal loss的參數α \alpha α 和γ \gamma γ ,設置w 1 = α ∥ B ∥ w_1 = \frac{\alpha}{\lVert B \rVert} w 1 = ∥ B ∥ α ,w 2 = 1 − α n ∥ B ∥ w_2 = \frac{1 - \alpha}{n\lVert B \rVert} w 2 = n ∥ B ∥ 1 − α 。FL_ ( p ) = − p γ log ( 1 − p ) \text{FL\_}(p)=-p^{\gamma} \log (1-p) FL_ ( p ) = − p γ log ( 1 − p ) 。
Experiments
使用coco數據集,對於非中心化的類別,實驗效果有提升,如
與其他模型的比較: