Self-Supervised Vision

Suppose you have one hundred million unlabeled photographs and only ten thousand labels. Supervised learning throws away the ninety-nine million unlabeled images. This wastes almost all the available signal. Self-supervised vision asks a sharper question. Can a model learn useful structure from pixels alone? Can it do this before ever seeing a label? It would do so by solving a task it invents from the data itself. The idea is to design a pretext task. Its solution requires understanding shape, texture, object parts, and scene layout. This holds even though the task's literal answer is meaningless. A model trained to decide whether two crops came from the same photo is implicitly forced to build representations that generalize. The same is true for a model that fills in a masked patch of an image. Those representations can then be reused for real downstream tasks — classification, detection, segmentation. This usually happens with a small linear layer or a brief fine-tuning pass on the scarce labeled data. This matters because labels are expensive. They are also biased by whatever taxonomy the labeler had in mind. Raw pixels, by contrast, are nearly free. Self-supervised pretraining is now the default first stage for state-of-the-art vision backbones. This mirrors what masked-language-model pretraining did for NLP. Contrastive methods (SimCLR, MoCo) and masked-image methods (BEiT, MAE) are the two dominant families. Modern systems such as DINOv2 blend ideas from both. This article builds the two families from first principles. It covers the losses, the architectural tricks that prevent them from cheating (collapse), the computational cost. It also covers the empirical evidence for why the resulting features transfer. It assumes familiarity with Vision Transformers and Data Augmentation for Vision. It explains precisely what "self-supervised" buys you. It also explains where it still falls short of supervised pretraining at scale.

Key takeaways
  • Self-supervised vision learns representations from unlabeled images by solving an invented pretext task.
  • Contrastive methods (SimCLR, MoCo) pull augmented views of the same image together and push different images apart.
  • Masked-image methods (BEiT, MAE) hide patches and train a model to reconstruct them, forcing semantic inference.
  • A key engineering problem is representation collapse: architectures use negatives, momentum encoders, or asymmetric predictors to avoid it.
  • Quality is measured by transfer: linear probing or fine-tuning on labeled downstream tasks (ImageNet, detection, segmentation).
  • Self-supervised pretraining now matches or beats supervised pretraining on many benchmarks, especially with large unlabeled corpora.
The core insight

Design a task solvable only by understanding image content, and let representations that solve it transfer to real vision problems.

The idea

A pretext task is a supervised-looking problem whose labels are generated automatically from unlabeled data, rather than by a human annotator. The two dominant pretext families for images are contrastive learning and masked image modeling. In contrastive learning, two random augmentations of the same image (a crop, a color jitter, a blur) are treated as a positive pair, while views from different images are negative pairs. The network is trained so that positive pairs map to nearby points in an embedding space and negative pairs map to far-apart points, typically via a temperature-scaled softmax loss called the InfoNCE loss. The implicit hypothesis is that if a representation is invariant to the augmentations (which preserve semantic content) while remaining discriminative across images (which have different content), it has captured something close to "what the image is about." In masked image modeling (MIM), a large fraction of image patches — commonly 40–75% — is hidden, and the network must predict the missing content, either as raw pixels (as in MAE, Masked Autoencoders) or as discrete visual tokens produced by a separate tokenizer (as in BEiT). This mirrors masked language modeling in NLP but requires care: images are far more redundant locally than text, so trivial interpolation from neighboring pixels can solve the task without learning semantics unless the masking ratio is aggressive and the architecture is chosen carefully. Both families share a deeper commonality: they are instances of predictive self-supervision, where part of the input is used to predict another part (a different view, or the hidden pixels), forcing the network to model statistical dependencies that reflect scene structure — occlusion, object continuity, and part-whole relationships — without ever needing a semantic label. The universal failure mode to guard against is collapse, where the network finds a degenerate shortcut (e.g., mapping every image to the same constant vector, trivially satisfying an invariance loss) instead of learning anything useful; much of the architectural cleverness in this area exists purely to prevent collapse.

