Improving fine-tuning of self-supervised models with Contrastive Initialization

Haolin Pan, Yong Guo, Qinyi Deng, Haomin Yang, Jian Chen, Yiqun Chen

TL;DR

Self-supervised models often struggle with downstream classification because their "class-blind" pre-training treats different images of the same category as negatives. This paper introduces COIN (Contrastive Initialization), a simple yet effective two-stage fine-tuning strategy that uses supervised contrastive loss to "cluster" features by class before training the final classifier, achieving state-of-the-art results with zero additional training cost.

What Problem Does This Paper Address?

Self-supervised learning (SSL) has revolutionized how we pre-train deep learning models without needing labels. Methods like MoCo or SimCLR learn by comparing different "views" of the same image. However, there is a catch: because these models don't know about classes, they treat every other image in a batch as a negative sample.

This creates a semantic gap. If you have two different images of Golden Retrievers, a standard SSL model will try to push their features as far apart as possible. Consequently, when it comes time to fine-tune the model for a downstream task (like dog breed classification), the feature space is a mess—instances of the same class are scattered, making it harder for a linear classifier to draw clean boundaries.

Methods

The authors propose breaking the traditional fine-tuning pipeline into two distinct stages:

  1. Contrastive Initialization (COIN) Stage: Instead of jumping straight to training a classifier, the model undergoes a "warm-up" on the target dataset. Using the available labels, it applies a Supervised Contrastive Loss. This loss explicitly pulls images of the same class together in the feature space and pushes different classes apart. Crucially, no classification head is trained here; the focus is purely on "re-arranging the furniture" of the feature space to be more semantically meaningful.
  2. Fine-tuning Stage: The model then proceeds with standard fine-tuning (using Cross-Entropy loss, often combined with continued contrastive loss).

The "No Free Lunch" Exception: To ensure this isn't just "training for longer," the authors introduce a stage split ratio ($\alpha$). If you have a budget of 100 epochs, you might spend 70 epochs on COIN ($\alpha=0.7$) and 30 on fine-tuning. The total computational cost remains identical to standard methods.

Datasets

The researchers evaluated COIN across nine diverse image classification datasets to ensure robustness:

  • General/Coarse-grained: ImageNet-20, CIFAR-10, CIFAR-100, Caltech-101.
  • Fine-grained: Stanford Cars, FGVC Aircraft, Oxford-IIIT Pets, Oxford 102 Flowers.
  • Texture: Describable Textures Dataset (DTD).

They primarily used a ResNet-50 backbone pre-trained with MoCo-v2, but also validated the approach using a Vision Transformer (ViT) pre-trained with MAE.

Key Insights and Ideas

  • The Power of Clustering: The "aha moment" is that a better initialization is more valuable than more iterations of standard fine-tuning. By spending the majority of the training budget just clustering features (COIN), the subsequent classifier training becomes trivial and much more accurate.
  • Quantifying "Messiness": The authors use the $S\_Dbw$ score, a metric that measures how tightly clusters are packed and how far apart they are. They show that COIN drastically reduces this score (e.g., from 0.48 to 0.28 on CIFAR-10), proving that the feature space becomes significantly more organized.
  • Class-Awareness Matters: Standard fine-tuning tries to learn the feature representation and the classifier simultaneously. COIN argues that fixing the representation first (using class labels) makes the classifier's job much easier.

Key Results

COIN consistently outperformed existing fine-tuning methods like CE-Tuning and Core-Tuning across almost all benchmarks:

  • ImageNet-20: Achieved 94.60% accuracy, a massive +5.00% improvement over standard supervised contrastive learning (SCL).
  • CIFAR-100: Improved accuracy by +2.57% over SCL.
  • Efficiency: Because COIN reallocates existing training epochs rather than adding new ones, these gains come with zero extra training time.
  • Architecture Agnostic: When applied to a Vision Transformer (ViT) pre-trained with MAE, COIN set new state-of-the-art marks, showing the method isn't tied to a specific model type.

Limitations and Future Work

  • Hyperparameter Sensitivity: The split ratio ($\alpha$) is dataset-specific. While the authors found that a moderate value (around 0.6 to 0.8) usually works best, finding the "sweet spot" for a new dataset requires some empirical tuning.
  • Label Dependency: COIN relies on having labels for the initialization stage. Its performance in extremely low-data (few-shot) regimes was not the primary focus of this paper.
  • Future Directions: The authors suggest that exploring how COIN interacts with different types of pre-training (like masked autoencoders vs. contrastive SSL) could yield further insights into how semantic information is stored in deep models.

Summary updated

Abstract

Self-supervised learning (SSL) has achieved remarkable performance in pre-training the models that can be further used in downstream tasks via fine-tuning. However, these self-supervised models may not capture meaningful semantic information since the images belonging to the same class are often regarded as negative pairs in the contrastive loss. Consequently, the images of the same class are often located far away from each other in the learned feature space, which would inevitably hamper the fine-tuning process. To address this issue, we seek to explicitly enhance the semantic relation among instances on the targeted downstream task and provide a better initialization for the subsequent fine-tuning. To this end, we propose a Contrastive Initialization (COIN) method that breaks the standard fine-tuning pipeline by introducing an extra class-aware initialization stage before fine-tuning. Specifically, we exploit a supervised contrastive loss to increase inter-class discrepancy and intra-class compactness of features on the target dataset. In this way, self-supervised models can be easily trained to discriminate instances of different classes during the final fine-tuning stage. Extensive experiments show that, with the enriched semantics, our COIN significantly outperforms existing methods without introducing extra training cost and sets new state-of-the-arts on multiple downstream tasks. For example, compared with the baseline method, our COIN improves the accuracy by 5% on ImageNet-20 and 2.57% on CIFAR100, respectively.
BibTeX
@article{pan2023improving,
  author = {Haolin Pan and Yong Guo and Qinyi Deng and Haomin Yang and Jian Chen and Yiqun Chen},
  title = {{Improving fine-tuning of self-supervised models with Contrastive Initialization}},
  journal = {Neural Networks},
  year = {2023},
  doi = {10.1016/j.neunet.2022.12.012},
}

Loading related content...

Figure