对比学习论文综述【论文精读】

第一阶段 - 百花齐放
InstDisc (2018) - 提出实例判别和memory bank做对比学习 01:48
Title: Unsupervised Feature Learning via Non-Parametric Instance Discrimination

每一个 instance 都看成是一个类别

对于 ImageNet 数据集,一共有128万张图片,因此 Memory Bank 是一个 1280000*128 的数据矩阵

主要贡献:
- 提出 Instance Discrimination (个体判别) 代理任务
- 使用代理任务和 NCE Loss 进行对比学习,从而取得了不错的无监督表征学习结果
- 提出用 Memory Bank 这种数据结构来存储大量的负样本
- 提出基于 Momentum (动量) 的模型参数更新方法 (Proximal Regularization:给模型的训练加了一个约束,后续的 MoCo 的想法与其一致)

temperature $\tau=0.07$, number of negative samples $m=4096$, 200 epochs, SGD with momentum, batch size 256, learning rate 0.03
里程碑式的工作,对后续的 Contrastive Learning 工作起到了至关重要的推进作用
InvaSpread (CVPR 19) - 只使用一个编码器的 end-to-end (端到端)对比学习 07:01
Title: Unsupervised Embedding Learning via Invariant and Spreading Instance Feature

特点:不需要借助额外的数据结构去存储大量的负样本,正负样本来自同一个 minibatch (可以理解为 SimCLR 的前身)

invariant and spreading
batchsize: 256, positive samples: 256, negative samples: (256-1)*2
代理任务:Instance Discrimination (个体判别)
从同一个 minibatch 中选择正负样本,是为了可以用一个编码器做 end-to-end 训练,但同时为了保证模型性能,batch size必须设置得足够大
结果不够好的原因在于:负样本的数量不够多,所维护的由负样本组成的字典不够大
CPC v1 (2019) - 对比预测编码,图像语音文本强化学习全都能做 10:30
Title: Representation Learning with Contrastive Predictive Coding

代理任务:基于 Predictive (预测)的
将当前时刻和之前时刻的 inputs 分别喂入 encoders $g_{\text{enc}}$,将 encoders 输出的 features 喂入自回归模型 $g_{\text{ar}}$ (如 RNN, LSTM 等),最终得到当前时刻的output (context representation) $c_t$
如果所学到的 context representation 足够好,也即包含了当前和之前所有信息的话,那么它应该可以对未来时刻作出合理预测
positive samples: 未来时刻的特征输出, negative samples: 任意选择的时刻的特征输出
特点:通用的结构,适用于语音,文本,图像 (将序列想象成图片的 patch 块),非常灵活
CMC (2020) - 多视角下的对比学习 13:00
Title: Contrastive Multiview Coding

一个 object 的 multi-view 都可以当做是 positive sample
缺点是所需要的 encoders 过多
不仅证明了对比学习的灵活性,而且证明了这种多视角、多模态的可行性
Abstract:
Humans view the world through many sensory channels, e.g., the long-wavelength light channel, viewed by the left eye, or the high-frequency vibrations channel, heard by the right ear. Each view is noisy and incomplete, but important factors, such as physics, geometry, and semantics, tend to be shared between all views (e.g., a "dog" can be seen, heard, and felt).
人观察这个世界是通过很多个传感器,比如说眼睛或者耳朵都充当着不同的传感器来给大脑提供不同的信号。每一个视角都是带有噪声的,而且有可能是不完整的,但是最重要的那些信息其实是在所有的这些视角中间共享,比如说基础的物理定律、几何形状或者说它们的语音信息都是共享的,比如一个狗既可以被看见,也可以被听到或者被感受到
The classic hypothesis: a powerful representation is one that models view-invariant factors.
一个非常强大的特征,它具有视角的不变性(不管看哪个视角,到底是看到了一只狗,还是听到了狗叫声,都能判断出这是个狗)
Learn a representation that aims to maximize mutual information between different views of the same scene but is otherwise compact.
学习目标:增大所有的视角之间的互信息
The contrastive loss outperforms a popular alternative based on cross-view prediction, and that the more views we learn from, the better the resulting representation captures underlying scene semantics.
小结
- 代理任务:Instance Discrimination, predictive, multi-view, multi-modal
- 目标函数:NCE, InfoNCE, 和其他变体
- 模型架构:一个 encoder + memory bank (Inst Disc); 一个 encoder (Invariant Spread); 一个 encoder + 一个 auto regressive (CPC); 多个 encoders (CMC)
- 任务类型:图像,音频,文字,强化学习等
第二阶段 - CV双雄
MoCov1 (CVPR 2020) - 无监督训练效果也很好 18:28
Title: Momentum Contrast for Unsupervised Visual Representation Learning

将之前 Contrastive Learning 方法都归纳总结为字典查询问题
主要贡献:
- 队列 queue,使得 batch size 与 queue size 解耦,可以维护一个又大又一致的字典
- momentum encoder
SimCLRv1 (ICML 2020) - 简单的对比学习 (数据增强 + MLP head + 大batch训练久) 23:00
Title: A Simple Framework for Contrastive Learning of Visual Representations