How it works

Contrastive learning: SimCLR

SimCLR is the cleanest instantiation of instance discrimination. Given a batch of NN images, each image is augmented twice to produce 2N2N views. For each view, its only true positive is the other view of the same source image; all other 2N−22N-2 views in the batch serve as negatives. The encoder ff (a ResNet or ViT) maps a view to a representation, and a small projection head gg maps that representation into the space where the contrastive loss is applied — the projection head is discarded after pretraining, and only ff's output is used downstream. ```

# SimCLR pretraining, one step

# batch: N images x_1 ... x_N (no labels)

# f: encoder, g: projection head, tau: temperature for each image x_i in batch: v_i,a = augment(x_i) # random crop, color jitter, blur, flip v_i,b = augment(x_i) # a second, independent augmentation views = [v_1,a, v_1,b, v_2,a, v_2,b, ..., v_N,a, v_N,b] # 2N views for each view v_k in views: h_k = f(v_k) # backbone representation z_k = normalize(g(h_k)) # projected, L2-normalized embedding loss = 0 for each view v_k with positive partner v_pos(k): numerator = exp(sim(z_k, z_pos(k)) / tau) denominator = sum over all j != k of exp(sim(z_k, z_j) / tau) loss += -log(numerator / denominator) loss = loss / (2N) backpropagate(loss) update(f, g) ``` Here `sim(a, b) = dot(a, b)` on L2-normalized vectors, i.e. cosine similarity. This is the InfoNCE loss: it is precisely a 2N2N-way classification loss where the correct class for each view is its positive partner. Larger batch size NN means more negatives per positive, which empirically improves the learned representation up to very large batch sizes (SimCLR used batches of 4096–8192), because more negatives give a sharper contrastive signal and reduce the variance of the softmax denominator.

Contrastive learning without giant batches: MoCo

Large batches require large accelerators. MoCo (Momentum Contrast) decouples the number of negatives from the batch size by maintaining a queue of negative embeddings computed in previous steps, plus a momentum encoder that updates slowly to keep the queue's embeddings consistent with the current query encoder. ```

# MoCo pretraining, one step

# f_q: query encoder (trained by gradient descent)

# f_k: key encoder (momentum-updated, no gradient)

# queue: FIFO buffer of K negative embeddings, K >> batch size

# m: momentum coefficient, e.g. 0.999 for each image x_i in batch: q_i = normalize(f_q(augment(x_i))) # query view with no_grad(): k_i = normalize(f_k(augment(x_i))) # key view, same source image logits_i = [ dot(q_i, k_i) ] + [ dot(q_i, n) for n in queue ] labels_i = 0 # the key k_i is always the correct (first) entry loss = cross_entropy(logits_i / tau, labels_i), averaged over batch backpropagate(loss) # gradient flows only through f_q update(f_q)

# momentum update (no gradient) f_k.weights = m f_k.weights + (1 - m) f_q.weights enqueue(k_i for all i); dequeue oldest entries to keep queue size K ``` The momentum update is the crux: if fkf_k were updated by gradient descent as fast as fqf_q, the embeddings already sitting in the queue would become stale relative to the current fqf_q, and the contrastive comparison would be inconsistent. A slowly-moving momentum encoder keeps the queue's negatives "fresh enough" while decoupling the negative pool size KK (tens of thousands) from the GPU batch size (hundreds).

Avoiding collapse without negatives: BYOL and SimSiam intuition

A subtlety: if you remove negatives entirely and only train the network to make two augmented views agree, the trivial optimum is a constant function — map every image to the same vector, and the agreement loss is zero. BYOL and SimSiam prevent this collapse using an asymmetric architecture (a predictor head on one branch only, stop-gradient on the target branch, and for BYOL a momentum target encoder) rather than negatives. The stop-gradient breaks the trivial constant-solution equilibrium: because the target branch is never updated to make the loss easier from its own side, the only way for the online branch to reduce loss is to genuinely predict the target's (non-trivial, momentum-averaged) representation.

