TT Lab
Blog

한국어 English 日本語 中文

Get started
Blog

Blog

Self-Supervised Learning 1: From SimCLR and MoCo to DINO and DINOv2 — How to Learn Features Without Labels and Prevent "Collapse"

Status: Draft (2026-10-13). Paper metrics are values verified directly from the original papers along with their conditions. Hands-on parts use a toy example on a notebook CPU (code/02_ssl_collapse.py, around 30 seconds), and we have not performed self-supervised learning on table tennis videos (unmeasured). Part 2 of the series "Reading Vision Models." Previous part: Contrastive Learning and CLIP. For the ViT architecture itself, see Reading Vision Models 1.

Self-Supervised Learning 1: Learning Features Without Labels

Table of Contents

1. Intuition: Labels Are Expensive, Images Are Abundant

Thinking about table tennis videos makes this immediately clear. Practice videos recorded with a smartphone pile up for hours, but manually labeling "the ball is here in this frame" yields at most a few hundred images an hour. Can we then learn something from the pile of unlabeled images itself?

Self-supervised learning creates tasks within the data and solves them. The problem family covered in this post works as follows:

Even if an image is augmented in two different ways (cropping, color jitter, blurring), the model must say they are the "same thing."

Features that survive augmentations are likely to capture the contentof the image while discarding its appearance(brightness, crop location). While CLIP in Part 1 paired "images and text," here we pair "an image and another augmented view of that image." Even text is unnecessary.

2. The Problem: Collapse

However, there is a catch. If "making the outputs of two augmented views identical" is the entire goal, a model that produces the exact same output for every inputis a perfect solution. The loss is at its minimum, but the features contain zero information. This is called collapse .

It is easy to summarize the methods in this post by viewing them all as different mechanisms to prevent collapse.

두 변형은 가깝게 — 그런데 「모두 한 점」 은 막는다 SimCLR · MoCo 오답을 밀어낸다(InfoNCE) 한 그림의 두 변형 다른 그림 = 오답 BYOL 오답 없이, 예측기 + 느린 교사 학생 인코더 예측기 교사 인코더 맞힌다 교사 = 학생의 이동 평균(EMA) 예측기를 빼면 붕괴 DINO: 교사의 분포를 학생이 따라 한다 큰 자르기 2장 작은 자르기 여럿 교사(EMA) 학생 가운데 맞추기 + 날카롭게(τ 0.04) 소프트맥스(τ 0.1) 손실 = 교사 분포와 학생 분포의 교차 엔트로피 가운데 맞추기만 → 고른 분포로 붕괴 날카롭게만 → 한 칸으로 붕괴 둘이 서로를 막을 때만 버틴다 (논문 그림 7, 이 글의 예제)
Figure: How SimCLR/MoCo, BYOL, and DINO prevent collapse
Method Collapse Prevention Mechanism Loss
SimCLR (2020) Pushes other images in the same batch away as negative examples InfoNCE (same form as Part 1)
MoCo (2020) Stores outputs from past batches in a queue to use as negative examples. The encoder filling the queue updates slowly InfoNCE
BYOL (2020) No negative examples. A predictor is attached only to the student side, while the teacher is an exponential moving average (EMA) of the student Mean squared error of normalized outputs
DINO (2021) No negative examples. Subtracts the teacher output mean (centering) and sharpens with a low temperature Cross-entropy between teacher and student distributions

3. How to Train

SimCLR: Large Batch and Strong Augmentations

SimCLR's loss is called NT-Xent, but it has the same form as the InfoNCE loss from Part 1. From N images, 2N augmented views are created; the positive target for each view is its paired counterpart, and the remaining 2N−2 views are negative examples. The paper highlights three main points:

MoCo: Storing Negative Examples in a Queue

Large batches consume a lot of memory. MoCo retrieves negative examples from past batches. Outputs are stored in a queue of length 65,536 and used as negatives. The issue is that the outputs in the queue were produced by encoders from different timesteps. Therefore, the encoder filling the queue (the key encoder) does not backpropagate gradients, but instead tracks the weights of the trained encoder very slowly.

key 인코더 ← m · key 인코더 + (1 − m) · query 인코더,   m = 0.999

Setting m to 0 (copying directly every time) caused training to fail; it reached 55.2% at 0.9 and 59.0% at 0.999 (paper, ablation study with a queue of 4,096). Slowly tracking teacher, this mechanism carries over to BYOL and DINO.

BYOL: Surviving Without Negative Examples

BYOL does not use negative examples at all. A predictoris attached on top of the student (online) encoder to match the output of the target (teacher) encoder that has seen a different augmentation. The teacher is an EMA of the student and does not receive gradients (gradually increasing from 0.996 to 1). While the paper does not provide a complete mathematical proof for why the shortcut of "collapsing to a single point" is prevented, experiments clearly show that removing the predictor leads to collapse (paper). We can observe the same result in the example below.

DINO: Following the Teacher's Distribution

DINO turns outputs into probability distributions of dimension K. The teacher and student observe different crops of the same image, and cross-entropy is minimized so that the student matches the teacher's distribution. Because this resembles distilling a classifier, it is called self-distillation (distillation is covered in detail in Part 4).

