天天看點

論文筆記之: Deep Metric Learning via Lifted Structured Feature Embedding

Deep Metric Learning via Lifted Structured Feature Embedding

CVPR 2016 

  摘要:本文提出一種距離度量的方法,充分的發揮 training batches 的優勢,by lifting the vector of pairwise distances within the batch to the matrix of pairwise distances. 剛開始看這個摘要,有點懵逼,不怕,後面會知道這段英文是啥意思的。

  

  引言部分開頭講了距離相似性度量的重要性,并且應用廣泛。這裡提到了三元組損失函數 (triplet loss),就是講在訓練的過程當中,盡可能的拉近兩個相同物體之間的距離,而拉遠不同物體之間的距離;這種做法會比普通的訓練方法得到更好的效果。但是,文章中提到,現有的三元組方法卻無法充分利用 minibatch SGD training 的 training batches 的優勢。現有的方法首先随機的采樣圖像對或者三元組,建構訓練 batches, 計算每一個 pairs or triplets 的損失。本文提出一種方法,稱為:lifts,将 the vector of pairwise distances 轉換成 the matrix of pairwise distance. 然後在 lifts problem 上設計了一個新的結構損失目标。結果表明,在 GoogleLeNet network 上取得了比其他方法都要好的結果。 

  然後作者簡單的回顧了一下關于判别性訓練網絡(discriminatively training networks)來學習 semantic embedding。大緻結構預覽圖如下所示:

論文筆記之: Deep Metric Learning via Lifted Structured Feature Embedding

  首先是: Contrastive embedding. 

  這種方法在 paired data ${(x_i, x_j, y_{ij})}$上進行訓練。這種 contrastive training 最小化具有相同 label 類别的樣本之間的距離,然後對不同label的樣本,但是其距離小于 $\alpha$ 的 negative pair 給予懲罰。代價函數的定義為:

論文筆記之: Deep Metric Learning via Lifted Structured Feature Embedding

  其中,m 代表batch中圖像的個數,f(*)是網路輸出的特征,即原文中表達的:the feature embedding output from the network. $D_{i, j}$ 是兩個樣本特征之間歐式距離的度量。标簽 $y_{i, j} \in {0, 1}$表明是否樣本對來自同一個類别。$[*]_+$ 操作是 the hinge function max(0, *)。

  第二個是:Triplet embedding。

  這個就是著名的三元組損失函數了,即:找一個 anchor,然後找一個正樣本,一個負樣本。訓練的目的就是:鼓勵網絡找到一個 embedding 使得 xa and xn 之間的距離大于 xa and xp 加上一個 margin $\alpha$ 的和。損失函數定義為:

論文筆記之: Deep Metric Learning via Lifted Structured Feature Embedding

  其中,D仍然表示樣本之間特征的距離。

  然後就是本文提出的一種度量方法了:

  Deep metric learning via lifted structured feature embedding. 

   我們基于訓練集合的正負樣本,定義了一個結構化的損失函數:  

論文筆記之: Deep Metric Learning via Lifted Structured Feature Embedding

  其中,P 是正樣本的集合,N 是負樣本的集合。這個函數提出了兩個計算上的挑戰:

  1. 非平滑(non-smooth)

  2. 評價和計算其子梯度需要最小化所有樣本對若幹次。

  我們以兩種方式解決了上述挑戰:

  首先,我們優化上述函數的一個平滑上界;

  第二,對于大資料常用的方法類似,我們采用随機的方法。

  然而,前人的工作都是用SGD的方法,随機的均勻的選擇 pairs or triplets。我們的方法從這之中得到了借鑒:

    (1). it biases the sample towards including "difficult" pairs, just like a subgradient of $J_{i,j}$ would use the close negative pairs; 

  (2). 一次采樣就充分的利用了一個 mini-batch的全部資訊,而不僅僅是兩個pair之間的資訊。 

  為了充分的利用這個 batch,一個關鍵的 idea 是增強 mini-batch 的優化以利用所有的pairs。

  需要注意的是:随機采樣的樣本對之間的 negative edges 攜帶了非常有限的資訊。

  是以,我們的方法改為并非完全随機,而是引入了重要性采樣的元素。我們随機的采樣了一些 positive pairs,然後添加了一些他們的 difficult neighbors 來訓練 mini-batch. 這個增強增加了子梯度會用到的相關資訊。下圖展示了一個 positive pair 在一個 batch 中的搜尋過程,即:在一個 positive pair 的圖像中,我們找到其 close(hard)negative images。  

論文筆記之: Deep Metric Learning via Lifted Structured Feature Embedding

  注意到我們的方法可以從兩端開始搜尋,而三元組則僅僅隻能和定義好的結構上的元素進行搜尋。

論文筆記之: Deep Metric Learning via Lifted Structured Feature Embedding

   此外,搜尋 single hardest negative with nested max function 實際上會導緻網絡收斂到一個 bad local optimum. 是以我們采用了如下的 smooth upper bound,是以 我們的損失函數定義為:  

論文筆記之: Deep Metric Learning via Lifted Structured Feature Embedding

  其中,P是batch中 positive pairs 集合,N 是negative pairs 的集合。後向傳播梯度可以如算法1所示的那樣,對應距離的梯度為:

論文筆記之: Deep Metric Learning via Lifted Structured Feature Embedding

    其中的 1[*] 是訓示函數,如果括号内的判斷為真,那麼輸出為1,否則就是0. 

  本文的算法流程圖,如下所示:

論文筆記之: Deep Metric Learning via Lifted Structured Feature Embedding

  結果展示:

論文筆記之: Deep Metric Learning via Lifted Structured Feature Embedding
論文筆記之: Deep Metric Learning via Lifted Structured Feature Embedding
論文筆記之: Deep Metric Learning via Lifted Structured Feature Embedding
論文筆記之: Deep Metric Learning via Lifted Structured Feature Embedding

    文章總結:

  可以看出,本文是在三元組損失函數基礎上的一個改進。并非僅僅考慮預先定義好的樣本之間的差異性,而是考慮到一個 batches 内部 所有的樣本之間的差異。在這個過程中,文章中引入了類似 hard negative mining 的思想,考慮到正負樣本之間的難易程度。并且為了避免網絡的訓練陷入到 局部最優的bug中去,引入了損失函數的上界來緩解這個問題。

  一個看似不大的改動,卻可以發到CVPR,也從某個角度說明了這個方法的價值。

  難道,三元組損失函數就這樣被這個算法擊敗了? 自己當初看到三元組損失函數的時候,為什麼就沒有忘這個方向去思考呢???

  還有一個疑問是:為什麼這種方法的操作,稱為:lifted structured feature embedding ? 

  難道說,是因為這個左右移動的搜尋 hard negative samples 的過程類似于電梯(lift)?那 feature embedding 怎麼了解呢? embedding 是映射,難道是:特征映射麼??

論文筆記之: Deep Metric Learning via Lifted Structured Feature Embedding

繼續閱讀