Source-linked AI summary

Fine-Tuning can Distort Pretrained Features and Underperform Out-of-Distribution

Ananya Kumar, Aditi Raghunathan, Robbie Jones, Tengyu Ma, Percy Liang

arXiv:2202.10054v1cs.LGcs.CV

TL;DR

The paper asks when fine-tuning a pretrained model can underperform linear probing under distribution shift. Through theory for overparameterized two-layer linear networks and experiments across ten benchmarks, it finds that LP-FT improves the ID–OOD tradeoff by first learning a head and then fine-tuning.

  • Problem

    Fine-tuning is known to improve ID accuracy, but its OOD accuracy relative to linear probing under large shifts is not well understood.

  • Method

    The paper analyzes fine-tuning dynamics in an overparameterized two-layer linear network and evaluates fine-tuning, linear probing, and LP-FT across distribution-shift benchmarks.

  • Results

    Across ten benchmarks, fine-tuning raises average ID accuracy from 83% to 85% but lowers average OOD accuracy from 66% to 59% relative to linear probing, while LP-FT outperforms both methods.

  • Takeaways & Limitations

    Preserving pretrained features can improve robustness, and initializing fine-tuning with a linear-probed head can mitigate the ID–OOD tradeoff.

  • Takeaways & Limitations

    The theory is developed in an overparameterized linear setting, and extending it to the neural tangent kernel regime remains an open direction.

Abstract

from arXiv · show

When transferring a pretrained model to a downstream task, two popular methods are full fine-tuning (updating all the model parameters) and linear probing (updating only the last linear layer -- the "head"). It is well known that fine-tuning leads to better accuracy in-distribution (ID). However, in this paper, we find that fine-tuning can achieve worse accuracy than linear probing out-of-distribution (OOD) when the pretrained features are good and the distribution shift is large. On 10 distribution shift datasets (Breeds-Living17, Breeds-Entity30, DomainNet, CIFAR $\to$ STL, CIFAR10.1, FMoW, ImageNetV2, ImageNet-R, ImageNet-A, ImageNet-Sketch), fine-tuning obtains on average 2% higher accuracy ID but 7% lower accuracy OOD than linear probing. We show theoretically that this tradeoff between ID and OOD accuracy arises even in a simple setting: fine-tuning overparameterized two-layer linear networks. We prove that the OOD error of fine-tuning is high when we initialize with a fixed or random head -- this is because while fine-tuning learns the head, the lower layers of the neural network change simultaneously and distort the pretrained features. Our analysis suggests that the easy two-step strategy of linear probing then full fine-tuning (LP-FT), sometimes used as a fine-tuning heuristic, combines the benefits of both fine-tuning and linear probing. Empirically, LP-FT outperforms both fine-tuning and linear probing on the above datasets (1% better ID, 10% better OOD than full fine-tuning).

1 Introduction

The paper shows that fine-tuning can improve ID accuracy yet underperform linear probing under large distribution shifts because it distorts pretrained features. It develops theory and experiments supporting LP-FT as a way to improve both ID and OOD performance.

  • Fine-tuning improves average ID accuracy from 83% to 85% but reduces average OOD accuracy from 66% to 59% across ten distribution-shift benchmarks.The comparison uses pretrained features from MoCo-v2 and CLIP.
  • Fine-tuning can distort pretrained features because the head and feature extractor are optimized simultaneously for ID training data.The resulting head accommodates distorted ID features and performs poorly on less-changed OOD features.
  • Linear probing preserves pretrained features and extrapolates better OOD, but it cannot adapt those features to the downstream task and therefore performs worse ID.
  • The theoretical analysis addresses fine-tuning dynamics, which are difficult to study because fine-tuning and training from scratch optimize the same loss but start from different initializations.
  • LP-FT first learns a head by linear probing and then fine-tunes the full model, outperforming both fine-tuning and linear probing on ID and OOD metrics.The first linear-probing stage is relatively cheap, so LP-FT uses similar compute to vanilla fine-tuning.
  • Empirically, fine-tuning never matches linear probing's OOD accuracy during training when pretrained features are good and the OOD shift is large.LP-FT changes ID and OOD features 10×–100× less than fine-tuning does.

2 Setup

The setup evaluates predictors built from a pretrained feature extractor and linear head on both ID and OOD distributions. It compares linear probing, which freezes the extractor, with fine-tuning, which updates both the head and extractor.

  • ID performance is evaluated on new test samples from the training distribution, while OOD performance is evaluated on samples from a different distribution.
  • The predictor maps inputs to outputs by applying a linear head v to features g_B(x) produced by feature-extractor parameters B.The experiments use a deep-network extractor, while the theory uses a linear projection.
  • The pretrained feature extractor B0 is obtained from potentially large amounts of data containing unlabeled or weakly supervised inputs from both ID and OOD distributions.
  • Linear probing fixes B = B0 and optimizes only the linear head, whereas fine-tuning optimizes both v and B by gradient descent on downstream training data.

