Emerging Properties in Self-Supervised Vision Transformers
- Publication
- ICCV 2021Conference
- First submitted to arXiv
- arXiv:2104.14294
Cite this paper · BibTeX
The citation identifies the linked source version. It cites the original paper and its authors.
@misc{contrastivelearningdino2021,
title = {{Emerging Properties in Self-Supervised Vision Transformers}},
author = {Mathilde Caron and Hugo Touvron and Ishan Misra and Hervé Jégou and Julien Mairal and Piotr Bojanowski and Armand Joulin},
year = {2021},
eprint = {2104.14294},
archivePrefix = {arXiv},
url = {https://arxiv.org/abs/2104.14294}
}
DINO appeared around the same time as MoCo v3, but its reported results look much stronger.
The name DINO comes from self-distillation with no labels. I read it like the dinosaur name, DI-NO rather than Dee-No.
Defining the Problem
Do you remember BYOL?
If not, no worries, here’s a brief introduction. The BYOL architecture looks like this:
BYOL is a prominent demonstration of the idea that negative samples are "unnecessary" in the process of representation learning.
The core components of BYOL are three:
- Siamese networks: An online network and a target network, where the target network updates its parameters through exponential moving average (EMA).
- Stop gradient: The target network does not propagate gradients during training.
- Additional MLP layer: The only difference between the online and target networks is that the online network has an additional MLP for prediction.
In this paper, the authors were inspired by BYOL and decided to make slight modifications to this structure.
The changes are minimal, just two:
- Change the loss function: BYOL uses MSE, while here it is changed to cross-entropy between teacher and student output distributions.
- Remove the additional MLP layer: This means the siamese network architecture here is exactly the same for both networks.
It may seem like not much, but this form is not without reasoning. The authors based it on this paper:
Mean Teacher provides empirical support for weight-averaged teachers in its semi-supervised setting. It is relevant motivation, not a theorem that EMA teachers outperform every fixed teacher.
Solving the Problem
After modifying the BYOL architecture, it looks like the figure above.
Given an input image , the two networks each output a -dimensional feature vector, which is converted to a probability distribution via the softmax function. For the student network (left side of the image), the probability for the -th dimension, , is defined as:
Where is the temperature parameter used to control the sharpness of the output distribution. Similarly, for the teacher network (right side of the image), the probability distribution is defined using a temperature .
The teacher network receives no gradient from this loss. We want the student distribution to match the teacher distribution by minimizing their cross-entropy:
Where the cross-entropy measures the difference between two distributions.
Since self-supervised learning does not use labels, the authors employ a common technique in contrastive learning, where different augmentations of the same image are used to generate different "views."
In this architecture, all views are input to the student network, and only global views are input to the teacher network. This design encourages the "local-to-global" correspondence.
For each global view and other views processed by the student network (where ), the cross-entropy loss is calculated, and the total loss is minimized:
This loss function is general for the number of views, and can be used even with just two views; the standard setting in this paper uses two global views and multiple local views as basic parameters.
The student network's parameters are optimized by minimizing the above loss function using gradient-based optimization; the reported ViT setup uses AdamW.
The teacher network's parameters are updated using EMA from the student network's parameters , with the update rule as follows:
This update method is similar to the momentum encoder, where the coefficient follows a cosine schedule from 0.996 to 1 during training.
Preventing Model Collapse
The issue with this type of siamese network self-supervised method is that the model often collapses unexpectedly. Previous studies have mostly used contrastive loss, clustering, and other methods to prevent the model from collapsing into a trivial solution. However, the authors here adopted centering and sharpening strategies.
-
Centering:
The centering operation subtracts the running center from the teacher logits of the teacher network, defined as:
This prevents any particular dimension from overly dominating the output, while simultaneously encouraging a more uniform distribution. Additionally, to ensure that the centering operation works stably under different batch sizes, the center is updated using exponential moving average:
where is the EMA momentum coefficient and is the batch size. This update ensures that the center only depends on the first-order statistics of the batch.
The paper's prose writes the bias as , but its Algorithm 1 and the authors' implementation subtract the center updated from the batch mean.
-
Sharpening:
The sharpening operation is achieved by using a lower temperature in the teacher's softmax normalization, which makes the teacher’s output probability distribution sharper. This balances the uniform tendency caused by centering, helping to prevent model collapse.
Discussion
Comparison with Other Methods
Based on experimental results, the authors categorized the comparisons into "same architecture" and "cross-architecture" comparisons:
-
Comparison within the Same Architecture:
- ResNet-50 Architecture: DINO achieves results on ResNet-50 that are comparable to the best existing self-supervised methods, verifying that DINO can perform on par with other methods under standard settings.
- ViT-S Architecture:
When using ViT-S (designed based on DeiT-S), DINO’s performance significantly surpasses BYOL, MoCov2, and SwAV.
- Linear classification reaches 77.0%, 3.5 percentage points above SwAV's 73.5% for ViT-S in the table.
- k-NN reaches 74.5%, 7.9 points above BYOL's 66.6% for ViT-S in the table. DINO ViT-S's k-NN result (74.5%) is just 2.5 points below its linear result (77.0%). Such a small gap is not seen for the other listed methods or DINO ResNet-50 in this table.
-
Cross-Architecture Comparison:
This section primarily explores the extreme performance of DINO-trained ViT models across different scale architectures, rather than directly comparing various methods.
Larger ViTs improve performance, while reducing patch size (the “/8” variants) has an even clearer effect in this table. For a given ViT architecture, smaller patches do not add parameters, but they create longer token sequences, increase memory use, and reduce inference throughput.
DINO's ViT-B/8 reaches 80.1% linear Top-1 and 77.4% k-NN accuracy. Its extractor has 85M parameters versus 794M for SimCLR v2 RN152w3+SK, with throughput of 63 versus 46 images/s. This is a cross-architecture comparison.
DINO and SwAV both reach 75.3% linear accuracy with standard ResNet-50. With ViTs, smaller patches improve the reported accuracy while lowering throughput for the same architecture.
Importance of Different Components
The authors conducted a series of experiments to assess the importance of various components:
- No Momentum (Row 2 in the table): When only the momentum teacher is removed and the other settings remain the same, both k-NN and linear accuracy fall to 0.1%.
- Operations to Prevent Collapse (e.g., SK): Row 9's SwAV has no momentum but uses the Sinkhorn-Knopp (SK) constraint and still reaches 71.8% linear accuracy. Rows 1 and 3 show little change when SK is added to DINO with momentum (76.1% versus 76.0%). Other settings also differ across rows, so the gap between rows 3 and 9 cannot be assigned entirely to momentum.
- Multi-crop and Cross-Entropy Loss: Relative to row 1, removing multi-crop in row 4 lowers linear accuracy from 76.1% to 72.5%; replacing cross-entropy with MSE in row 5 lowers it to 62.4%. These ablations test different components.
- Predictor: Adding a predictor to the student in row 6 gives 75.6%, 0.5 percentage points below row 1. BYOL relies on its predictor under a different method configuration.
Model Collapse Testing
Generally, the two most common types of collapse are:
- The model outputs the same result for different inputs, collapsing into a uniform distribution.
- One dimension overly dominates, leading to an imbalanced output.
Centering subtracts the running center from teacher logits before softmax. It suppresses domination by a single dimension, but may encourage uniform outputs. A low teacher temperature sharpens the distribution and counterbalances that tendency.
Mathematically, the cross-entropy can be decomposed into the teacher’s output entropy and the KL divergence :
A zero KL divergence means that teacher and student distributions agree. Collapse must also be assessed through output entropy and variation across samples.
The experiment shown in the figure indicates that if only one operation is used, KL converges to 0, while the teacher entropy tends to different limits: 0 without centering, or without sharpening. These correspond to one-dimension and uniform-output collapse, respectively. With both operations, the plotted entropy and KL avoid those two degenerate limits.
Conclusion
Through extensive experimental analysis, the authors found that training ViT using self-supervised learning not only demonstrates exceptional performance in downstream tasks but can even rival convolutional neural networks (CNNs) specifically designed for vision tasks.
These experiments suggest that self-supervision gives ViT useful transfer features and emergent object-level attention.
The red regions are thresholded attention masks, not individual attention points or outputs from a trained segmentation head. In this visualization, the authors retain 60% of the attention mass and select the best head for the displayed object. The comparison illustrates emergent localization under that visualization procedure.
The results make self-supervised learning a promising way to train ViTs with less dependence on human labels. They support further exploration, rather than proving a universally optimal training method.