Masked image modeling: MAE

MAE (Masked Autoencoders) exploits the ViT's patch structure directly. A large fraction of patches (typically 75%) is dropped before the encoder ever sees them — not masked-with-a-special-token, but physically removed — which makes the encoder pass cheap, since it only processes 25% of the tokens. ```

# MAE pretraining, one step

# image split into P patches, patch_embed: linear projection + position embedding

# encoder: ViT operating only on visible tokens

# decoder: lightweight ViT that sees visible tokens + mask tokens patches = split_into_patches(image) # P patches total mask_ids, visible_ids = random_partition(P, keep_ratio=0.25) visible_tokens = [ patch_embed(patches[i]) for i in visible_ids ] encoded = encoder(visible_tokens) # only 25% of tokens processed

# reinsert mask tokens (a single shared learned vector) at masked positions,

# add positional embeddings so decoder knows WHERE each token belongs decoder_input = combine(encoded, mask_token, visible_ids, mask_ids, positions) decoded = decoder(decoder_input) # full-length sequence predicted_pixels = linear_head(decoded) # per-patch pixel prediction loss = 0 for i in mask_ids: loss += mean_squared_error(predicted_pixels[i], normalize(patches[i])) loss = loss / len(mask_ids) # loss computed ONLY on masked patches backpropagate(loss) update(encoder, decoder)

# after pretraining: discard decoder, keep encoder for downstream tasks ``` Two design choices matter enormously for correctness of the pretext task. First, computing the loss only on masked patches (not visible ones) forces the network to actually infer content rather than get credit for copying visible input. Second, the very high masking ratio (75%) removes the redundancy shortcut: with low masking, a masked patch can often be interpolated trivially from adjacent visible patches (since natural images are locally smooth), so the network never needs to learn global semantic structure. At 75% masking, patches are typically far from any visible patch, so successful reconstruction requires the encoder to represent object identity, shape, and layout, not just local texture continuity.

Masked image modeling with a tokenizer: BEiT

BEiT instead predicts discrete visual tokens rather than raw pixels. A separately pretrained discrete tokenizer (e.g., a VQ-VAE-style encoder) first converts the image into a grid of discrete codes; masked patches are then predicted as a classification problem over the token vocabulary, analogous to masked language modeling over a word vocabulary. This sidesteps a subtlety of pixel-level reconstruction (that pixel-space MSE loss can over-reward blurry, low-frequency-correct predictions) by making the target a genuinely discrete, semantically pooled quantity.

Figure
Two pretext-task families for self-supervised vision: contrastive instance discrimination and masked image modeling
Contrastive (SimCLR/MoCo) image x aug view A aug view B f(·) → z_A f(·) → z_B pull together embedding space: green = same image, red = other images (push apart) Masked Image Modeling (MAE/BEiT) blue = visible, gray = masked (75%) Encoder (ViT) sees only visible tokens Decoder visible tokens + shared mask tokens red = reconstructed patches Loss (MIM) is computed only over the reconstructed (masked) patches — not the visible ones. Loss (contrastive) is computed over all pairs in the batch via a softmax over similarities (InfoNCE). Discarded after pretraining: contrastive projection head g(·); MIM decoder. Kept: the encoder f(·).

Complexity & correctness

SimCLR / contrastive time and space. For a batch of NN images producing 2N2N views, computing all pairwise similarities is O((2N)2d)O((2N)^2 d) where dd is the embedding dimension, since the InfoNCE denominator requires a similarity between every pair of views. This is negligible next to the cost of the encoder forward/backward pass, which is O(N⋅C)O(N \cdot C) for per-image encoder cost CC (for a ResNet-50, CC is on the order of 4×1094 \times 10^9 FLOPs; for a ViT, CC scales roughly with the square of the number of patches due to self-attention). Memory is dominated by storing 2N2N activations for backpropagation, which is why large-batch contrastive training needs large accelerator memory or gradient checkpointing.

