improved open set domain adaptation with backpropagation 學習筆記

improved open set domain adaptation with backpropagation 學習筆記

TIP

KL距離,是Kullback-Leibler差異(Kullback-Leibler Divergence)的簡稱,也叫做相對熵(Relative Entropy)。它衡量的是相同事件空間裏的兩個概率分佈的差異情況
本文更改了OpenBP中的二元交叉熵損失,提高了識別率。

ABSTRACT

本文對Open set domain adaptation by back propagation(OSDA-BP)中用於提取潛在未知類別樣本的二元交叉熵損失進行了深入的研究。基於這種新的理解,我們提出用對稱的庫勒貝克-萊布勒距離損失來代替二元交叉熵損失

1.INTRODUCTION AND RELATED WORK

作者透徹詳盡地解釋了對於OSDA-BP中二元交叉熵損失的理解,並使用對稱的KL距離來提出一個新的二元交叉熵損失公式

2.PROPOSED METHOD

2.1 Overall Idea

本文的方法框架主要還是基於論文《Open set domain adaptation by backpropagation》中的框架。該方法的框圖爲:

image-20201108213044235

其中源域 D s = { ( x i s , y i s ) } i = 1 n s D_s=\{(x^s_i,y^s_i)\}^{n_s}_{i=1} Ds={(xis,yis)}i=1ns擁有 n s n_s ns個已標註的樣本,而目標域 D t = { ( x i t , y i t ) } i = 1 n t D_t=\{(x^t_i,y^t_i)\}^{n_t}_{i=1} Dt={(xit,yit)}i=1nt擁有 n t n_t nt個未標註的樣本,其中x表示樣本的圖像,y表示樣本相對應的標籤。源域與目標域之間都存在彼此未擁有的類別。在這樣的設定下,作者基於CNN訓練網絡 f ( θ , x ) f(\theta,x) f(θ,x),來將輸入的樣本 x s x_s xs或者 x t x_t xt分類成K+1類,其中K表示已知類的個數,第K+1類表示未知類。即 f ( θ , x ) = { P ( c l s ( x ) = 1... P ( c l s ( x ) = K + 1 ) ) } f(\theta,x)=\{P(cls(x)=1...P(cls(x)=K+1))\} f(θ,x)={P(cls(x)=1...P(cls(x)=K+1))}.

模型使用了一個特徵提取器與一個分類器,其中 f ( θ , x ) = C ( G ( θ g , x ) , θ c ) f(\theta,x)=C(G(\theta_g,x),\theta_c) f(θ,x)=C(G(θg,x),θc)。( θ g \theta_g θg表示特徵提取器的參數,而 θ c \theta_c θc表示分類器的參數)

在OpenBP中,首先使用標準交叉熵損失 L s L_s Ls來進行源域樣本的分類:

L s ( θ , D s ) = 1 ∣ D s ∣ ∑ ( x s , y s ) ∈ D s l ( y s , f ( θ , x s ) ) L_s(\theta,D_s)=\frac{1}{|D_s|}\sum \limits_{(x_s,y_s)\in D_s}l(y_s,f(\theta,x_s)) Ls(θ,Ds)=Ds1(xs,ys)Dsl(ys,f(θ,xs)),其中的 l ( y , f ) = − ∑ j = 1 K y j l o g ( f j ) l(y,f)=-\sum \limits_{j=1}\limits^{K}y_jlog(f_j) l(y,f)=j=1Kyjlog(fj), ∣ D s ∣ |D_s| Ds表示源域樣本的個數。

接着OpenBP使用一個二元交叉熵損失 L u L_u Lu訓練分類器來形成目標域中已知類與未知類之間的邊界: L u ( θ , x t ) = − ( 1 − t ) ( 1 − l o g ( P ( c l s ( x t ) = K + 1 ) ) ) − t l o g ( P ( c l s ( x t ) = K + 1 ) ) L_u(\theta,x_t)=-(1-t)(1-log(P(cls(x_t)=K+1)))-tlog(P(cls(x_t)=K+1)) Lu(θ,xt)=(1t)(1log(P(cls(xt)=K+1)))tlog(P(cls(xt)=K+1)),t的值爲0.5.