# 02_ssl_collapse.py 의 DINO 부분에서 줄임
with torch.no_grad():
    q = softmax((teacher(v1) - center) / 0.04)         # 가운데 맞추고, 낮은 온도로 날카롭게
loss = -(q * log_softmax(student(v2) / 0.1)).sum(1).mean()
center = 0.9 * center + 0.1 * teacher_outputs.mean(0)    # 교사 출력의 이동 평균
teacher = EMA(student)

The two components that prevent collapse work in opposite directions:

The paper showed through illustrations that using only one of the two causes collapse in its respective direction. The student views two large crops and multiple small crops, while the teacher views only large crops (multi-crop). This turns into the task of "predicting the meaning of the entire image from just small fragments."

DINOv2: Data Over Methods

DINOv2 did not significantly alter the loss (DINO loss + iBOT loss at the masked patch level + KoLeo regularization to spread features evenly). Instead, it focused heavily on data curation. From a deduplicated source of 1.2 billion images, it searched for images resembling established datasets to select 142 million images (LVD-142M). After training the largest ViT-g (1.1 billion parameters), smaller models were not trained from scratch but distilled from the large model(paper). Why distillation wins is the topic of Part 4.

4. Hands-on: Seeing Collapse with Your Eyes

code/02_ssl_collapse.py generates 32-dimensional "images" derived from 10 hidden classes. The images contain a highly fluctuating "background" in addition to the content defining the class, meaning that comparing raw pixels causes the background to dominate distances. Augmentations include repainting the background, erasing 30% of pixels, brightness scaling, and noise. All methods were trained using the same encoder (a small MLP) and the same 1,500 steps. Labels (class numbers) are used only for evaluation .

Evaluation consists of two metrics: the standard deviation per embedding dimension (near 0 means all points collapse to one), and k-NN accuracy, which polls the 5 nearest class numbers for each test image (using raw outputs, code/02_ssl_collapse.out.txt).

Method Standard Deviation k-NN Accuracy Notes
Random guess — 0.100
Raw pixels — 0.315 Background dominates distance
Untrained encoder 0.170 0.234
1. Pulling together only 0.003 0.107 Loss −0.9998 (minimum −1) — Complete collapse
2. SimCLR (τ=0.2) 0.170 0.931
3. BYOL 0.087 0.816
3′. BYOL without predictor 0.002 0.150 Collapse
4. DINO 0.077 0.669 Active dimensions 12/32, entropy per image 2.62
4′. Without centering 0.054 0.301 Active dimensions 1/32, entropy 0 — Collapsed to a single dimension
4″. Without sharpening 0.056 0.286 Entropy per image 3.47 = Maximum (log 32) — Collapsed to a uniform distribution

There are several takeaways here:

5. Paper Metrics

Evaluations are mostly linear evaluations. The self-supervised encoder is frozen, a single linear classifier is trained on top of it using ImageNet labels, and accuracy is measured. This checks how well-organized the features are so that they are "linearly separable."

Method Model ImageNet Linear Evaluation Top-1 Conditions (Paper)
MoCo ResNet-50 60.6% 200 epochs, batch 256
SimCLR ResNet-50 / 4x width 69.3% / 76.5% 1,000 epochs. 76.5% matches supervised ResNet-50 performance
MoCo v2 ResNet-50 71.1% 800 epochs, added MLP head and blur augmentation
BYOL ResNet-50 74.3% 1,000 epochs, batch 4,096
DINO ViT-S/16 · ViT-B/8 77.0% · 80.1% k-NN is 74.5% · 77.4%
DINOv2 ViT-S/14 · ViT-g/14 81.1% · 86.5% LVD-142M, S distilled from g
DINOv3 ViT-7B/16 88.4% Evaluation resolution 512px, LVD-1689M (1.7 billion images)

There are also numbers regarding the importance of augmentations. When restricted to only cropping, BYOL maintained 59.4% (−13.1%p), whereas SimCLR collapsed to 40.3% (−27.6%p) (BYOL paper). This suggests that methods relying on negative examples are more vulnerable to shortcuts like "finding pairs based solely on color."

Besides the metrics, DINO has another famous observation. Without ever seeing labels, the attention maps in the final layer of the ViT trace the outlines of objects. The mask overlap (Jaccard) created using these maps was 45.9 for ViT-S/16, which is higher than supervised training with the same architecture (27.3) (Paper).

The computation cost is as follows: DINO ViT-S/16 took 3 days on two 8-GPU servers, the entire DINOv2 took 22,000 datacenter-class GPU hours, and DINOv3 took 61,000 hours (Paper).

6. Limitations

7. Connection to Our Project

TT's Word. If you tell the model, "Just say the two are the same," the model ends up saying everything in the world is the same. It was fascinating to see firsthand that removing even one mechanism preventing that—whether it's negative examples, a predictor, or centering—truly causes it to collapse.

References

Sign in to like

Comments

No comments yet.

Sign in to leave a comment