MoCo time and space. The queue holds KK negative embeddings of dimension dd, costing O(Kd)O(Kd) memory — cheap, since KK is tens of thousands and dd is a few hundred, versus recomputing KK forward passes every step. The per-step compute is O(N⋅C)O(N \cdot C) for the batch (only the query encoder needs gradients; the momentum encoder's forward pass is gradient-free but still costs a forward pass, roughly doubling per-step forward compute versus a plain encoder but not adding any backward compute for fkf_k).

MAE time and space. Because only the visible fraction ρ\rho (e.g., ρ=0.25\rho = 0.25) of PP patches is passed to the encoder, encoder compute scales as O(ρP⋅(ViT layer cost))O(\rho P \cdot \text{(ViT layer cost)}) instead of O(P⋅(ViT layer cost))O(P \cdot \text{(ViT layer cost)}). Since self-attention cost within a ViT layer is O(P2d)O(P^2 d) for sequence length PP, dropping to ρP\rho P tokens reduces this term to O(ρ2P2d)O(\rho^2 P^2 d) — a quadratic saving, roughly a 16× reduction in attention FLOPs at ρ=0.25\rho=0.25. This is why MAE pretraining is markedly cheaper per step than encoding full images, despite using very deep ViT backbones.

Why contrastive learning doesn't just collapse (informally). The InfoNCE loss is a lower bound related to mutual information between the two views' representations; minimizing it maximizes a bound on I(zA;zB)I(z_A; z_B) subject to the representation staying discriminative across the negatives in the batch, because the softmax denominator explicitly penalizes any representation where negatives look similar to the anchor. A constant embedding function trivially satisfies "positives agree" but catastrophically fails "negatives disagree," since every negative similarity would then also be maximal, making the denominator huge and the loss large — collapse is therefore not a minimum of the InfoNCE loss, unlike a naive squared-distance-only objective. This is the formal reason negatives are structurally necessary in this family (or an asymmetric predictor/stop-gradient substitute is needed, as in BYOL/SimSiam, to break the same trivial optimum by other means).

Why MAE's masked prediction forces semantics (informally). With masking ratio ρmask=0.75\rho_{mask} = 0.75, the expected distance from a masked patch to its nearest visible neighbor is large relative to the spatial correlation length of natural images (local smoothness typically decays within a few patches), so low-level interpolation is insufficient. The reconstruction loss can then only be driven down by the encoder producing a representation that encodes higher-level regularities — object shape, symmetry, category-typical texture — that generalize past the immediate neighborhood, because that is the only remaining source of predictive signal once local smoothness is exhausted.

Correctness of transfer (what "correctness" even means here). There is no formal proof that self-supervised features are optimal for a downstream task; the field's evidence is empirical: linear probing (freeze the encoder, train only a linear classifier on top) and fine-tuning accuracy on ImageNet, and mAP on detection/segmentation benchmarks, consistently show that contrastive and MIM pretraining transfer competitively with, and sometimes exceed, supervised pretraining, especially when downstream labels are scarce or when the downstream distribution differs from the label taxonomy used in supervised pretraining. The honest tradeoff: contrastive methods tend to produce features that are strong for global, instance-level tasks (classification) but historically weaker at dense/local tasks without extra tricks, while MIM tends to produce features stronger for dense prediction (detection, segmentation) since the reconstruction task is inherently local-and-global, but MIM features are often weaker under a linear probe (they need fine-tuning to shine), because the pretext task never explicitly enforces linear separability of instances the way instance discrimination does.

Worked example

Trace a single SimCLR-style step with a tiny toy batch of N=3N = 3 images (a cat, a dog, and a car), embedding dimension d=2d = 2 for visualization, temperature τ=0.5\tau = 0.5. Suppose after augmentation and the encoder+projection head, the six L2-normalized embeddings (two per image) are:

viewimageembedding (x,y)(x, y)
z1az_{1a}cat, view A(0.98,0.20)(0.98, 0.20)
z1bz_{1b}cat, view B(0.95,0.31)(0.95, 0.31)
z2az_{2a}dog, view A(0.10,0.99)(0.10, 0.99)
z2bz_{2b}dog, view B(0.20,0.98)(0.20, 0.98)
z3az_{3a}car, view A(−0.99,0.14)(-0.99, 0.14)
z3bz_{3b}car, view B(−0.95,0.31)(-0.95, 0.31)

For anchor z1az_{1a} (cat, view A), compute cosine similarity to all five other views (dot product, since vectors are already unit-normalized):

comparisondot product/τ=/0.5/\tau = /0.5exp⁡(⋅)\exp(\cdot)
z1a⋅z1bz_{1a}\cdot z_{1b} (positive)0.98(0.95)+0.20(0.31)=0.9930.98(0.95)+0.20(0.31) = 0.9931.9867.288
z1a⋅z2az_{1a}\cdot z_{2a}0.98(0.10)+0.20(0.99)=0.2960.98(0.10)+0.20(0.99) = 0.2960.5921.808
z1a⋅z2bz_{1a}\cdot z_{2b}0.98(0.20)+0.20(0.98)=0.3920.98(0.20)+0.20(0.98) = 0.3920.7842.190
z1a⋅z3az_{1a}\cdot z_{3a}0.98(−0.99)+0.20(0.14)=−0.9420.98(-0.99)+0.20(0.14) = -0.942-1.8840.152
z1a⋅z3bz_{1a}\cdot z_{3b}0.98(−0.95)+0.20(0.31)=−0.8690.98(-0.95)+0.20(0.31) = -0.869-1.7380.176

InfoNCE loss contribution for anchor z1az_{1a}:

L1a=−log⁡7.2887.288+1.808+2.190+0.152+0.176=−log⁡7.28811.614=−log⁡(0.6275)≈0.466\mathcal{L}_{1a} = -\log \frac{7.288}{7.288 + 1.808 + 2.190 + 0.152 + 0.176} = -\log \frac{7.288}{11.614} = -\log(0.6275) \approx 0.466

This is a small loss (probability ≈0.63\approx 0.63 assigned to the correct positive out of five candidates), reflecting that the cat's two augmented views are indeed much more similar to each other (dot product 0.9930.993) than to any other image's views (all ≤0.392\le 0.392, and strongly negative for the car). The same computation is repeated for each of the other five anchors, and the six per-anchor losses are averaged to get the batch loss, whose gradient then pushes z1az_{1a} and z1bz_{1b} marginally closer together and pushes them marginally further from the dog and car embeddings — exactly the intended contrastive update. Notice that the dog embeddings, despite being a different image, are noticeably closer to the cat embeddings (≈0.3\approx 0.3–0.40.4) than the car embeddings (≈−0.9\approx -0.9); a well-trained representation is expected to reflect exactly this kind of coarse visual/semantic similarity structure among negatives, even though the loss only explicitly requires negatives to be pushed away, not ranked by similarity. Now trace one MAE reconstruction step on a 4×44\times4-patch toy image (16 patches, so with ρmask=0.75\rho_{mask}=0.75, 12 patches are masked and 4 remain visible). The encoder receives only the 4 visible-patch embeddings plus their positions; suppose these are patches at grid positions (0,0),(1,3),(2,1),(3,2)(0,0), (1,3), (2,1), (3,2) — scattered, not clustered, which is typical of MAE's uniform random masking and is itself intentional (block masking would leave large uninterpolatable holes but also correlated, easier local cues at the hole's boundary, whereas scattered masking forces genuinely non-local inference across most of the image). The decoder reinserts the shared mask token at the 12 masked positions, combined with position embeddings so it knows where each unknown patch is, and predicts pixel values for all 16 patches, but the MSE loss is computed only over the 12 masked positions — the 4 visible positions contribute zero loss, since the decoder trivially could just copy them and that offers no training signal about the encoder's semantic quality.