3 Theory: fine-tuning distorts pretrained features

The theory explains how full fine-tuning can distort good pretrained features, producing higher OOD error than linear probing under large distribution shifts while often improving ID performance.

  • Setting: Fine-tuning updates both the feature extractor and head in an overparameterized two-layer linear model, whereas linear probing updates only the head.The analysis focuses on regression with squared loss and linear feature extractors.
  • Key intuitions: Feature distortion occurs because fine-tuning changes features in directions within the training-data span but leaves orthogonal directions unchanged.This asymmetric update can make ID and OOD representations inconsistent.
  • OOD theory: When pretrained features are perfect, linear probing has zero OOD error, while fine-tuning retains positive OOD error at all times under the theorem’s conditions.The result applies when the relevant principal-angle non-degeneracy condition holds.
  • OOD theory: As feature-extractor error approaches zero, the ratio of linear-probing to fine-tuning OOD losses approaches zero under mild non-degeneracy conditions.Thus, sufficiently good pretrained features can make linear probing substantially better OOD than fine-tuning.
  • ID–OOD tradeoff: Fine-tuning can achieve lower ID error than linear probing when pretrained features are imperfect because it updates features to fit the ID data.The resulting tradeoff is lower ID error but higher OOD error for fine-tuning than for linear probing.
  • Mitigating the tradeoff: With a randomly initialized head, fine-tuning has positive OOD error at every time step, while initializing the head through linear probing improves fine-tuning’s OOD performance.The theory motivates the two-step LP-FT strategy, which first finds a good head and then fine-tunes all parameters.

4 Experiments

Across ten distribution-shift benchmarks, fine-tuning generally improves ID accuracy but linear probing is stronger under large OOD shifts. LP-FT achieves the best overall ID and OOD performance, while feature-distortion analyses support the proposed explanation.

  • Fine-tuning exceeds linear probing on 5 of 6 ID datasets, averaging 85.1% versus 82.9% accuracy.
  • Linear probing exceeds fine-tuning on 8 of 10 OOD datasets, averaging 66.2% versus 59.3% accuracy.The exceptions are CIFAR-10.1 and ImageNetV2, whose OOD datasets closely resemble their ID datasets.
  • LP-FT achieves the best average accuracy both ID at 85.7% and OOD at 68.9%.It is best on 5/6 ID datasets and all 10 OOD datasets, except that fine-tuning remains better on FMoW ID.
  • Fine-tuning changes ID features more than OOD features, with the observed distortion supporting the feature-distortion theory.The analysis measures Euclidean feature changes before and after fine-tuning on Living-17.
  • When ID and OOD distributions are very similar, fine-tuning can also outperform linear probing OOD, while LP-FT remains strongest.On CIFAR-10→CIFAR-10.1, fine-tuning reaches 92.3%, linear probing 82.7%, and LP-FT 93.5%.

5 Related work and discussion

The discussion situates the work within research on lightweight transfer and theoretical analyses of fine-tuning. It emphasizes LP-FT as a simple robustness intervention that requires no extra unlabeled data.

  • Lightweight fine-tuning methods are increasingly associated with better performance under distribution shift by preserving pretrained features.The paper provides a theoretical grounding for this broader empirical pattern.
  • LP-FT addresses the ID-OOD tradeoff without extra unlabeled data and is a simple variant of fine-tuning.The discussion contrasts it with self-training and mentions weight ensembling as a concurrent alternative.
  • Prior transfer-learning theory mainly analyzes linear probing, whereas this work studies fine-tuning in an overparameterized regime.The analysis must track optimization trajectories from pretrained initialization rather than only characterize loss minimizers.
  • The paper’s comparison with prior work is not intended to be comprehensive.

6 Conclusion.

The conclusion argues that preserving pretrained features can improve robustness, especially as pretraining quality increases. It presents LP-FT as a promising but preliminary approach and identifies several theoretical extensions.

  • Preserving pretrained features can improve OOD performance, making linear probing a useful alternative to full fine-tuning.The OOD gap between fine-tuning and linear probing grows as pretrained feature quality improves.
  • The theoretical framework leaves open extensions to nonlinear activations, layerwise learning rates, and explicit regularization.
  • LP-FT mitigates the ID-OOD tradeoff in the paper’s setting and can initialize fine-tuning with a zero-shot classifier in CLIP.
  • LP-FT outperforms explicit regularization and higher learning rates for the linear layer on Living-17, although broader study remains necessary.

A.2 Feature distortion theorem

