- Introduced by
- Caron et al. (DINO); He et al. (MAE)
- Year
- 2021–2022
- Type
- Self-supervised pre-training for vision transformers
- Family
- Deep learning / NLP / CV
What does it do?
Self-supervised Vision Transformer (SSL-ViT) applies label-free pre-training objectives to the Vision Transformer architecture.
Two representative objectives are masked patch reconstruction (MAE) and self-distillation between augmented views (DINO). The pre-trained encoder is then adapted to a labeled target task, which can reduce the labeled data needed compared with training a ViT from scratch.
The intuition behind the method
A Vision Transformer splits an image into a grid of patches and uses self-attention to relate patches across the whole image. Self-supervised pre-training trains this encoder on a pretext objective that needs no labels. In DINO, a student network is trained to match a teacher network's output on other views of the same image; in MAE, the model must reconstruct pixels hidden behind masked patches. Solving either task requires the encoder to capture image structure, so the learned features are intended for reuse in classification, detection and segmentation. Because the training signal comes from the images themselves, the approach can use large unlabeled collections. How well the features transfer depends on how close the target domain is to the pre-training images.
History
Self-supervised pre-training for Vision Transformers builds on the Vision Transformer architecture. DINO (Caron et al., 2021) applies self-distillation to ViTs without labels. MAE (He et al., 2022) masks a large proportion of patches and reconstructs them.
When to use it
Consider self-supervised ViT pre-training when a substantial pool of unlabeled images from your target domain is available but labeled examples are scarce or expensive. This motivation is common in specialised domains far from natural photographs, such as some medical, satellite or scientific microscopy imagery, but the benefit has to be established on your own task. It fits best when the pre-training images resemble the images you will later classify or segment. Avoid it when a labeled dataset is already large enough to train a standard supervised ViT, since the benefit over supervised training may then be small. It is also a poor choice under tight compute budgets, because pre-training is expensive, and for very small images, since patch-based encoders need enough resolution to form meaningful patches.
Limitations and considerations
- Pre-training is computationally intensive, requiring substantial GPU resources and large image datasets.
- Patch-based tokenization is sensitive to image resolution; very low-resolution inputs may weaken representation quality.
- MAE-based approaches use high masking ratios (75% in the setting described on this page) that may not suit all image domains and should be validated for each modality.
- Gains over supervised baselines diminish when labeled data is abundant.
- Hyperparameter sensitivity (masking ratio, augmentation strength, teacher momentum) requires careful tuning.
Source conditions do not replace independent scientific review or validation by an analysis engine.
Strengths
- Pre-training uses unlabeled images only, so labeling cost is confined to the downstream task.
- DINO-trained features have been reported to show emergent properties, which the original work examines (Caron et al., 2021). The reported properties are benchmark-specific and should be read from that paper.
- MAE's asymmetric design passes only the visible patches through the encoder, so encoder computation scales with the unmasked fraction of the image.
- Frozen embeddings can be checked with a linear probe, a cheap test of representation quality before committing to full fine-tuning.
- The same pretext approach can be run on an in-domain unlabeled corpus, which may suit domains far from natural photographs.
Applications
- Dense prediction tasks (semantic segmentation, object detection) via fine-tuning of the pre-trained encoder.
- Image classification in specialised domains far from natural photographs, where labeled data is scarce; the benefit must be tested against a supervised baseline.
- Low-label adaptation, where a frozen or lightly tuned encoder is paired with a small task head.
- Medical or scientific imaging, where annotation is often costly; the reported benefit is domain-specific and must be validated on the target task.
How it works
How it works
Pre-training needs a variation or corruption of each image to create a learning signal. In DINO-style training, each image is turned into several augmented crops (for example random crops and colour changes) that are passed to the student and teacher networks. In MAE-style training, the corruption is the masking itself: a high proportion of patches (for example 75%) is removed, and no paired augmented views are required.
The pretext task defines what the encoder must learn without labels. In DINO-style methods, a student network is trained to match the output distribution of a teacher network on different views of the same image. The training objective is a cross-entropy between the two output distributions, with the teacher's outputs centred and sharpened to discourage collapse, and the teacher's weights are a moving average of the student's. In MAE-style methods, most patches are masked and the model is trained to reconstruct the missing pixel content from the visible patches; the loss is the mean squared error between reconstructed and original pixel values, computed on the masked patches.
The ViT encoder processes image tokens through multi-head self-attention layers and is updated by gradients from the pretext loss. In DINO-style training, gradients update the student, while the teacher follows through the moving-average update. In MAE-style training, the encoder processes only the visible patches, and a separate lightweight decoder reconstructs the masked content from the encoder output and mask tokens.
After pre-training, an image embedding is taken from the encoder, typically the [CLS] token or an average over patch tokens. The choice of pooling changes the embedding, so it should be stated when results are reported. This embedding is what downstream probes or fine-tuned heads consume.
The pre-trained encoder is adapted to a labeled target task such as classification, detection or segmentation by attaching a task head. This can be done by fine-tuning all weights end-to-end, or by keeping the backbone frozen and training only the head, for example as a linear probe. Whether pre-training helps relative to a fully supervised baseline depends on the amount of labeled data and the domain match, so it should be tested on the target task rather than assumed.
Common pitfalls
- Using pre-trained weights from a very different domain (for example, natural photographs) for a specialised domain without domain-adaptive fine-tuning.
- Relying on linear probing alone: it is a useful cheap diagnostic of frozen features, but it does not measure how the encoder performs after fine-tuning or on dense tasks such as segmentation.
- Applying self-supervised ViT to small datasets without pre-training. ViTs need more data than CNNs when trained from scratch and underperform without it.
- Conflating the masking ratio or augmentation schedule from the original MAE or DINO settings with defaults for a different image modality.
- Reporting only linear-probe results: a reader who wants to know whether pre-training helps a target application needs fine-tuned performance on that task, reported alongside the probe result.
Frequently asked questions
What is the difference between DINO and MAE?
DINO is a self-distillation method: a student ViT is trained to match the output of a momentum-updated teacher ViT on different augmented views of the same image, without labels. MAE is a reconstruction method: a high proportion of patches is masked and the model reconstructs the missing pixel content from the visible patches. The two differ in training signal and computational profile, and which produces better features for a given task should be tested on that task rather than assumed.
How much unlabeled data do I need for self-supervised ViT pre-training?
No fixed minimum is established for this method; the useful amount of unlabeled data depends on the domain and the compute available. To judge whether a given corpus is sufficient, compare downstream results on a labeled validation split with those from a publicly released self-supervised checkpoint fine-tuned on the same data. When the unlabeled corpus is small, that starting point is often more practical than pre-training from scratch.
Can I use self-supervised ViT features without any fine-tuning?
Yes. A common evaluation is linear probing, in which a linear classifier is trained on frozen self-supervised features; DINO-style features are frequently assessed this way. For the best performance on a specific task, full fine-tuning is usually the stronger option, but its gain must be measured on the target task. The two results should be reported separately.
Is self-supervised ViT suitable for small images?
Patch-based tokenization needs enough resolution to form meaningful tokens. A common ViT-B configuration uses 16x16 patches on 224x224 inputs; images much smaller than this leave few patches and may give weaker representations. If your images are very small, check whether a patch-based encoder is feasible at your resolution before investing in pre-training.
How do I choose between self-supervised ViT and transfer learning from a supervised ViT?
If your target domain is close to natural photographs such as ImageNet, supervised ViT transfer is often simpler and may perform as well. Self-supervised pre-training on domain-specific unlabeled data is more likely to help when the domain is far from natural photographs (for example, some medical or remote-sensing imagery) and when a large unlabeled corpus from that domain is available. Both options should be compared on the target task.
Related methods
Sources
Caron, M., Touvron, H., Misra, I., Jegou, H., Mairal, J., Bojanowski, P., & Joulin, A. (2021). Emerging Properties in Self-Supervised Vision Transformers. Proceedings of the IEEE/CVF International Conference on Computer Vision (ICCV), 9650–9660.
Open publication referenceHe, K., Chen, X., Xie, S., Li, Y., Dollar, P., & Girshick, R. (2022). Masked Autoencoders Are Scalable Vision Learners. Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition (CVPR), 16000–16009.
Open publication reference