Common pitfalls & traps

PitfallWhy it happensFix
Representation collapse (contrastive)Symmetric loss with no negatives and no asymmetry lets the network map everything to a constantUse negatives (SimCLR/MoCo) or a predictor + stop-gradient + momentum target (BYOL/SimSiam)
Masking ratio too low in MIMLow masking lets the model interpolate locally instead of learning semanticsUse aggressive masking (~75% for MAE); validate via ablation on downstream accuracy
Comparing linear-probe accuracy across methods without matching protocolProbe learning rate, epochs, augmentation strongly affect probe accuracy independent of encoder qualityUse standardized eval protocols (fixed probe recipe) before claiming method A beats method B
Treating augmentation choice as neutralContrastive methods are extremely sensitive to which augmentations are used; e.g. omitting color jitter lets the model shortcut on color histogramsUse a strong, validated augmentation stack (random-resized crop + color jitter + blur + flip) and never assume augmentations transfer across domains unchanged
Momentum coefficient / EMA rate mis-setToo fast an EMA update reintroduces staleness/collapse risk; too slow wastes early training signalTune momentum (commonly 0.996–0.999) and use a warm-up/cosine schedule as in BYOL/MoCo v2/v3
Using MIM pixel loss and expecting strong linear-probe features immediatelyPixel reconstruction does not explicitly optimize instance-level separability, so linear probes underperform relative to fine-tuningFine-tune (or use attentive/nonlinear probing) rather than judging MIM encoders purely by linear-probe numbers