The appendix proves that fine-tuning can distort pretrained features and retain a nontrivial OOD error throughout training in an overparameterized two-layer linear setting. The bounds depend on relationships between pretrained feature directions and directions outside the training-data span.

  • The core theorem proves that fine-tuning distorts pretrained features in the overparameterized linear setting.
  • If the largest principal-angle cosine between pretrained feature directions and the training-span complement is positive, fine-tuning has a lower-bounded OOD error at every time.
  • The proof uses that features do not change in directions perpendicular to the span of the training examples, while the head and feature extractor remain coupled.
  • The analysis relies on an overparameterized linear model and principal-angle conditions linking optimal feature directions to both the ID span and its complement.
  • As pretrained representations approach the optimal representation, the OOD-error ratio of linear probing to fine-tuning converges to zero in probability.

A.3.2 Bounding the head error

The analysis bounds head error under zero and Gaussian-random initialization, showing that randomly initialized heads typically begin substantially misaligned with the target head.

  • The zero initialization case has head error equal to the squared norm of the target head.
  • A Gaussian variable cannot concentrate too closely around any fixed nonzero target, regardless of its variance.
  • For Gaussian head initialization v0 ∼ N(0, σ2I), the head error is typically at least proportional to the squared norm of the target head, for every variance σ2.
  • The head error is unchanged when the initial head is negated, allowing the Gaussian analysis to assume a convenient orientation.

A.3.3 Upper bounding linear probing error

This section establishes an upper bound on linear probing’s OOD error by characterizing its unique head solution under the pretrained feature extractor and bounding the resulting terms.

  • Under the ID subspace assumption, the data matrix factorizes as X = ZF^T, where F spans the ID subspace.
  • The matrix B0X^TXB0^T is invertible almost surely, so linear probing has a unique global loss minimizer over the head.
  • The proof bounds linear probing’s square-root OOD error by decomposing it into terms and controlling the relevant singular values.
  • The OOD bound depends on the pretrained representation’s alignment with the ID subspace, including the principal-angle factor.
  • The resulting bounds apply without Gaussian covariates and become more quantitative when the ID covariates are Gaussian.

A.4 LP vs. FT (OOD), non-asymptotic result for Gaussian covariates

For Gaussian covariates, the non-asymptotic analysis gives conditions under which linear probing has lower OOD error than fine-tuning throughout the fine-tuning trajectory.

  • The result extends beyond Gaussian covariates to iid mean-zero sub-Gaussian coordinates with constant nonzero variance.
  • The threshold for linear probing to outperform fine-tuning depends on representation dimension, sample size, and angles between the ID subspace and important pretrained directions.
  • The theorem assumes Gaussian covariates on the ID subspace, nondegenerate principal angles, sufficient sample size, and a pretrained representation with sufficiently small error.
  • Under these conditions, linear probing has lower OOD error than fine-tuning at every time step t ≥ 0.
  • Random-subspace arguments show that the required principal-angle cosines are nonzero almost surely under the stated dimensional conditions.

A.6 LP vs. FT (ID)

In the overparameterized linear setting, fine-tuning achieves better ID performance when the pretrained representation is imperfect, while linear probing can retain nonzero ID error.

  • Thus, when the optimal model is not already in the pretrained feature rowspace and the relevant principal angle is nonzero, fine-tuning does better ID almost surely.
  • If fine-tuning converges to a local minimum, it reaches zero training loss and therefore zero ID error under the stated spanning assumptions.
  • Linear probing has positive ID error when the optimal model’s projection onto the ID subspace lies outside the projected pretrained feature rowspace.
  • The condition for positive linear-probing error is expressed through the span of the pretrained feature rowspace combined with the optimal model.

A.7 LP-FT

The section formalizes when LP-FT preserves the benefits of linear probing while enabling full fine-tuning. In the analyzed linear setting, linear probing can achieve zero OOD loss, whereas randomly initialized-head fine-tuning retains positive OOD loss.

  • A.7 LP-FT: With perfect pretrained features, linear probing achieves zero OOD loss under the proposition’s non-degeneracy condition.The proposition states zero OOD loss for all training times after convergence to the linear-probing solution.
  • A.7 LP-FT: Linear probing keeps the pretrained feature extractor fixed and tunes only the head, yielding a strongly convex loss with a unique minimizer in the stated setting.Gradient flow therefore converges to the unique minimizer.
  • A.7 LP-FT: When the head is initialized at the appropriate optimum, both gradients vanish, so the fine-tuned parameters remain unchanged and OOD loss stays zero.The proof uses a rotated perfect feature extractor and matching head.
  • A.7 LP-FT: Randomly initialized-head fine-tuning has positive OOD loss throughout training under the corresponding non-degeneracy conditions.The result applies even though the feature extractor and head are trained jointly.
  • A.7 LP-FT: Across the three DomainNet OOD domains, LP outperforms FT across the board, while LP-FT performs best.The table reports 90% confidence intervals over three runs.

