TL;DR
Fine-tuning, a common method for adapting pretrained models, can surprisingly hurt out-of-distribution (OOD) performance when pretrained features are good and the distribution shift is large. This paper shows that fine-tuning distorts these valuable features, leading to worse OOD accuracy than simpler linear probing. A hybrid approach, linear probing followed by fine-tuning (LP-FT), effectively mitigates this tradeoff, achieving better performance on both in-distribution (ID) and OOD tasks.
What Problem Does This Paper Address?
When we want to use a powerful pretrained model (like one trained on ImageNet) for a new task, we have a few options. The most common is "fine-tuning," where we update all the model's parameters. Another is "linear probing," where we only train the final classification layer (the "head") and keep the rest of the model's learned features frozen. While fine-tuning usually leads to better accuracy on data similar to the training set (in-distribution, ID), this paper investigates what happens when the test data comes from a different distribution (out-of-distribution, OOD). The challenge is that in real-world applications (like self-driving cars or medical diagnosis), models must generalize to unseen scenarios. The paper asks: does fine-tuning, which adapts all parameters, always lead to better generalization, especially OOD, compared to the more conservative linear probing?
Methods
The authors tackle this problem with a combination of theoretical analysis and empirical validation.
Theoretical Analysis: They develop a theoretical framework using simplified linear models (two-layer linear networks) to understand the core mechanisms at play. They mathematically prove that when pretrained features are "good" (i.e., already capture useful information) and the distribution shift is significant, fine-tuning can distort these features. This distortion occurs because the gradient updates, aiming to improve ID performance, simultaneously modify both the head and the feature extractor. This coupling leads the feature extractor to adapt to the ID data in a way that makes it perform poorly on OOD data. They also theoretically show that a simple two-step strategy, linear probing first to find a good head and then fine-tuning (LP-FT), can preserve the benefits of both approaches.
Empirical Validation: They conduct experiments on a variety of distribution shift datasets. They compare fine-tuning, linear probing, and their proposed LP-FT method. They also perform ablations to examine the impact of feature distortion, early stopping, and different architectures.
Datasets
The paper uses a diverse set of datasets to evaluate their methods across various distribution shifts:
- DomainNet: A standard domain adaptation dataset with "sketch" images as ID and "real," "clipart," and "painting" images as OOD.
- Living-17 and Entity-30: Sub-population shift datasets from the BREEDS benchmark, where ID and OOD datasets contain different but related categories (e.g., different types of bears).
- FMoW Geo-shift: Adapted from a satellite imagery dataset, with ID from North America and OOD from Africa and Europe.
- CIFAR-10 → STL: A standard domain adaptation task.
- CIFAR-10 → CIFAR-10.1: A dataset with a "minute distributional shift."
- ImageNet: Fine-tuning on ImageNet-1K and evaluating on four OOD variants: ImageNetV2, ImageNet-R, ImageNet-A, and ImageNet-Sketch.
Key Insights and Ideas
- Fine-tuning can hurt OOD performance: Counterintuitively, when pretrained features are good and the distribution shift is large, fine-tuning can lead to worse OOD accuracy than linear probing. This is a significant finding, as fine-tuning is often assumed to be superior.
- Feature Distortion is the culprit: The core reason for fine-tuning's OOD degradation is that it distorts the valuable pretrained features. The simultaneous updates to the head and feature extractor, driven by ID data, cause the feature extractor to change in ways that are detrimental to OOD generalization.
- Linear Probing Preserves Features: Linear probing, by freezing the feature extractor, inherently preserves these pretrained features, leading to better OOD performance when the shift is large.
- LP-FT: The Best of Both Worlds: The proposed LP-FT strategy, which first performs linear probing to find a good head and then fine-tunes, effectively combines the benefits of both methods. It leverages the feature preservation of linear probing while allowing for some adaptation, leading to improved performance on both ID and OOD tasks.
- Pretrained Feature Quality Matters: The phenomenon of fine-tuning underperforming linear probing OOD is more pronounced when the pretrained features are of high quality. With lower quality features, fine-tuning might be more beneficial as it has more room to adapt.
Key Results
- On 10 distribution shift datasets, fine-tuning achieved 2% higher ID accuracy but 7% lower OOD accuracy on average compared to linear probing.
- The LP-FT method consistently outperformed both fine-tuning and linear probing, achieving 1% better ID accuracy and 10% better OOD accuracy on average across the tested datasets.
- Empirical analysis showed that fine-tuning indeed distorts features more for ID examples than OOD examples, and LP-FT caused significantly less feature change (20x smaller) compared to fine-tuning.
- When pretrained features were intentionally degraded (e.g., using MoCo-v1 instead of MoCo-v2), fine-tuning performed better OOD than linear probing, supporting the theory that high-quality features are key to the observed tradeoff.
Limitations and Future Work
- Theoretical Model Simplification: The theoretical analysis primarily uses linear models. While insightful, extending these results to non-linear deep networks with more complex architectures remains a challenge.
- Non-linear Activations and Layerwise Rates: The authors suggest future work could explore the impact of non-linear activations and different learning rates for different layers.
- Explicit Regularization: The effect of explicit regularization on fine-tuning and OOD performance is an open question.
- Broader Applicability of LP-FT: While LP-FT is shown to be effective, the authors hope their theoretical insights will inspire even better methods for robust fine-tuning. They also note that LP-FT is not necessarily a state-of-the-art method but a principled approach.
- Dataset Size: The paper acknowledges that in some cases with very small training datasets, linear probing might outperform fine-tuning even in-distribution, though this is less of an issue with larger datasets.
Summary updated