Pioneers & history

Self-supervised vision synthesizes decades of representation-learning ideas — autoencoders, word2vec-style contrastive prediction, and metric learning — applied specifically to the structure of images.

Origins · 1 minGeoffrey Hinton and how this was discovered
GH
Geoffrey Hinton
1947– · Co-developed backpropagation-era deep learning; his lab's SimCLR (2020) established the modern contrastive-learning recipe for vision (strong augmentations, a nonlinear projection head, large-batch InfoNCE) that most later contrastive methods build on.

History
1993
— Contrastive metric-learning ideas ("siamese networks") appear for signature verification.
2018
— CPC (Contrastive Predictive Coding) introduces InfoNCE for representation learning across modalities including images.
2020
— SimCLR and MoCo establish large-scale contrastive pretraining as competitive with supervised ImageNet pretraining.
2021
— BYOL and SimSiam show negatives are not strictly necessary; BEiT applies masked-token prediction to images via a visual tokenizer.
2022
— Masked Autoencoders (MAE) show pixel-level masked prediction pretrains ViTs efficiently and transfers strongly to detection and segmentation.

Where this matters

Self-supervised pretraining is now the default backbone-training stage in production and research vision pipelines wherever labels are scarce relative to available imagery: medical imaging (pretraining on large unlabeled scan archives before fine-tuning on small annotated cohorts), satellite and remote sensing (petabytes of unlabeled imagery with sparse ground-truth), and general-purpose vision foundation models such as DINOv2, which combine contrastive and masked-prediction objectives to produce features usable off-the-shelf for retrieval, depth estimation, and segmentation without any task-specific fine-tuning. Self-driving perception stacks use self-supervised pretraining on unlabeled fleet video to warm-start detectors before fine-tuning on the much smaller set of hand-labeled frames. Search and recommendation systems use contrastively trained image embeddings directly for visual similarity search, since the InfoNCE objective is itself explicitly optimizing an embedding space for nearest-neighbor retrieval. The technique also underlies multimodal systems: CLIP's contrastive image-text objective is a direct descendant of the instance-discrimination idea, generalized to align two different modalities instead of two augmented views, and CLIP-style pretraining is now foundational to text-to-image generation and open-vocabulary detection systems.

Ask the tutor: How does DINO's self-distillation objective relate to both the contrastive and masked-image-modeling families described here?

Is self-supervised pretraining strictly better than supervised pretraining?

