What Happens During Finetuning of Vision Transformers: An Invariance Based Investigation

Gabriele Merlin, Vedant Nanda, Ruchit Rawal, Mariya Toneva · DOI

Abstract

The "pretrain-finetune" paradigm is a cornerstone of modern deep learning, yet the internal mechanics of how representations adapt to downstream tasks remain largely opaque. This paper investigates these dynamics through the lens of invariances—the specific input transformations that a model learns to ignore. By utilizing Similarity Through Inverted Representations (STIR), we introduce three novel metrics: Forgetting, Learning, and Invariance Flow. Our findings reveal that finetuning is characterized by a systematic reorganization where shallow layers remain stable while deeper pretrained invariances are "compressed" into shallower layers, freeing capacity for task-specific features. We further demonstrate a strong correlation between the variability of invariance forgetting and model robustness.

1. Introduction

While transfer learning consistently improves performance and convergence speed, the internal representational shifts during finetuning are often treated as a "black box." Existing tools like Centered Kernel Alignment (CKA) measure representational similarity but fail to capture the functional property of invariance. Understanding how invariances are retained, lost, or relocated is essential to deciphering the success of transfer learning and the underlying stability-plasticity dilemma.

2. Methodology

This study builds upon the STIR (Similarity Through Inverted Representations) metric. STIR estimates shared invariances by identifying input perturbations to which one model is invariant and testing if a second model maintains that invariance. From this foundation, we derive three metrics:

  • Forgetting: Quantifies the loss of invariances present in the pretrained model.
  • Learning: Measures the acquisition of new, task-specific invariances.
  • Invariance Flow: Tracks the migration of invariances across the network hierarchy. This allows for the identification of compression (migration to shallower layers) or expansion (migration to deeper layers).

3. Experimental Setup

The researchers evaluated Vision Transformers (ViTs) across diverse datasets:

  • Pretraining: ImageNet and CIFAR100.
  • Finetuning (Naturalistic): CIFAR10, CIFAR100, and Oxford-IIIT Pet.
  • Finetuning (Specialized): EuroSAT (satellite imagery).
  • Robustness: CIFAR10C and CIFAR100C (algorithmic corruptions).

4. Key Insights and Results

4.1 Stability of Shallow Layers

Pretrained models exhibit significantly lower learning and forgetting in the first six layers compared to models trained from scratch. This suggests that early layers develop general-purpose, reusable invariances during pretraining that require minimal adjustment for downstream tasks.

4.2 The Compression Phenomenon

A central finding is the "compression" of invariances. During finetuning, invariances originally residing in deeper pretrained layers (e.g., layers 6-12) frequently migrate to shallower layers (e.g., layers 4-8). This reorganization likely frees up the capacity of deeper layers to focus on high-level features specific to the new task. Conversely, in low-level tasks like image reconstruction, the model exhibits expansion, where early-layer invariances move deeper into the network.

4.3 Invariance vs. Similarity

The study highlights that high representational similarity (low CKA divergence) does not necessarily imply shared invariance. Early layers may appear similar under CKA while undergoing significant internal reshuffling of what information they choose to ignore.

There is a strong Pearson correlation (0.78) between the variability of "forgetting" across layers and the model's robustness to corrupted data (CIFAR10C). Models that distribute the forgetting of pretrained knowledge differently across their hierarchy tend to generalize better to noisy or out-of-distribution inputs.

5. Discussion and Limitations

While this work provides a new framework for understanding ViT finetuning, several questions remain. The link between forgetting variability and robustness was most prominent with the SGD optimizer, suggesting that optimization choice fundamentally alters invariance reorganization. Additionally, this study focused exclusively on ViTs; further research is required to determine if these patterns, such as the compression phenomenon, generalize to Convolutional Neural Networks (CNNs).

6. Conclusion

Finetuning is not merely a process of weight adjustment but a complex reorganization of invariances. By compressing pretrained knowledge into shallower layers, ViTs efficiently balance the retention of general features with the acquisition of task-specific information. This invariance-based perspective offers a promising path toward more interpretable and robust transfer learning strategies.

Summary updated

BibTeX
@inproceedings{merlin2023what,
  author = {Gabriele Merlin and Vedant Nanda and Ruchit Rawal and Mariya Toneva},
  title = {{What Happens During Finetuning of Vision Transformers: An Invariance Based Investigation}},
  booktitle = {Collas},
  year = {2023},
}
Figure