B.1 Dataset and method details

The experiments use diverse distribution-shift benchmarks, pretrained models, and adaptation protocols. Across the evaluated settings, linear probing typically remains stronger OOD than fine-tuning, while feature-change measurements support the predicted distortion mechanism.

  • B.1 Dataset and method details: The evaluation spans CIFAR→STL, DomainNet, Living-17, Entity-30, FMoW Geo-shift, CIFAR-10.1, and four ImageNet shifts.Protocols vary by dataset, including domain, subpopulation, geographic, and corruption-style shifts.
  • B.1 Dataset and method details: The experiments use MoCo-v2, MoCo-TP, and CLIP-pretrained models selected to provide useful features for the target datasets.The authors note that weaker pretrained features may allow fine-tuning to perform better OOD.
  • B.1 Dataset and method details: Even when fine-tuning selects learning rates and early-stopping points using OOD data, linear probing averages 67.1% OOD accuracy versus 61.3% for fine-tuning.The only reported reversal from the earlier comparison is on FMoW.
  • B.1 Dataset and method details: Feature changes are measured as average Euclidean distances between pretrained and adapted ResNet-50 features on held-out ID and OOD examples.The distances are reported separately in Tables 5 and 6 and multiplied by 100.
  • B.1 Dataset and method details: ID features change more than OOD features in 9 out of 10 cases under fine-tuning.This comparison matches the feature-distortion theory’s prediction.
  • B.1 Dataset and method details: Across all datasets, LP-FT changes features substantially less than fine-tuning, supporting its stronger ID and OOD performance.On CIFAR-10, the cited example reports a 30× reduction in feature change for LP-FT.

B.4 Additional architectures, fine-tuning methods

Additional architectures and adaptation heuristics reproduce the central pattern: fine-tuning can lose to linear probing OOD, while LP-FT improves ID performance and recovers much of the OOD gap. The section also motivates heuristics that reduce feature distortion.

  • B.4 Additional architectures, fine-tuning methods: CLIP ResNet-50 and CLIP ViT-B/16 experiments reproduce the pattern of better fine-tuning ID performance but worse OOD performance than linear probing.The ViT-B/16 result uses the largest publicly available CLIP model identified by the authors.
  • B.4 Additional architectures, fine-tuning methods: LP-FT performs better than both methods ID and closes 86% of the OOD gap with the CLIP ResNet-50.The result is reported on Living-17.
  • B.4 Additional architectures, fine-tuning methods: LP-FT performs better than both methods ID and closes 75% of the OOD gap with CLIP ViT-B/16.This provides a corresponding result for the larger vision transformer.
  • B.4 Additional architectures, fine-tuning methods: Even with OOD-based early stopping, fine-tuning reaches 84.4 ± 0.5% OOD accuracy, below LP’s 88.3 ± 0.2%.LP-FT reaches 87.9 ± 0.4%, with no statistically significant difference from LP in that comparison.
  • B.4 Additional architectures, fine-tuning methods: The theory motivates higher head learning rates and feature-weight regularization as ways to reduce distortion during adaptation.The regularization approach corresponds to L2-SP, while side-tuning freezes pretrained features and adds a side network.
  • B.4 Additional architectures, fine-tuning methods: All fine-tuning methods and linear probing substantially outperform training from scratch on both ID and OOD accuracy.The compared training-from-scratch runs used 450 epochs, versus 20 epochs for fine-tuning.

B.5 Discussion of effective robustness

Linear probing and LP-FT show higher effective robustness than fine-tuning across the reported comparisons, including matched-ID settings and Living-17 curves. However, higher effective robustness alone does not establish overall superiority, because it can result from worse ID accuracy.

  • Linear probing has higher effective robustness in most datasets despite lower ID accuracy than fine-tuning.This reverses the expectation that lower ID accuracy should imply lower OOD accuracy under the effective-robustness framework.
  • LP-FT achieves 8% higher OOD accuracy than fine-tuning on CIFAR-10 →STL without a statistically significant ID-accuracy difference.
  • At matched 97.2% ID accuracy on CIFAR-10 →STL, LP-FT reaches 90.2% OOD accuracy versus 81.8% for fine-tuning.
  • On Living-17, LP-FT’s ID-OOD line lies above fine-tuning’s across pretrained CLIP and MoCo-V2 models, indicating higher effective robustness.Figure 3 averages each point over three random seeds.
  • Higher effective robustness is not sufficient to show that a method is better, since it can arise from substantially worse ID accuracy at equal OOD accuracy.
Loading 2202.10054v1…