positive samples: batchsize, negative samples: 2*(batchsize-1)
encoder $f(\cdot)$ 共享权重
增加了 projection head $g(\cdot)$,并且只用于 training,不用于 downstream tasks

主要贡献:
- Composition of multiple data augmentation operations is crucial in defining the contrastive prediction tasks that yield effective representations. In addition, unsupervised contrastive learning benefits from stronger data augmentation than supervised learning. 使用了更多的 data augmentation (数据增强) 方法
- Introducing a learnable nonlinear transformation between the representation and the contrastive loss substantially improves the quality of the learned representations. 非线性变换,在编码器后加一层 MLP
- Representation learning with contrastive cross entropy loss benefits from normalized embeddings and an appropriately adjusted temperature parameter. 正则化 + tenperature 参数
- Contrastive learning benefits from larger batch sizes and longer training compared to its supervised counterpart. Like supervised learning, contrastive learning benefits from deeper and wider networks. 训练更大的 batchsize,训练时间更久

Linear: projection head without ReLU
Non-Linear: the whole projection head
None: without projection head
- 使用 Non-Linear,相比原来什么都不用,结果提升了十几个点,效果非常显著 (原因不明)
- 最后的维度不论是 32, 64 还是 2048 其实都没太大区别 (为什么大多选择较低的特征维度,因为128就够了)
MoCov2 (2020) 31:00
Title: Improved Baselines with Momentum Contrastive Learning
MoCov1 + improvements from SimCLRv1


SimCLRv2 (2020) - 大的自监督预训练模型很适合做半监督学习 36:15
Title: Big Self-Supervised Models are Strong Semi-Supervised Learners

主要改进:
- 将 backbone network 从 ResNet-50 换成 ResNet-152,并配备3倍宽度的 channels 和 selective kernels (SK) net
- 将 projection head 从一层 MLP 换成两层 MLP
- 使用 momentum encoder
受启发与 google 的 noisy student 的工作
SWaV (NeurIPS 2020) - 聚类对比学习 40:24
Title: Unsupervised Learning of Visual Features by Contrasting Cluster Assignments

使用聚类的好处:
- 如果与每一个 instance-like 的负样本去做对比,则需要成千上万个负样本,而且即使如此也只是近似;相反,如果是与 cluster centers 做对比,在 ImageNet 上使用几百或者最多3000个 cluster centers 足矣
- cluster centers 具有明确的语义含义,相比较于在 instance-like 的负样本中 random sampling 会碰到如某些正样本也会被 sampling 和样本类别不均衡等问题,不如使用 cluster centers 有效

Multi-Crop: 全局特征 + 局部特征

推荐阅读:Deep Cluster, Deep Cluster 2
CPC v2 (ICML 2020) 49:58
Title: Data-Efficient Image Recognition with Contrastive Predictive Coding
Improvements:
- Model Capacity
- Layer Normalization
- Predicting lengths and directions
- Patch-based Augmentation:
InfoMin (NeurIPS 2020) 50:30
Title: What Makes for Good Views for Contrastive Learning
主要为分析型延伸工作,Minimize Mutual Information。主要观点是合适的 Mutual Information 很重要
提出了一个新的 InfoMin Principle,其目的是使特征表示在学到不同 view 之间共享的信息之外,尽量去除与下游任务无关的冗余信息来保证学习到的特征表示具有好的泛化能力。
引入三个定义:
- Sufficient Encoder
- Minimal Sufficient Encoder
- Optimal Representation of a Task
小结
目标函数:类 infoNCE
模型:一个 encoder + projection head
more strongly data augmentation
momentum encoder
训练更久
ImageNet 上的 accuracy 逼近有监督的 baseline
第三阶段-不用负样本
BYOL (2020) - 不需要负样本的对比学习 52:31
Title: Bootstrap your own latent: A new approach to self-supervised Learning

目标函数:

针对BYOL的博客 (https://generallyintelligent.com/research/2020-08-24-understanding-self-supervised-contrastive-learning) 和他们的回应 (https://arxiv.org/pdf/2010.10241.pdf)
SimSiam (CVPR 2021) - 化繁为简的孪生表征学习 01:09:31
Title: Exploring Simple Siamese Representation Learning


没有使用 (i) negative sample pairs, (ii) large batches, (iii) momentum encoders
猜测 stop gradient 机制是至关重要的
Hypothesis: SimSiam is an implementation of an Expectation-Maximization (EM) like algorithms.


Barlow Twins (ICML 2021) 01:16:26
Title: Barlow Twins: Self-Supervised Learning via Redundancy Reduction
既没有作对比,也没有作预测,本质上是换了一个目标函数。
具体而言,是生成 Cross Correlation Matrix (关联矩阵),希望该矩阵与 Identity Matrix 尽可能相似
第四阶段-基于 Transformer
MoCov3 (CVPR 2021) - 如何更稳定的自监督训练ViT 01:17:23
Title: An Empirical Study of Training Self-Supervised Vision Transformers



DINO - transformer加自监督在视觉也很香 01:23:10
Title: Emerging Properties in Self-Supervised Vision Transformers



总结 01:25:53
