# SimCLR ###### tags: `self-sup` ## 概述 作者提出 **SimCLR** 技術,一種 self-supervised 訓練的方法,作者有以下發現: 1. **資料增強組合** 對預測任務表現有顯著影響 2. 在 **Representation** 與 **Contrastive Loss** 間引進非線性轉換,這樣可提高 Representation 的品質 3. **大 batch size** 與更多的訓練步數能提升對比學習任務的表現。 實驗顯示,使用 SimCLR 訓練出來的 Representation 用線性分類器在 ImageNet 上有 76.5% (**ResNet50**) 的 top-1 accuracy;僅用 1% 的 ImageNet 標籤 finetune 情況下,模型取得 85.8% 的 top-5 accuracy。  ## 方法  #### 架構 1. **Stochastic Data Augmentation**:使用不同的 augmentation 作用在同一張圖片上,產生 $\tilde{x_i}$, $\tilde{x_j}$,彼此將作為 **positive pair**。 2. **Base Encoder**:負責抽取圖片的特徵。 3. **Projection Head**:將抽取的特徵向量映射到要作用 Contrastive loss 的空間。 $$ z_i = g(h_i) = W^{(2)} \sigma(W^{(1)} h_i) $$ 其中 $\sigma$ 為 **ReLU** 函數。 4. **Contrastive Loss function**:給定集合 $\{\tilde{x}_k\}$,集合包含 **positive pair** 樣本 $\tilde{x}_i$, $\tilde{x}_j$,在給定 $\tilde{x}_i$ 情況下,**contrastive prediction task** 的目標是在 $\{\tilde{x}_k\}_{k \neq i}$ 中找出 $\tilde{x}_j$。定義 **positive pair** $(i, j)$ 的損失函數為 $$ l_{(i, j)} = -\log \frac{\exp(sim(z_i, z_j)/\tau)}{\sum_{i=1}^{2N} \mathbb{I}_{[k \neq i]} \exp(sim(z_i, z_k)/\tau)}, $$ 其中 $sim(u, v)= \frac{u^T v}{\|u\| \|v \|}$. :::info This loss, called NT-Xent, has been used in previous work. :::  #### 使用大 batch size 作者使用的 batch size 範圍介於 **256-8192 之間**,並使用 **LARS 優化器**。 #### GLOBAL BN ## 資料增強  作者嘗試了各種不同的資料增強方法,並比較其對於訓練的效果,因為 ImageNet 上的圖片大小並非一致,作者會先對圖片進行 **crop** 與 **resize**,接著**僅會對其中一個分支的圖片進行 augmentation 轉換**,另一個分支的圖片不進行轉換,實驗顯示,**單種 augmentation 轉換不利於學習好的 Representation**,另外,**random cropping + random color distortion** 在所有組合種表現最突出。  作者還嘗試了 **不同強度的 color augmentation** 對預測任務的影響,結果顯示,color augmentation 強度的增加能加強 Representation 的品質;相反地,supervised learning 任務並不會隨著 color augmentation 強度的增加,而使得訓練效果變得更好。  :::info self-supervised learning 任務更依賴強的 augmentation ::: ## 模型架構 1. **模型大小**:實驗顯示 (如下圖),相比於 supervised learning,unsupervised learning 任務會更傾向大模型。  2. **Nonlinear Projection Head 提升 Representation 品質**:作者研究 projection head $h$ 的重要性,作者實驗了三種 **head**: + **Identity mapping** + **Linear projection** + **Default nonlinear projection with one additional hidden layer** 實驗顯示,**nonlinear projection head** 的效果最好,值得注意的是,即使使用 nonlinear projection head,**head 前的 Representation $h$ 品質會更好**。作者表示 $z = g(h)$ 的訓練目標是 **invariant to data transformation**,因此 $g$ 會移除 Representation 的一些資訊,包含顏色、方向等資訊,使得 Representation 在下游任務上表現較差。 :::info 引進 $g$ 就是為了保留 data transfromation 的資訊 :::   ## Batch size  作者實驗了不同 batch size 對結果的影響,當訓練 epoch 數少的時候,大 batch size 對於結果有顯著影響,隨著 epoch 數增大,batch size 對結果影響程度有所下降,作者表示,大 batch size 意味著更多的 negative examples,這樣能夠加速收斂,訓練更長 (epoch 提升),同樣也會看到跟多 negative examples,並提升表現。 ## 參考連結 1. [論文](https://arxiv.org/pdf/2002.05709.pdf)
×
Sign in
Email
Password
Forgot password
or
By clicking below, you agree to our
terms of service
.
Sign in via Facebook
Sign in via Twitter
Sign in via GitHub
Sign in via Dropbox
Sign in with Wallet
Wallet (
)
Connect another wallet
New to HackMD?
Sign up