爲了將目標域中未知類別的樣本分離,我們還可以使用二元交叉熵損失的平均形式 L u ( θ , D t ) = 1 ∣ D t ∣ ∑ x t ∈ D t L u ( θ , x t ) L_u(\theta,D_t)=\frac{1}{|D_t|}\sum\limits_{x_t\in D_t}L_u(\theta,x_t) Lu(θ,Dt)=Dt1xtDtLu(θ,xt).

使用 p t = ( t , 1 − t ) p_t=(t,1-t) pt=(t,1t)來表示一個由t(0<t<1)參數化的二元分佈,對於任何目標域樣本 x t x_t xt,令 t ^ ≜ P ( c l s ( x t ) = K + 1 ) \hat{t} \triangleq P(cls(x_t)=K+1) t^P(cls(xt)=K+1),且 p t ^ = ( t ^ , 1 − t ^ ) p_{\hat{t}}=(\hat{t},1-\hat{t}) pt^=(t^,1t^)。則 p t p_t pt p t ^ p_{\hat{t}} pt^之間的KL距離爲

d K L ( p t ∣ ∣ p t ^ ) = t l o g t t ^ + ( 1 − t ) l o g 1 − t 1 − t ^ = − t l o g t ^ − ( 1 − t ) l o g ( 1 − t ^ ) + v ( t ) d_{KL}(p_t||p_{\hat{t}})=tlog\frac{t}{\hat{t}}+(1-t)log\frac{1-t}{1-\hat{t}}=-tlog\hat{t}-(1-t)log(1-\hat{t})+v(t) dKL(ptpt^)=tlogt^t+(1t)log1t^1t=tlogt^(1t)log(1t^)+v(t).

其中 v ( t ) = t l o g t + ( 1 − t ) l o g ( 1 − t ) v(t)=tlogt+(1-t)log(1-t) v(t)=tlogt+(1t)log(1t)對於一個固定的t來說是一個固定的值。

上面的二元交叉熵損失 L u L_u Lu可以看作爲 ( t , 1 − t ) (t,1-t) (t,1t) ( p ( c l s ( x t ) = K + 1 ) , 1 − p ( c l s ( x t ) = K + 1 ) (p(cls(x_t)=K+1),1-p(cls(x_t)=K+1) (p(cls(xt)=K+1),1p(cls(xt)=K+1)之間除去常數 v ( t ) v(t) v(t)的KL距離,通過設置t = 0.5,它爲訓練好的網絡提供了一個合理的機制來區分已知類和未知類。

由於二元交叉熵損失本質上是一個KL距離,我們可以進一步利用它的對稱形式:

L a d v ( θ , t , D t ) = 1 ∣ D t ∣ ∑ x t ∈ D t L a d v ( θ , t , x t ) L_{adv}(\theta,t,D_t)=\frac{1}{|D_t|}\sum\limits_{x_t\in D_t}L_{adv}(\theta,t,x_t) Ladv(θ,t,Dt)=Dt1xtDtLadv(θ,t,xt)

L a d v ( θ , t , x t ) = d K L ( p t ∣ ∣ p t ^ ( x t ) ) + d K L ( p t ^ ( x t ) ∣ ∣ p t ) L_{adv}(\theta,t,x_t)=d_{KL}(p_t||p_{\hat{t}(x_t)})+d_{KL}(p_{\hat{t}(x_t)}||p_t) Ladv(θ,t,xt)=dKL(ptpt^(xt))+dKL(pt^(xt)pt).

整理之後,總的損失爲:

L ( θ , t ) = L s ( θ , D s ) + λ 1 L a d v ( θ , t , D t ) L(\theta,t)=L_s(\theta,D_s)+\lambda_1L_{adv}(\theta,t,D_t) L(θ,t)=Ls(θ,Ds)+λ1Ladv(θ,t,Dt), λ 1 \lambda_1 λ1=0.5

總的目標函數爲:

min ⁡ θ c L s ( θ , D s ) + λ 1 L a d v ( θ , t , D t ) \min\limits_{\theta_c}L_s(\theta,D_s)+\lambda_1L_{adv}(\theta,t,D_t) θcminLs(θ,Ds)+λ1Ladv(θ,t,Dt).

min ⁡ θ g L s ( θ , D s ) − λ 1 L a d v ( θ , t , D t ) \min\limits_{\theta_g}L_s(\theta,D_s)-\lambda_1L_{adv}(\theta,t,D_t) θgminLs(θ,Ds)λ1Ladv(θ,t,Dt).