Not strictly. Supervised ImageNet pretraining remains a strong, cheap baseline, and at moderate scale it sometimes still beats self-supervised methods on linear probes for the exact same taxonomy it was trained on. Self-supervised methods win decisively when unlabeled data vastly outnumbers labeled data, when the downstream task's label space differs from any fixed supervised taxonomy, or when the goal is dense prediction (detection, segmentation) where MIM-style pretraining transfers especially well. In practice, the strongest modern systems (DINOv2 and successors) use self-supervision at massive scale with curated unlabeled data and often surpass supervised pretraining on transfer benchmarks, but the comparison depends heavily on dataset scale and evaluation protocol.

What exactly is the InfoNCE loss, and where does the name come from?

InfoNCE stands for "Information Noise-Contrastive Estimation." It is a categorical cross-entropy loss over a set of candidates (one positive, many negatives), computed as a softmax over similarity scores scaled by a temperature τ\tau. Minimizing it can be shown to maximize a lower bound on the mutual information between two related views' representations, subject to the number of negatives used; more negatives tighten the bound. The "noise-contrastive" name derives from earlier noise-contrastive estimation techniques used to train language models (like word2vec) by distinguishing true context words from randomly sampled noise words, generalized to arbitrary paired data.

Why do contrastive methods need such large batch sizes or memory queues, but MAE does not?

Contrastive losses need many negatives per positive to produce a strong, low-variance gradient signal — too few negatives make the task trivially easy and the gradient uninformative. That requirement is intrinsic to instance discrimination. MAE's masked-reconstruction task, by contrast, gets its difficulty from the masking ratio and image content itself, not from comparisons across other images in the batch; each image supplies its own pretext supervision independently, so MAE needs no negatives and no large batch or queue to remain a hard, informative task.

Can self-supervised pretraining fail silently, and how would you notice?

Yes — collapse and shortcut learning are silent failures: the loss curve looks fine (it decreases smoothly) while the learned representation is nearly useless for transfer. The standard way to catch this is to periodically run a linear-probe evaluation on a small labeled held-out set during pretraining, not just watch the pretext loss. A collapsed contrastive encoder often shows near-uniform pairwise similarities across unrelated images; a shortcut-exploiting MIM encoder often shows suspiciously low reconstruction loss at low masking ratios that does not correlate with downstream accuracy.

How do you choose between contrastive learning and masked image modeling for a new project?

If the downstream task is closer to classification or retrieval and labeled data is extremely scarce, contrastive pretraining (or a hybrid like DINO) tends to give strong linear-probe features quickly. If the downstream task is dense prediction (segmentation, detection, depth) or you plan to fine-tune the whole network rather than probe it, MIM approaches like MAE tend to transfer better and are cheaper to pretrain because of the token-dropping efficiency trick. Many production pipelines now combine both: a MIM-style reconstruction loss alongside a contrastive or distillation loss, following the recipe popularized by DINOv2.

Does self-supervised pretraining eliminate the need for any labels at all?

No — it reduces, but does not eliminate, label dependence. The encoder is pretrained without labels, but essentially all practical uses still require some labeled data downstream: a linear probe needs labeled examples to train the classifier head, and fine-tuning needs labeled examples to adapt the encoder to the task. The gain is that the number of labels required for strong downstream accuracy drops substantially, sometimes by an order of magnitude, compared to training the same architecture from random initialization purely supervised.

Why does the projection head in SimCLR get discarded after pretraining instead of being kept?

Empirically, the representation immediately before the projection head transfers better than the projected embedding used for the contrastive loss itself. The intuition is that the projection head learns to discard information that is irrelevant to the contrastive task (e.g., precise color or exact orientation, since the loss explicitly wants invariance to the augmentations that alter those attributes) — information that is nonetheless useful for other downstream tasks. Keeping the pre-projection representation preserves that extra information while still benefiting from the contrastive training signal that shaped the encoder.

Before this