Abstract
Self-supervised learning offers a path to leverage vast amounts of unlabeled data, reducing the reliance on expensive human annotations. This paper introduces Selfie (SELF-supervised Image Embedding), a pretraining technique that adapts the masked language modeling approach of BERT to the visual domain. Unlike traditional methods that attempt to reconstruct pixel values, Selfie treats image patches as discrete units and employs a classification-based "distractor" task. By predicting the correct patch from a set of candidates, the model learns robust semantic features. Evaluations on ImageNet and CIFAR-10 demonstrate that Selfie significantly improves classification accuracy and training stability, particularly in low-data regimes where labeled examples are scarce.
Introduction
Deep learning models typically require massive datasets of hand-labeled images to achieve high performance. While self-supervised learning—learning representations from unlabeled data—has long been a goal, it has historically lagged behind supervised methods in computer vision. In Natural Language Processing (NLP), models like BERT have revolutionized the field by using "masked language modeling," where the model predicts missing words in a sentence.
Adapting this to images is challenging because images are continuous pixel arrays rather than discrete tokens. Predicting exact pixel values (regression) often forces models to focus on low-level noise or lighting rather than high-level semantics. Selfie addresses this by reframing the problem as a classification task.
Methods
The Selfie framework consists of two distinct stages: pretraining on unlabeled data and finetuning on a specific labeled task.
Pretraining Stage
During pretraining, an image is divided into a grid of patches. A subset of these patches is masked. The architecture consists of an encoder and a decoder:
- The Encoder: Processes the unmasked patches using convolutional blocks (ResNet-50) and summarizes them into a single vector $u$ via an attention pooling network.
- The Decoder: Receives the summary vector $u$ and a location query for a masked patch.
Instead of pixel reconstruction, Selfie utilizes Contrastive Predictive Coding (CPC). The model is presented with the correct patch and several "distractor" patches sampled from the same image. The objective is to correctly classify which patch belongs in the masked location. This approach encourages the model to learn high-level features that distinguish the target patch from others in the same context.
Finetuning Stage
After pretraining, the convolutional weights are used to initialize a standard ResNet-50 architecture. This model is then trained on a labeled dataset (e.g., ImageNet classification).
Key Insights
- Classification vs. Regression: By treating patch prediction as a selection task rather than a generation task, the model becomes more robust to pixel-level perturbations and focuses on semantic content.
- The "10x Rule": The benefits of Selfie pretraining are most pronounced when the amount of unlabeled data is at least ten times greater than the amount of labeled data.
- Attention Pooling: Replacing standard global average pooling with a Transformer-style attention layer allows the model to better capture long-range dependencies between patches.
- Improved Stability: Selfie-initialized models exhibit significantly lower variance across training runs, making them more reliable for small-scale datasets.
Results
Selfie was evaluated on CIFAR-10, ImageNet 32x32, and standard ImageNet 224x224. The results show consistent gains, especially in data-efficient settings:
- ImageNet (5% labels): With only 60 examples per class, Selfie improved ResNet-50 accuracy from 35.6% to 46.7%, an 11.1 point absolute gain.
- CIFAR-10 (8% labels): Accuracy reached 80.3%, a 1.0% improvement over the baseline.
- Training Stability: On ImageNet 32x32, the standard deviation of test accuracy was reduced by a factor of 8 compared to random initialization.
Discussion and Limitations
While Selfie shows great promise, some challenges remain. There is a "pretrain-finetune mismatch" because the model processes patches independently during pretraining but sees the full image during finetuning. Additionally, transferring features across very different datasets (e.g., ImageNet to CIFAR) remains difficult. Future work may explore hybrid architectures that combine convolutions with full attention mechanisms throughout the network.
Summary updated