论文解读(MoCo v2)《Improved Baselines with Momentum Contrastive Learning》

  论文题目:《Improved Baselines with Momentum Contrastive Learning》

  论文作者: Xinlei Chen Haoqi Fan Ross Girshick Kaiming He  

  论文来源:arXiv

  论文代码:https://github.com/facebookresearch/moco

  论文链接:https://arxiv.org/abs/2003.04297

1 概述

  SimCLR对 end-to-end 的改进:

  • 可以提供更多负样本的大得多的批次(4k或8k);
  • 使用 MLP projection head 代替 $F_c$  projection head ;
  • 更强的数据增强。

  SimCLR 的批次为 4-8K,需要 TPU 支持。MoCo v2无需 SimCLR 一样超大 batch size,普通 8-GPU 即可训练。  
  MoCo V2 融合了 MoCo V1 和 SimCLR, 是二者的集大成者,并且全面超越SimCLR。
  MoCo V2 吸收了 SimCLR 的两个重要改进。

  • 使用 MLP projection head 代替 $F_c$  projection head ;
  • 使用更多的数据增强手段;

 知识点:

  Fully Connected(FC) Layer = 一层layer

  MLP = 多层 FC layer 构成的NN

  DNN = MLP 和 CNN的集合相并,通常包括多个卷积layer和FC layer

2 Improved designs

  回顾 MoCo v1 模型:

        

  MoCo 步骤:
  对于每个batch x:

  1. 随机增强出 $x^{q} 、 x^{k} $ 两种 view ;
  2. 分别用 $f_{q} $ , $ f_{k} $ 对输入进行编码得到归一化的 $q $ 和 $ mathrm{k} $ , 并去掉 $mathrm{k} $ 的梯度更新 ;
  3. 将 $mathrm{q} $ 和 $mathrm{k} $ 中的唯一一个正例做点积得 cosine相似度 ($mathrm{Nx} 1$) , 再将 $mathrm{q}$ 和队列中存储的K个负样本做点积得 cosine相似度 ($mathrm{NxK}$) , 拼接起来的到 $mathrm{Nx}(1+mathrm{K}) $ 大小 的矩阵, 这时第一个元素就是正例,直接计算交叉摘损失, 更新 $f_{q}$ 的参数;
  4. 动量更新 $f_{k} $ 的参数: $ f_{k}=m * f_{k}+(1-m) * f_{q} $;
  5. 将 $ mathrm{k}$ 加入队列,把队首的旧编码出队,负例最多时有 65536 个。

  在MoCo框架中,大量的负样本是现成的;MLP头部和数据增强与对比学习的实例化方式是正交的。

  MoCo v2 框架

  

  将 MoCo 网络结构中经过卷积层后的一层线性MLP扩展为两层非线性的MLP,使用ReLU激活函数。该方法在 SimCLR 中使用。
  在 Data Argumentation中,增加使用 Blur augmentation 来进行数据增光。但 color distortion 并未取得很好的效果。

3 实验 

  

  Table 1. Ablation of MoCo baselines, evaluated by ResNet-50 for (i) ImageNet linear classification, and (ii) fine-tuning VOC object detection (mean of 5 trials). “MLP”: with an MLP head; “aug+”: with extra blur augmentation; “cos”: cosine learning rate schedule.
  采用1:添加 MLP 2:添加数据增强(数据模糊) 3:采用余弦衰减学习率 4:调整 epochs 大小 这4种策略,和 MoCo v1 做对比。在ImageNet 和 VOC 微调上得到显著提升。

  

  Table 2. MoCo vs. SimCLR: ImageNet linear classifier accuracy (ResNet-50, 1-crop 224×224), trained on features from unsuper￾vised pre-training. “aug+” in SimCLR includes blur and stronger color distortion. SimCLR ablations are from Fig. 9 in [2] (we thank the authors for providing the numerical results).
  MoCo vs. SimCLR 在ImageNet 线性分类的准确率对比,显然 MoCo v2 胜出。

  

  Table 3. Memory and time cost in 8 V100 16G GPUs, implemented in PyTorch. : based on our estimation.
  比较 MoCo 和end-to-end 的效率。

因上求缘,果上努力~~~~ 作者:每天卷学习,转载请注明原文链接:https://www.cnblogs.com/BlairGrowing/p/15026396.html

原文地址:https://www.cnblogs.com/BlairGrowing/p/15026396.html