A Simple Framework for Contrastive Learning of Visual Representations

Ting Chen, Simon Kornblith, Mohammad Norouzi, Geoffrey Hinton

2020 · ICML

A Simple Framework for Contrastive Learning of Visual Representations

Problem

Framing

Contrastive image pretraining lagged supervised ImageNet features because objective choice, augmentation design, and architecture coupling were entangled. SimCLR closes this gap with a minimal recipe: two stochastic views, a projection head, and temperature-scaled contrastive loss, reaching 76.5% top-1 linear evaluation on ImageNet with ResNet-50.

Currently Used Methods

Foundational

Proposed Method

Architecture

SimCLR applies two random augmentations t,tTt, t' \sim \mathcal{T} to each image xx, encodes both views with a shared base network f()f(\cdot), then maps features hh to contrastive embeddings zz with a projection head g()g(\cdot). The downstream representation is the pre-projection vector hh; the paper reports a nonlinear 2-layer MLP head improves it.

Two augmented views pass through a shared encoder f(\cdot) and projection head g(\cdot); contrastive loss acts on z, downstream tasks use h.

Loss / Objective

The paper trains on ordered positive pairs within a 2N2N-view minibatch using NT-Xent.

(i,j)=logexp(sim(zi,zj)/τ)k=12N1[ki]exp(sim(zi,zk)/τ)\ell(i,j) = - \log \frac{\exp\left(\mathrm{sim}(\mathbf{z}_i, \mathbf{z}_j)/\tau\right)}{\sum_{k=1}^{2N} \mathbf{1}_{[k \neq i]} \exp\left(\mathrm{sim}(\mathbf{z}_i, \mathbf{z}_k)/\tau\right)} L=12Nk=1N[(2k1,2k)+(2k,2k1)]\mathcal{L} = \frac{1}{2N} \sum_{k=1}^{N} \left[ \ell(2k-1,2k) + \ell(2k,2k-1) \right]

Algorithm

Each minibatch draws two stochastic views per image, computes 2N2N embeddings, and optimizes the symmetric contrastive loss over all positive pairs.

x~2k1=t(xk),x~2k=t(xk),hi=f(x~i),zi=g(hi)\tilde{\mathbf{x}}_{2k-1} = t(\mathbf{x}_k), \quad \tilde{\mathbf{x}}_{2k} = t'(\mathbf{x}_k), \quad \mathbf{h}_i = f(\tilde{\mathbf{x}}_i), \quad \mathbf{z}_i = g(\mathbf{h}_i)

Training Procedure

Evaluation

Datasets

Metrics

Headline results

Results plot comparing SimCLR models against prior self-supervised methods and supervised baselines; larger models move steadily upward in ImageNet linear accuracy.

Ablations

Table 1: Effect of color distortion strength and blur on ImageNet top-1 accuracy

Methods1/81/41/211 (+Blur)AutoAug
SimCLR59.661.062.663.264.561.1
Supervised77.076.776.575.775.477.1

Method Strengths and Weaknesses

Strengths

Weaknesses

Suggestions from the authors

Links

Prior Papers

Further Papers