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

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

Introduction

Pretraining a model on a large dataset before transferring to a downstream task’s training data substantially improves accuracy over training from scratch—for example, pretraining a ResNet-50 on unlabeled ImageNet boosts accuracy on CIFAR-10 from 94% to 98% (Chen et al., 2020a, b). Achieving high in-distribution accuracy is not enough: high-stakes applications such as poverty mapping in under-resourced countries (Jean et al., 2016), self-driving cars (Yu et al., 2020), and medical diagnosis (AlBadawy et al., 2018), require models that also generalize to circumstances not seen in the training distribution. In addition to testing on data drawn from the downstream task’s training distribution (in-distribution; ID), it is increasingly important to test on data distributions unseen during training (out-of-distribution; OOD). OOD accuracy can be much lower than ID accuracy; for example, an ImageNet pretrained ResNet-50 fine-tuned on CIFAR-10 gets 98% accuracy on CIFAR-10 (ID) but 82% on STL (OOD).

After initializing with a pretrained model, two popular transfer methods are fine-tuning (running gradient descent on all the model parameters), and linear probing (tuning the head but freezing lower layers). In the ID setting, it is well known that fine-tuning leads to better accuracy than linear probing (Kornblith et al., 2019; Zhai et al., 2020; He et al., 2020),Probing is commonly used but usually for interpretability or assessing feature quality. and even when testing OOD, prior work usually fine-tunes all parameters of their model (Hendrycks et al., 2019a; Miller et al., 2021; Andreassen et al., 2021). Intuitively, fine-tuning all layers of a network can improve pretrained features by adapting them to the specific task, while linear probing simply inherits the frozen pretrained features.

In this work, we investigate the OOD accuracy of fine-tuning and linear probing and find that surprisingly, fine-tuning can do worse than linear probing in the presence of large distribution shift. We experiment on ten distribution shift benchmarks (Breeds Living17, Breeds Entity30, DomainNet, CIFAR →\to STL, CIFAR10.1, FMoW geo-shift, ImageNetV2, ImageNet-R, ImageNet-A, ImageNet-Sketch), initializing with good pretrained features from MoCo-v2 (Chen et al., 2020b) and CLIP (Radford et al., 2021). While both methods offer gains over training from scratch, fine-tuning improves the average ID accuracy relative to linear probing from 83%83\% to 85%85\% but brings down the OOD accuracy from 66%66\% to 59%59\% (Figure 1).

Under what conditions does fine-tuning underperform linear probing? We theoretically consider fine-tuning a two-layer linear network in an overparameterized regression setting where the feature extractor layer has been pretrained to map high-dimensional inputs to useful, lower-dimensional, features. We prove that fine-tuning is worse than linear probing on directions outside the span of the training data when using “good” pretrained features. Even with an infinitesimally small learning rate, fine-tuning distorts pretrained features—the features of ID training data are updated while those of OOD data change less. Since the head and feature extractor are simultaneously optimized during fine-tuning to a configuration that works well on ID training data, the head only accomodates the distorted features of ID points and performs poorly (relative to linear probing) on the less changed features of OOD points. Interestingly, we show that this feature distortion issue cannot be simply fixed by early stopping—throughout the entire process of fine-tuning, we never pass through parameters that do well OOD (relative to linear probing). On the other hand, given “good” features, linear-probing extrapolates better OOD because it preserves pretrained features, but does not do as well as fine-tuning ID because linear probing cannot adapt the features to the downstream task.

Technical challenges. Existing theoretical work on transfer learning focuses on linear probing (Wu et al., 2020; Tripuraneni et al., 2020; Du et al., 2020). In contrast, analyses of fine-tuning is scarce and challenging because it requires understanding the training dynamics, instead of only the loss function and its global minimizers. In fact, fine-tuning and training from scratch optimize the same training loss and only differ in their initializations (pretrained vs random). A mathematical analysis that distinguishes them needs to capture properties of the different minima that these algorithms converge to, a phenomenon that is sometimes theoretically referred to as the implicit regularization effect of initialization (Neyshabur et al., 2014). Accordingly, our analysis reasons about the parameters that gradient methods pass through starting from the pretrained initialization, which is challenging because this is a non-convex optimization problem and there is no known closed form for this trajectory. Two-layer linear networks are widely studied in the literature on implicit regularization (Saxe et al., 2014; Gunasekar et al., 2017; Gidel et al., 2019; Arora et al., 2018). However, they analyze random and often small initializations, which don’t capture pretraining.

Algorithmic implications. Our theory shows that fine-tuning underpeforms because when trying to fit ID training data with a randomly initialized head, the feature extractor changes significantly for ID examples, making features for ID and OOD examples largely inconsistent. This can be fixed by initializing with a good head that does not need to be updated much during fine-tuning, reducing how much the feature extractor changes. This suggests a simple two-step strategy of first linear-probing to find a good head and then full fine-tuning (LP-FT). Empirically, LP-FT outperforms fine-tuning and linear-probing, both ID and OOD. Even on CIFAR-10.1 (small distribution shift), where fine-tuning is better for both ID and OOD, we find LP-FT outperforms fine-tuning on both metrics. LP-FT and vanilla fine-tuning use similar amounts of compute because the first step of linear probing is relatively very cheap. Prior work has used LP-FT (Levine et al., 2016; Kanavati & Tsuneki, 2021) (or variants such as layerwise fine-tuning (Howard & Ruder, 2018) or larger learning rates for the head layer (Prabhu et al., 2021))—however it has not been used for robustness / OOD accuracy, and we show that it addresses the ID-OOD tradeoff theoretically and empirically. Note that LP-FT is not meant to be a SOTA method but a simple, principled way to get good ID and OOD accuracy—we hope our analysis inspires even better methods for robust fine-tuning.

Empirical validation. Finally, we check whether fine-tuning underperforms and LP-FT works, for the reasons predicted by our feature distortion theory. As predicted by the theory, we find that: (1) fine-tuning indeed never matches the OOD accuracy of linear probing throughout the course of training (if the pretrained features are good, and OOD shift is large); (2) fine-tuning changes the features for ID examples more than for OOD examples, leading to distortions; (3) LP-FT indeed changes both ID and OOD features 10×−100×10\times-100\times less than fine-tuning does; (4) fine-tuning can do better than linear probing OOD if the pretrained features are not very high quality (MoCo-v1 instead of MoCo-v2) or the ID and OOD datasets are very close (e.g., CIFAR-10 and CIFAR-10.1); and (5) LP-FT gets the best of both worlds, better accuracies than fine-tuning and linear probing, both ID and OOD (Figure 1).

Setup

We assume access to some initial pretrained feature extractor B0B_{0} that is obtained by training on potentially large amounts of data from a distribution that contains unlabeled or weakly supervised xx inputs from PidP_{\mathsf{id}} and PoodP_{\mathsf{ood}}. We focus on two popular methods to learn a predictor fv,Bf_{v,B} given training data from PidP_{\mathsf{id}}: (i) linear probing where B=B0B=B_{0} and the linear head is obtained by minimizing some loss (e.g., logistic loss for classification, squared loss for regression) on the training data, and (ii) fine-tuning where both vv and BB are updated by performing gradient descent on some loss on the training data with BB initialized at B0B_{0}.

Theory: fine-tuning distorts pretrained features

Our goal is to understand under what conditions fine-tuning does worse than linear probing out-of-distribution (OOD).For example, without additional assumptions we can have Pid=PoodP_{\mathsf{id}}=P_{\mathsf{ood}} and so the same method will do better both ID and OOD. We consider a linear setting (feature extractor gBg_{B} is linear) where the pretrained features are “good” and the OOD shift is large (Section 3.1). We prove our main result: that fine-tuning, in which all model parameters are updated, distorts features and gets suboptimal OOD error (Section 3.2, Theorem 3.3). We use this result to show that linear probing gets better OOD error but worse ID error than fine-tuning (Section 3.3). Finally, we explain why linear probing then fine-tuning can mitigate this ID-OOD tradeoff (Section 3.4).

Our analysis handles two key challenges which distinguishes it from prior work on transfer learning in linear models (Wu et al., 2020; Tripuraneni et al., 2020; Du et al., 2020; Xie et al., 2021a). Prior work focuses on linear probing, while we study fine-tuning where the resulting optimization problem is non-convex. We also study overparameterized models where the training loss alone does not determine test performance—this captures the fact that both training neural networks from scratch and fine-tuning them have the same training loss but very different test performance. However, it also makes the analysis challenging because we need to reason about the trajectory of gradient methods starting from a pretrained initialization, which has no known closed form.

Pretraining coverage intuition: Intuitively, the existence of B⋆B_{\star} corresponds to assuming that there exists a shared set of useful features for ID (PidP_{\mathsf{id}}) and OOD (PoodP_{\mathsf{ood}}). We also assume that B0B_{0} is close to B⋆B_{\star}—one way this can happen is if pretraining is done on large scale data and has seen unlabeled or weakly supervised xx inputs that cover the support of PidP_{\mathsf{id}} and PoodP_{\mathsf{ood}}. Formally, the task diversity assumption in Tripuraneni et al. (2020) is sufficient (but not necessary) for obtaining a good B0B_{0}. In our paper we show that even if we have these good features, fine-tuning can distort them and lead to low OOD accuracy.

Training methods. Given training data and a pretrained feature extractor B0B_{0}, we study the two popular methods of linear probing (LP) and fine-tuning (FT) to learn the final predictor. Both methods involve optimizing the training loss via gradient descent (or variants). In order to effectively analyze these gradient based algorithms, we study vanishing step sizes leading to gradient flows. Gradient flows can be thought of as a continuous time analogue of gradient based methods and have been extensively studied in recent years as a way to understand gradient based methods (Gunasekar et al., 2017; Arora et al., 2018; Du et al., 2018).

Formally, for training loss L^(v,B)=∥XB⊤v−Y∥22\widehat{L}(v,B)=\|XB^{\top}v-Y\|_{2}^{2}, the gradient flow differential equations for LP and FT are as follows:

initialized with Bft(0)=Blp(0)=B0{B_{\mathsf{ft}}}(0)={B_{\mathsf{lp}}}(0)=B_{0} and vft(0)=vlp(0)=v0{v_{\mathsf{ft}}}(0)={v_{\mathsf{lp}}}(0)=v_{0}. In practice, the head parameter v0v_{0} is initialized randomly—our results hold for any standard random initialization (Glorot & Bengio, 2010), for example v0∼N(0,σ2I)v_{0}\sim\mathcal{N}(0,\sigma^{2}I) for any σ2\sigma^{2}, or zero initialization where v0=0v_{0}=0. Recall that the initial value of the feature extractor B0B_{0} is obtained via pretraining.

The final LP and FT solutions are the limit points of the corresponding gradient flows:

2 Fine-tuning distorts pretrained features

The more common method of using a pretrained feature extractor is fine-tuning (FT) which typically improves ID performance relative to linear probing (LP). In this section, we show theoretically that FT can distort features leading to poor OOD performance. We first present the key intuitions demonstrating potential issues of FT and then present our formal theorem lower bounding the OOD error of FT (Section 3.2.2).

There are two main observations that we use to characterize when and why FT has higher OOD error than linear probing.

1. Features get distorted: representations change only in the ID subspace (i.e., subspace spanned by the training data) and are unchanged in the orthogonal subspace. To see this, we take the derivative of the training loss L^(v,B)=∥XB⊤v−Y∥22\widehat{L}(v,B)=\|XB^{\top}v-Y\|_{2}^{2} with respect to the feature extractor parameter BB:

By definition, if uu is a direction orthogonal to the training subspace S=\mboxrowspace(X)S=\mbox{rowspace}(X), then ∇BL^(v,B)u=0\nabla_{B}\widehat{L}(v,B)u=0, that is the gradient updates to BB do not modify BuBu for u∈S⊥u\in S^{\perp}. However, the gradient is non-zero for directions uu in the ID subspace and the corresponding features BuBu change across the fine-tuning process. We call this feature distortion: the features in some directions are changed but not others. Next, we explain why this can lead to high OOD error.

2. Distorted features can lead to higher OOD error. Consider a toy example (Figure 2) where d=2d=2 and the dimensionality of the representations k=1k=1. The linear head vv is a scalar quantity that denotes how much the feature extractor BB has to be scaled by. Suppose the ID-subspace is the xx-axis. There are different ways of fitting the ID subspace depending on the feature extractors BB as shown in the Figure—both fine-tuned and linear probed estimators match the true parameter in the ID subspace (since wlp,wft,w⋆{w_{\mathsf{lp}}},{w_{\mathsf{ft}}},w_{\star} have the same projection on the xx-axis). If the feature extractor were optimal or scaled versions of the optimal, good performance on the ID subspace would translate to good performance everywhere, even in directions orthogonal to the ID subspace. However, in FT, the features change only for inputs in the ID subspace (see (1)) and thus the updated features are not simply scaled but distorted. In Figure 2, this corresponds to the feature extractor B0B_{0} changing along the xx-axis. In this case even if the ID error is low, error in directions orthogonal to the ID subspace can be high, leading to high OOD error.

The only way the pretrained features are not distorted and only scaled during FT is if the initial feature extractor B0B_{0} is exactly aligned with the ID subspace. In Figure 2, if B0B_{0} is along the xx-axis (the ID subspace), then updating the features exclusively along the xx-axis would simply scale the initial features. In this case linear probing and fine-tuning will have identical behavior. If the angle between B0B_{0} and the xx-axis is non-zero—which occurs with probability 11 if the training data XX or pretrained feature extractor B0B_{0} involves even a tiny amount of randomness e.g., from SGD in pretraining—the updates would lead to distortions. In high dimensions, we measure the alignment between B0B_{0} and the ID subspace with the largest principal angle:

Let AA and BB be arbitrary subspaces, and EE and FF be matrices with orthonormal columns than span AA and BB respectively, with r=min⁡(dim⁡(A),dim⁡(B))r=\min(\dim(A),\dim(B)). Then cos⁡θmax(A,B)=σr(E⊤F)\cos\theta_{\mathsf{max}}(A,B)=\sigma_{r}(E^{\top}F), which is the rr-th largest singular value of E⊤FE^{\top}F.

Note that E,FE,F are not unique in Definition 3.2, but σr(E⊤F)\sigma_{r}(E^{\top}F) is the same for every valid choice of EE and FF. See Appendix A.1 for more information on principal angles.

2.2 General result on the OOD error of fine-tuning

Our main theorem lower bounds the OOD error of fine-tuning outside the span of the training data. In Section 3.3 we compare this lower bound with an upper bound on the OOD error of linear probing.

In the overparameterized linear setting, let S⊥=\mboxrowspace(X)⊥S^{\perp}=\mbox{rowspace}(X)^{\perp}, R0=\mboxrowspace(B0)R_{0}=\mbox{rowspace}(B_{0}), and v⋆,B⋆v_{\star},B_{\star} be the optimal parameters with w⋆=B⋆v⋆w_{\star}=B_{\star}v_{\star}. If cos⁡θmax(R0,S⊥)>0\cos\theta_{\mathsf{max}}(R_{0},S^{\perp})>0, then for all time steps tt, the OOD error of the fine-tuning iterates (Bft(t),vft(t))({B_{\mathsf{ft}}}(t),{v_{\mathsf{ft}}}(t)) is lower bounded:

where φ2=∣(v0⊤v⋆)2−(v⋆⊤v⋆)2∣\varphi^{2}=\lvert(v_{0}^{\top}v_{\star})^{2}-(v_{\star}^{\top}v_{\star})^{2}\rvert is defined to be inital head alignment error and ϵ≥d(B0,B⋆)\epsilon\geq d(B_{0},B_{\star}) is the error in the pretrained feature extractor.

Proof sketch. Since the features do not change for examples in S⊥S^{\perp} (perpendicular to the training data), we show that in order to achieve low error on S⊥S^{\perp} the linear head vft(t){v_{\mathsf{ft}}}(t) would have to become very similar to the optimal v⋆v_{\star} at some time tt. The head initialization v0v_{0} is random (or zero) and likely to be far from v⋆v_{\star} (measured by the alignment error φ\varphi), so the head would have to change a lot to get close to v⋆v_{\star}. As we see from the fine-tuning gradient flow (3.2), vft(t){v_{\mathsf{ft}}}(t) and Bft(t){B_{\mathsf{ft}}}(t) change in a “coupled” manner, and a “’balancedness” invariant in Du et al. (2018) holds across the fine-tuning trajectory. Correspondingly, if vft(t){v_{\mathsf{ft}}}(t) changes a lot and gets close to v⋆v_{\star}, the features Bft(t){B_{\mathsf{ft}}}(t) also change a lot for examples in SS—we show that this would lead to high error on examples in SS. Either way, fine-tuning would get some subspace (SS or S⊥S^{\perp}) of examples wrong, leading to high OOD error. The full proof appears in Appendix A.

Interpretations of various quantities. Quality of pretrained features (ϵ\epsilon). To unpack the bound consider a special case where the pretrained features are perfect (ϵ=0\epsilon=0). With perfect features, Proposition A.20 shows that linear probing gets zero OOD error. Theorem 3.3 shows that Lood(vft(t),Bft(t))>0L_{\mathsf{ood}}({v_{\mathsf{ft}}}(t),{B_{\mathsf{ft}}}(t))>0 at all times tt—so fine-tuning underperforms when the features are perfect. The ϵ>0\epsilon>0 case just captures the fact that even if the features are not perfect, fine-tuning can still get positive error. Ideally we would like the lower bound to increase if we have worse features (so “+ϵ+\epsilon” instead of “−ϵ-\epsilon” in the bound)—the reason we do not is that the errors of the pretrained feature extractor d(B0,B⋆)d(B_{0},B_{\star}) and the fine-tuning step can potentially cancel out.Intuitively this cancelation is very “unlikely” to happen, and we hope future work can capture this intuition.

Alignment error of random head initialization (φ2\varphi^{2}). The lower bound (Equation A.14) increases as φ2\varphi^{2} increases i.e. alignment error increases because the gradient updates to the head and feature extractor are coupled. If the head were somehow initialized perfectly at v⋆v_{\star}, then fine-tuning updates may not increase the OOD error. However, when the head is randomly initialized (or initialized to zero) as is standard in fine-tuning, the alignment error is high, leading to high OOD error. We use this insight in Section 3.4 to show that better head initialization (namely via linear probing) improves OOD performance of fine-tuning.

Span of Training data (SS). Theorem 3.3 lower bounds the error outside the span of the training data. If the training dataset is very small, then even the support of the ID distribution PidP_{\mathsf{id}} may not be spanned by the training data, and the ID error can be large. Indeed, even in the ID setting Kornblith et al. (2019) show that linear probing can do better than fine-tuning if we have very few training examples, but fine-tuning does better on all 11 of their datasets once we have more than just 30 examples per class.

Conjectures for improved bounds. We believe it may be possible to improve cos⁡θmax(R0,S⊥)\cos\theta_{\mathsf{max}}(R_{0},S^{\perp}) to the cosine of the minimum principal angle.Which would be a larger/better lower bound since the cosine of a smaller quantity is larger. This may look like a technicality but would be a substantial improvement, because it would imply that fine-tuning has error in every direction outside the training span, whereas we show that it would have errors in some directions. Our proof strategy requires the maximum principal angle (a crucial step is a variational characterization of the maximal principal angle in Lemma A.2—we use this in Step 1 of the proof in Appendix A to show that to get low OOD error vft(t){v_{\mathsf{ft}}}(t) must become similar to v⋆v_{\star}).

3 Linear probing vs. fine-tuning

In this section, we use our main theorem on fine-tuning (Theorem 3.3) and adapt prior work on linear probing to show that linear probing is better than fine-tuning OOD, but worse ID, when the ID distribution has density on a lower m<dm<d dimensional subspace SS, and B0B_{0} is close to B⋆B_{\star} (so we have “good” pretrained features).

Recall that the ID error is the expected mean-squared error over the ID distribution PidP_{\mathsf{id}}:

OOD comparison: Under mild non-degeneracy conditions, we show that as the feature extractor error ϵ\epsilon goes to , linear probing does much better than fine-tuning OOD: the ratio of the losses goes to . The non-degeneracy conditions are similar to Section 3.2—we require that the training data cannot be exactly in the same direction or orthogonal to the pretrained features, formally that cos⁡θmax(R∗,S)\cos\theta_{\mathsf{max}}(R_{*},S) and cos⁡θmax(R∗,S⊥)\cos\theta_{\mathsf{max}}(R_{*},S^{\perp}) are not where R∗=\mboxrowspace(B⋆)R_{*}=\mbox{rowspace}(B_{\star}). In the toy example in Figure 2, this means that xidx_{\mathsf{id}} cannot be exactly in the same direction or orthogonal to B0⊤B_{0}^{\top}—in these cases fine-tuning and linear probing get the same loss but in all other cases in the toy example in Figure 2 linear probing does better OOD.

In the linear overparameterized setting, under the ID subspace assumption (Assumption 3.4), if cos⁡θmax(R∗,S)≠0\cos\theta_{\mathsf{max}}(R_{*},S)\neq 0 and cos⁡θmax(R∗,S⊥)≠0\cos\theta_{\mathsf{max}}(R_{*},S^{\perp})\neq 0 where R∗=\mboxrowspace(B⋆)R_{*}=\mbox{rowspace}(B_{\star}), then,

This holds for all times tt for FT (and therefore also for the limit vft∞,Bft∞{v_{\mathsf{ft}}^{\infty}},{B_{\mathsf{ft}}^{\infty}}) and the LP iterates converge to vlp∞,B0{v_{\mathsf{lp}}^{\infty}},B_{0} as a result of the gradient flow on a convex problem.

Intuitively, if the pretrained features are good, LP learns a near optimal linear head which has small OOD error (Lemma A.14) but fine-tuning has high OOD error (Theorem 3.3). We give a more formal version of Theorem 3.5 and a proof in Appendix A.3. If PzP_{z} is isotropic Gaussian, we can get a better result: Theorem A.15 derives a threshold TT (in terms of d,n,kd,n,k) where LP does better than FT if ϵ<T\epsilon<T, instead of just the asymptotic result (B0→B⋆B_{0}\rightarrow B_{\star}). Theorem 3.5 requires that cos⁡θmax(R∗,S)≠0\cos\theta_{\mathsf{max}}(R_{*},S)\neq 0 and cos⁡θmax(R∗,S⊥)≠0\cos\theta_{\mathsf{max}}(R_{*},S^{\perp})\neq 0—intuitively, for any subspace a small perturbation would make these angles non-zero and the assumption would hold. To illustrate that these assumptions typically hold, Lemma A.16 in Appendix A proves that if SS is a random mm-dimensional subspace then these angles are non-zero almost surely.

ID comparison: When the pretrained features have some error, we show that fine-tuning does better than linear probing ID because fine-tuning can update the features to fit the ID data.

If the pretrained features are perfect so that the optimal predictor can be written as a linear combination of the pretrained features (w⋆=B⋆⊤v⋆∈rowspace(B0)w_{\star}=B_{\star}^{\top}v_{\star}\in\text{rowspace}(B_{0})), then both linear probing and fine-tuning get zero ID error. However, if the pretrained representation has some error, and the training data satisfies a mild non-degeneracy condition, then LP has high ID error because there is no linear head on B0B_{0} that fits the training data perfectly. FT, on the other hand, can update the features to find a new Bft∞{B_{\mathsf{ft}}^{\infty}} that can fit the training data perfectly with a linear head vft∞{v_{\mathsf{ft}}^{\infty}}.

The non-degeneracy condition is similar to our previous results, and holds with probability 1 if the ID subspace is chosen randomly, from Lemma A.16. Formally, let Raug{R_{\mathsf{aug}}} be a k+1k+1 dimensional subspace spanning R0∪{w⋆}R_{0}\cup\{w_{\star}\}, where we recall that R0=\mboxrowspace(B0)R_{0}=\mbox{rowspace}(B_{0}). Then we just require that the ID subspace SS and Raug{R_{\mathsf{aug}}} are not orthogonal: cos⁡θmax(S,Raug)≠0\cos\theta_{\mathsf{max}}(S,{R_{\mathsf{aug}}})\neq 0. We state the formal proposition below and give a proof in Appendix A.

In the linear overparameterized setting, under the ID subspace assumption (Assumption 3.4), let R0=\mboxrowspace(B0)R_{0}=\mbox{rowspace}(B_{0}), and Raug=\mboxSpan({w⋆}∪R0){R_{\mathsf{aug}}}=\mbox{Span}(\{w_{\star}\}\cup R_{0}). Suppose w⋆∉R0w_{\star}\not\in R_{0}, cos⁡θmax(S,Raug)≠0\cos\theta_{\mathsf{max}}(S,{R_{\mathsf{aug}}})\neq 0, and that fine-tuning converges to a local minimum of its loss, then fine-tuning does better ID almost surely: Lid(vft∞,Bft∞)<Lid(vlp∞,B0)L_{\mathsf{id}}({v_{\mathsf{ft}}^{\infty}},{B_{\mathsf{ft}}^{\infty}})<L_{\mathsf{id}}({v_{\mathsf{lp}}^{\infty}},B_{0}) with probability 1 (over the randomness of the training examples).

To summarize, we proved that there are tradeoffs between ID and OOD error: FT has lower ID error but higher OOD error than LP. In the next section, we extend our theoretical insights to illustrate why a simple variant of FT may mitigate such tradeoffs.

4 Linear probing then fine-tuning: a simple variant to mitigate tradeoffs

The advantage of fine-tuning is it can adapt both the feature extractor and head to fit the downstream task. Can we keep this benefit while ensuring that our OOD error is low when we have good pretrained features?

Going back to Theorem 3.3, we see that the alignment error in the head initialization φ2=(v0⊤v⋆)2−(v⋆⊤v⋆)2\varphi^{2}=(v_{0}^{\top}v_{\star})^{2}-(v_{\star}^{\top}v_{\star})^{2} plays an important role. The issue with FT was that under random or zero initialization, φ2\varphi^{2} is usually large and since the gradient updates to the feature extractor parameter are coupled with that of the head parameter, the features get distorted in a manner that increases the OOD error. This suggests that we should use a better head initialization—one obtained from linear probing. If the pretrained features are decent, a linear probed head would be much better aligned with v⋆v_{\star} allowing the features to be updated in a manner that does not increase the OOD error much.

We formally prove this intuition in a simple setting where we have perfect pretrained features. Of course, if we have perfect pretrained features, linear probing alone gets zero OOD error—so Proposition 3.7 is just a first cut result to illustrate that if initialized well, full fine-tuning does not distort features.

Suppose we have perfect pretrained features B0=UB⋆B_{0}=UB_{\star} for some rotation UU. Let R0=\mboxrowspace(B0)R_{0}=\mbox{rowspace}(B_{0}). Under the non-degeneracy conditions cos⁡θmax(R0,S)≠0,cos⁡θmax(R0,S⊥)≠0\cos\theta_{\mathsf{max}}(R_{0},S)\neq 0,\cos\theta_{\mathsf{max}}(R_{0},S^{\perp})\neq 0:

The case where we do not have perfect features (d(B0,B⋆)>0d(B_{0},B_{\star})>0) is challenging to analyze because except in very special cases, there is no closed form for the fine-tuning iterates (vft(t),Bft(t))({v_{\mathsf{ft}}}(t),{B_{\mathsf{ft}}}(t)). Our proof of Theorem 3.3 leveraged invariants to show a lower bound on the error of fine-tuning when v0v_{0} and v⋆v_{\star} are different, but we were not able to show an upper bound.

Experiments

We run experiments on ten distribution shifts to see if our theoretical predictions on the relative performance of linear probing (LP), fine-tuning (FT), and LP-FT, generalize to deep neural networks on real datasets. As expected, given good pretrained features, fine-tuning (FT) does better ID but worse on large OOD shifts than linear probing (LP). In particular, ID and OOD accuracy are not correlated, unlike Recht et al. (2018) but like Xie et al. (2021a). As predicted by the theory, we find that LP-FT does better than both methods ID and OOD and gets around this tradeoff. Our theory also predicts that the reason for these trends is that fine-tuning distorts features, and we see that this distortion indeed happens in practice. For more details on datasets, pretraining models, and experiment protocols, see Appendix B. The datasets we use are:

DomainNet (Peng et al., 2019) is a standard domain adaptation dataset. Here, our ID dataset contains “sketch” images (e.g., drawings of apples, elephants, etc), and the OOD dataset contains “real”, “clipart”, and “painting” images of the same categories. We use the version of the dataset from Tan et al. (2020).

Living-17 and Entity-30 are sub-population shift datasets from the BREEDS benchmark (Santurkar et al., 2020). In Living-17 the goal is to classify an image as one of 17 animal categories such as “bear”—for example, the ID dataset contains images of black bears and sloth bears and the OOD dataset has images of brown bears and polar bears. In Entity-30 the goal is to classify an image as one of 30 entities such as “fruit” or “insect”.

FMoW Geo-shift is adapted from the satellite remote sensing dataset Functional Map of the World (Christie et al., 2018; Koh et al., 2021). The goal is to classify a satellite image into one of 62 categories such as “impoverished settlement” or “hospital”. Our ID dataset contains images from North America, and the OOD dataset contains images from Africa and Europe.

CIFAR-10 →\to STL is a standard domain adaptation dataset (French et al., 2018), where the ID is CIFAR-10 (Krizhevsky, 2009), and the OOD is STL (Coates et al., 2011). The task is to classify an image into one of 10 categories such as “dog”, “cat”, or “airplane”—as usual, we remove the “monkey” class in STL since CIFAR-10 has no “monkey” images.

CIFAR-10 →\rightarrow CIFAR-10.1 (Recht et al., 2018) is a dataset collected using a very similar protocol to CIFAR-10, and the authors describe it as “a minute distributional shift”. The hope is that a classifier trained on CIFAR-10 gets high accuracy on CIFAR-10.1.

ImageNet-1K (Russakovsky et al., 2015) is a large scale dataset containing over a million images, where the goal is to classify an image into one of 1000 categories such as “Yorkshire terrier”, “Labrador retriever”, “acoustic guitar”, “library”, “school bus”, etc. We fine-tune on ImageNet as the ID dataset, and evaluate on four standard OOD datasets: ImageNetV2 (Recht et al., 2019), ImageNet-R (Hendrycks et al., 2020), ImageNet-A (Hendrycks et al., 2019b), and ImageNet-Sketch (Wang et al., 2019).

Pretraining and models. We use a CLIP pretrained ViT-B/16 for ImageNet. For the other datasets we use a ResNet-50 architecture and consider a diverse range of pretraining methods and datasets: MoCo-v2 (Chen et al., 2020b), CLIP (Radford et al., 2021), and MoCo-TP (Ayush et al., 2020). In Appendix B, we also show results for a CLIP-ViT-B/16 and more fine-tuning baselines on Living-17.

Results. Fine-tuning does better than linear probing on 5 out of 6 ID datasets (average accuracy of 85.1% for fine-tuning vs. 82.9% for linear probing, see Table 1). This is consistent with prior work and intuitions. However, linear-probing does better on 8 out of 10 OOD datasets (average accuracy of 66.2% for linear probing vs. 59.3% for fine-tuning, see Table 2)—linear probing does better on all datasets except CIFAR-10.1 and ImageNetV2, where the OOD is designed to closely replicate the ID dataset. This matches our theoretical predictions, which says that linear probing does better than fine-tuning when the ID and OOD are very different (and the pretrained features are “good”). Our training datasets vary in size from 20K examples to over a million examples, so linear probing does not appear to perform better than fine-tuning simply because of a small training set.

2 Linear probing then fine-tuning (LP-FT)

Experiment protocols. For LP-FT, we initialize the neural network head using the linear probed solution, and then fine-tune the model. LP-FT and fine-tuning use similar compute because the linear probing step is much faster than fine-tuning. As with fine-tuning, we swept over 6 learning rates, early stopping using ID validation accuracy. For the ImageNet experiments we swept over 3 learning rates, and explicitly ensured that LP-FT and fine-tuning use exactly the same compute (we ran each stage of LP-FT for half as many epochs as we ran vanilla fine-tuning).

Results. We find that LP-FT gets the best accuracy ID (average: 85.7%) and OOD (average: 68.9%). This is true for 5/6 ID and 10/10 OOD datasets—every dataset except FMoW ID, where LP-FT is better than linear probing but worse than fine-tuning. Since the ID accuracy on FMoW is low (56.5%), this could be because the pretrained features are not good.

3 Examining the feature distortion theory

Early stopping does not mitigate feature distortion. One might think that fine-tuning is simply overfitting ID, and so early stopping on OOD data (if it were available) might match linear probing OOD. However, our theory predicts that fine-tuning can do worse OOD (than linear probing) throughout the process of fine-tuning, and not just at the end. To test this, we early stop each fine-tuning method and choose the best learning rate based on OOD test accuracy (OOD data was not used except for this ablation). As expected, fine-tuning does improve a little, but linear probing (average accuracy: 67.1%) is still better than fine-tuning (average accuracy: 61.3%). See Appendix B for per-dataset results.

ID-OOD features get distorted from fine-tuning. The feature distortion theory predicts that fine-tuning changes features for ID examples more than for OOD examples, which is why fitting a head on ID examples performs poorly OOD. To test this, for each example xx in Living-17 (results for other datasets are in Appendix B), we took the Euclidean distance of the ResNet-50 features before and after fine-tuning: ∥gB(x)−gB0(x)∥2\|g_{B}(x)-g_{B_{0}}(x)\|_{2}. As expected, the average distance for ID examples (0.0188±0.00010.0188\pm 0.0001) is more than for OOD examples (0.0167±0.00010.0167\pm 0.0001). The theory also predicts that LP-FT changes features less than fine-tuning does. As expected, the average distance changed by LP-FT both ID (0.0011±0.00010.0011\pm 0.0001) and OOD (0.0009±0.00010.0009\pm 0.0001) is 20×20\times smaller than for fine-tuning.

Pretrained features must be good, ID-OOD far apart. Our theory gives conditions under which linear probing can do better than fine-tuning OOD. Specifically, we require that the ID distribution PidP_{\mathsf{id}} and OOD distribution PoodP_{\mathsf{ood}} are quite different, and the pretrained features are good (B0B_{0} is close to B⋆B_{\star})—otherwise fine-tuning can do better OOD by adjusting the feature extractor ID. Here we test that these conditions are essential—when they are violated fine-tuning can do better than linear probing OOD.

Feature quality: We use a checkpoint of MoCo-v1 that got 10% worse accuracy (on ImageNet) and compare linear probing and fine-tuning on Living-17. With worse features, both methods do worse, but fine-tuning (96% ID, 71% OOD) does better than linear probing (92% ID, 66% OOD).

ID ≈\approx OOD: We fine-tune / linear probe on CIFAR-10, and test on CIFAR-10.1, a dataset collected using a similar protocol to CIFAR-10. As expected, fine-tuning (92.3%) outperforms linear probing OOD (82.7%). Even in this case, where we have no tradeoffs, LP-FT does the best (93.5%).

Related work and discussion

Fine-tuning vs. linear probing. Fine-tuning (FT) and linear probing (LP) are popular transfer learning algorithms. There is substantial evidence of FT outperforming LP in-distribution (ID) including recent large-scale investigations (Kornblith et al., 2019; Chen et al., 2021a; Zhai et al., 2020; Chen et al., 2020b) (the only notable exception is in Peters et al. (2019) where LP performs better than FT when using ELMo representations, but worse using BERT). This is not intended to be a comprehensive list. There is a large body of past work across different domains that have reported a similar observation. FT is therefore the method of choice for improving accuracy, while LP is used to analyze properties of representations (Peters et al., 2018; Belinkov et al., 2017; Hewitt & Manning, 2019). In our work, we find that FT can underperform LP especially when using high quality pretrained features in the presence of a large distribution shift. There are a variety of other fine-tuning heuristics (Ge & Yu, 2017; Guo et al., 2019; Zhang et al., 2020; Zhu et al., 2020; Jiang et al., 2021; Aghajanyan et al., 2021)—combining our insights with these ideas might lead to better methods.

The benefit of preserving pretrained features. Our work adds to growing evidence that lightweight fine-tuning, where only a small part of a pretrained model are updated, performs better under distribution shifts—and we give a theoretical grounding to why this might be the case. Zero-shot language prompting in vision (Radford et al., 2021) and other lightweight fine-tuning approaches in NLP (Houlsby et al., 2019; Li & Liang, 2021; Xie et al., 2021b; Lester et al., 2021; Utama et al., 2021; Zhou et al., 2021) have been shown to improve OOD performance. In independent and concurrent work, Andreassen et al. (2021) observe that through the course of fine-tuning, ID accuracy continues to increase but OOD accuracy plateaus. Our work shows something stronger: at no point in the fine-tuning process does FT outperform LP.

Mitigating ID-OOD tradeoffs. While LP-FT has sometimes been used as a fine-tuning heuristic (Levine et al., 2016; Kanavati & Tsuneki, 2021; fastai, ), it has not been used for robustness / OOD accuracy, and we show that it addresses the ID-OOD tradeoff theoretically and empirically. Tradeoffs between ID and OOD accuracy are widely studied and prior work self-trains on large amounts of unlabeled data to mitigate such tradeoffs (Raghunathan et al., 2020; Xie et al., 2021a; Khani & Liang, 2021). In contrast, LP-FT uses no extra unlabeled data and is a simple variant of fine-tuning. In concurrent and independent work, Wortsman et al. (2021) show that ensembling the weights of a zero-shot and fine-tuned model mitigates the ID-OOD tradeoff between these approaches, and this method could be promising for our datasets as well.

Theoretical analysis of transfer learning. Prior works on transfer learning mainly analyze linear probing (Wu et al., 2020; Tripuraneni et al., 2020; Du et al., 2020). In recent work, (Chua et al., 2021) study regularized fine-tuning in an underparameterized regime where there is a unique global optimum. In contrast, our analysis studies the overparameterized regime (mirroring modern settings of zero train loss) where we need to analyze the trajectory of fine-tuning from the pretrained initialization because there is no unique optimizer of the objective function. Prior works also focus on ID error, while we analyze OOD error. See Section C for additional related work on theory of overparameterized models.

Conclusion.

There is a strong trend towards leveraging pretrained models to improve downstream performance, and whenever feasible, it is common to fine-tune all model parameters. In this work, we show theoretically and empirically that preserving features might be important for robustness, and simpler approaches like linear-probing can improve out-of-distribution (OOD) performance. This OOD gap between fine-tuning and linear probing grows as the quality of pretrained features improve, so we believe our results are likely to gain significance over time with growing innovations and scale of pretraining.

Theoretical understanding of modern deep learning remains limited, especially the effect of pretraining and transfer learning. In addition to our specific results on fine-tuning, our work introduces some tools and ideas for dealing with the main challenge of characterizing properties of the trajectory from a specific initialization in the presence of multiple global optima (implicit regularization effect of initialization). There are several open questions and extensions such as dealing with non-linear activations, different layerwise learning rates, and the effect of explicit regularization. We found that LP-FT outperforms explicit regularization and using a higher learning rate for the linear layer on Living-17 (Appendix B.4), but a more extensive theoretical and empirical study on this is important.

Finally, we showed LP-FT can mitigate tradeoffs between ID and OOD accuracy in our context. LP-FT could be useful in other situations, for example in CLIP we could initialize the final layer with the zero-shot classifier and then fine-tune the entire model, as done in concurrent work (Wortsman et al., 2021). LP-FT is just a first step in leveraging the intuition from our theoretical analysis and we hope that this work inspires new methods of leveraging powerful pretrained models.

Proofs and Reproducibility: We include proofs for our theoretical results in Appendix A and additional experiment details in Appendix B.

Acknowledgements: We would like to thank Kumar Ayush and Burak Uzkent for MoCo checkpoints pretrained on unlabeled FMoW images, Nilesh Tripuraneni for clarifications on his work and references on principal angles, Daniel Levy for useful suggestions on experiments to run, Niladri Chatterji, Jeff Z. HaoChen, and Colin Wei for useful papers and comments on figures, Niladri Chatterji and Kaidi Cao for reviewing the paper at ML paper swap, Kevin Yang for his help with analyzing differential equations, Tri Dao and Pang Wei Koh for help with writing, Suriya Gunasekar, Adam Kalai, Simon Kornblith, Ting Chen, Sang Michael Xie, Albert Gu, and Kendrick Shen for useful discussions, and Pang Wei Koh, Niladri Chatterji, and Tri Dao for suggestions on framing our results better.

Ananya Kumar was supported by the Rambus Corporation Stanford Graduate Fellowship. Percy Liang was supported by the Open Philantropy Project and NSF Award Grant No. 1805310. Aditi Raghunathan was supported by a Google PhD Fellowship and Open Philanthropy Project AI Fellowship. Tengyu Ma acknowledges support of a Google Faculty Award, NSF IIS 2045685, the Sloan Fellowship, JD.com, SAIL, and SDSI.

References

Appendix A Proofs for Section 3

Big-Oh Notation: For convenience, we use big-oh notation in a way that differs from standard theoretical computer science texts. When we say O(\mbox<expr1>)O(\mbox{<expr1>}) we mean that this can be replaced by c\mbox<expr1>c\mbox{ <expr1>} for some universal constant such that the statement holds. As an example, we can say 5x2≤O(x2)5x^{2}\leq O(x^{2}) because there exists some universal constant (c=5c=5) such that 5x2≤5x25x^{2}\leq 5x^{2}. More examples: we can also say 5x2≥O(x2)5x^{2}\geq O(x^{2}) or if x≥1x\geq 1 then 7x2≤O(x3)7x^{2}\leq O(x^{3}) and 0.1x2≥O(x)0.1x^{2}\geq O(x).

Working with minimum singular values requires more care than maximum singular vectors. In particular, when we have rectangular matrices some bounds depend on whether the matrix is ‘fat’ (has more columns than rows) or ‘tall’ (has more rows than columns).

Given a matrix AA, the operator norm ∥A∥2\|A\|_{2} is the maximum singular value: ∥A∥2=σmax⁡(A)\|A\|_{2}=\sigma_{\max}(A).

From this we can easily check that ΠR2=ΠR\Pi_{R}^{2}=\Pi_{R} and ΠR⊤=ΠR\Pi_{R}^{\top}=\Pi_{R}. See e.g., Chapter 2.5.1 Golub & Loan (2013) for more information.

Principal Angles: Given two non-zero vectors xx and yy, the cosine of the angle between them, cos⁡θ\cos{\theta}, is:

If we consider the 1-dimensional subspaces (so basically lines) SxS_{x} and SyS_{y} spanned by xx and yy respectively, then the angle between them, cos⁡θ′\cos{\theta^{\prime}} is given by the absolute value (since lines are undirected):

Principal angles generalize this notion to higher dimensions. See e.g., Chapter 6.4.3 in Golub & Loan (2013) for more information on principal angles.

The directions of the inequalities swap when we take the cosine of the principal angles:

where σi\sigma_{i} denotes the ii-th largest singular value. In this paper, we are interested in the cosine of the largest angle between them, given by:

We can massage this into a variational characterization of the maximum principal angle, which is important for lower bounding the error of fine-tuning outside the span of the training data.

The result now follows from some algebra:

A.2 Feature distortion theorem

We first prove our core theorem, that fine-tuning distorts pretrained features.

In the overparameterized linear setting, let S⊥=\mboxrowspace(X)⊥S^{\perp}=\mbox{rowspace}(X)^{\perp}, R0=\mboxrowspace(B0)R_{0}=\mbox{rowspace}(B_{0}), and v⋆,B⋆v_{\star},B_{\star} be the optimal parameters with w⋆=B⋆v⋆w_{\star}=B_{\star}v_{\star}. If cos⁡θmax(R0,S⊥)>0\cos\theta_{\mathsf{max}}(R_{0},S^{\perp})>0, then for all time steps tt, the OOD error of the fine-tuning iterates (Bft(t),vft(t))({B_{\mathsf{ft}}}(t),{v_{\mathsf{ft}}}(t)) is lower bounded:

where φ2=∣(v0⊤v⋆)2−(v⋆⊤v⋆)2∣\varphi^{2}=\lvert(v_{0}^{\top}v_{\star})^{2}-(v_{\star}^{\top}v_{\star})^{2}\rvert is defined to be inital head alignment error and ϵ≥d(B0,B⋆)\epsilon\geq d(B_{0},B_{\star}) is the error in the pretrained feature extractor.

We follow the sketch in the main paper. We begin with a few lemmas, showing that certain quantities are preserved throughout the fine-tuning process.

Our first lemma says that the representations Bfttx{B_{ft}^{t}}x do not change for examples perpendicular the span of the training examples. Note that the final output vftt⊤Bfttx{v_{ft}^{t}}^{\top}{B_{ft}^{t}}x still changes, because vftt{v_{ft}^{t}} changes.

For all times tt and all x∈S⊥x\in S^{\perp}, we have:

We initialized fine-tuning with the feature extractor Bft(0)=B0{B_{\mathsf{ft}}}(0)=B_{0}. It suffices to show that ∂tBfttx=0\partial_{t}{B_{ft}^{t}}x=0 for all x∈S⊥x\in S^{\perp}. Recall that ∂tBftt\partial_{t}{B_{ft}^{t}} is given by the gradient flow update equation:

Computing the RHS explicitly using multivariable chain rule, we get:

But Xx=0Xx=0 for x∈S⊥x\in S^{\perp}, since x∈S⊥x\in S^{\perp} is defined as xx is perpendicular to the rowspace of XX (i.e., perpendicular to the rows of XX). So the RHS is —that is, ∂tBfttx=0\partial_{t}{B_{ft}^{t}}x=0, as desired. ∎

Next, we show that the change in the head and feature extractor are ‘coupled’. So if the head changes in a certain way, then the feature extractor cannot just stay the same. In the literature, this is sometimes called the “balancedness" lemma, and has been proved in prior work on two layer linear networks.

This follows by showing that the derivative is :

Which can be verified by direct calculation. See Theorem 2.2 in Du et al. (2018) and the proof of Theorem 1 in Arora et al. (2018). ∎

For our proof we will require that every feature r∈Rr\in R can be generated from some OOD direction, that is r=B0ur=B_{0}u for some u∈S⊥u\in S^{\perp}. We will show that this is implied by the condition on the principal angle: cos⁡θmax(R,S⊥)>0\cos\theta_{\mathsf{max}}(R,S^{\perp})>0 where R=\mboxrowspace(B0)R=\mbox{rowspace}(B_{0}), which we assumed in Theorem 3.3. The following lemma shows this (and also quantifies that the norm of uu does not shrink too much when projected onto RR).

Let c=cos⁡θmax(R,S)c=\cos\theta_{\mathsf{max}}(R,S). Firt, we get rid of an easy case—if c=0c=0, then we need to show the claim for all r∈Rr\in R with ∥r∥2=c=0\|r\|_{2}=c=0, which means r=0r=0. Then we can just pick s=0s=0, and ΠR(s)=0=r\Pi_{R}(s)=0=r and ∥s∥2=0≤1\|s\|_{2}=0\leq 1. So for the rest of the proof we assume c>0c>0.

Step 2: Bounding norm of ss: It suffices to show that ∥s∥2≤1\|s\|_{2}\leq 1. Since FF has orthonormal columns, ∥s∥2=∥Fw∥2=∥w∥2\|s\|_{2}=\|Fw\|_{2}=\|w\|_{2}, so it suffices to show that ∥w∥2≤1\|w\|_{2}\leq 1. Since EE has orthonormal columns, ∥r∥2=∥z∥2\|r\|_{2}=\|z\|_{2}. Recall that z=E⊤Fwz=E^{\top}Fw—since w∈\mboxrowspace(E⊤F)w\in\mbox{rowspace}(E^{\top}F), from Lemma A.6 we have:

Rearranging, we get ∥w∥2≤∥z∥2/c=1\|w\|_{2}\leq\|z\|_{2}/c=1, as desired.

In the lemma above, we used a standard linear algebraic result that we include for completeness. This says that AA cannot shrink vectors in its rowspace too much, where the shrinkage factor is given by the minimum singular value of AA.

We bound the norm of xx using the SVD. Consider the singular value decomposition (SVD) of AA:

Where for the fourth step, we used the fact that if x∈rowspace(V⊤)x\in\text{rowspace}(V^{\top}) and the rows of V⊤V^{\top} are orthonormal, then ∥V⊤x∥2=∥x∥2\|V^{\top}x\|_{2}=\|x\|_{2}. One way to see this is by writing x=∑iαivix=\sum_{i}\alpha_{i}v_{i}, where viv_{i} are rows of V⊤V^{\top}, and then noting that V⊤x=(α1,…,αr)V^{\top}x=(\alpha_{1},\ldots,\alpha_{r}) and so xx and V⊤xV^{\top}x have the same norm. ∎

We now prove Theorem 3.3, following the 3 steps outlined in the main text.

Let c=cos⁡θmax(R,S⊥)c=\cos\theta_{\mathsf{max}}(R,S^{\perp}). From Lemma A.7, we have Lood(vftt,Bftt)≤σmin⁡(Σ)∥B⋆⊤v⋆−Bftt⊤vftt∥22L_{\mathsf{ood}}({v_{ft}^{t}},{B_{ft}^{t}})\leq\sigma_{\min}(\Sigma)\|B_{\star}^{\top}v_{\star}-{B_{ft}^{t}}^{\top}{v_{ft}^{t}}\|_{2}^{2} so it suffices to bound ∥B⋆⊤v⋆−Bftt⊤vftt∥2\|B_{\star}^{\top}v_{\star}-{B_{ft}^{t}}^{\top}{v_{ft}^{t}}\|_{2}.

Because it makes the proof much easier, we will prove the contrapositive, and then convert back to the original theorem statement. We assume ∥B⋆⊤v⋆−Bftt⊤vftt∥2≤Δ\|B_{\star}^{\top}v_{\star}-{B_{ft}^{t}}^{\top}{v_{ft}^{t}}\|_{2}\leq\Delta, and will show that:

Where g1g_{1} and g2g_{2} are non-negative polynomials we will bound in the proof.

We gave a basic outline of the proof in the main paper, and here we are just trying to be careful about capturing all the dependencies. We also give intuition for each step before diving into algebra (which we include for completeness).

Recall that in the overparameterized linear setting we assumed we have orthonormal B0B_{0} with ∥B0−UB⋆∥2≤ϵ\|B_{0}-UB_{\star}\|_{2}\leq\epsilon for some UU. We note that the setup is rotationally symmetric so without loss of generality we can suppose ∥B0−B⋆∥2≤ϵ\|B_{0}-B_{\star}\|_{2}\leq\epsilon. This is because we can let B⋆′=UB⋆B_{\star}^{\prime}=UB_{\star} and v⋆′=Uv⋆v_{\star}^{\prime}=Uv_{\star}, and we have w⋆=B⋆⊤v⋆=(UB⋆)⊤(Uv⋆)w_{\star}=B_{\star}^{\top}v_{\star}=(UB_{\star})^{\top}(Uv_{\star}), where w⋆w_{\star} is the optimal classifier—so we can now write the entire proof in terms of B⋆′B_{\star}^{\prime} and v⋆′v_{\star}^{\prime}.

Step 1: Show that ∥vftt−v⋆∥2≤Δ/c\|{v_{ft}^{t}}-v_{\star}\|_{2}\leq\Delta/c: We first give intuition and then dive into the math. The key insight is to use the fact that in ‘many’ directions Bftt{B_{ft}^{t}} and B0B_{0} are the same (formally, for all x∈S⊥x\in S^{\perp}, Bfttx=B0x{B_{ft}^{t}}x=B_{0}x). But B0B_{0} and B⋆B_{\star} are close by assumption, which means that Bftt{B_{ft}^{t}} and B⋆B_{\star} are close in ‘many’ directions. Then since we assumed in the contrapositive that vftt⊤Bftt{v_{ft}^{t}}^{\top}{B_{ft}^{t}} and v⋆⊤B⋆v_{\star}^{\top}B_{\star} are close, we get that vftt{v_{ft}^{t}} and v⋆v_{\star} are close in ‘many’ directions. Because S⊥S^{\perp} covers the rowspace of B0B_{0}, we get that ‘many’ is kk, which is precisely the dimensionality of v⋆v_{\star}, so the two vectors vftt{v_{ft}^{t}} and v⋆v_{\star} must be close.

We now dive into the math. Since B0B_{0} has orthogonal rows, B0B_{0} has full column rank.

We note that ∥z∥2=c\|z\|_{2}=c. Then, we can find y∈R=rowspace(B0)y\in R=\text{rowspace}(B_{0}) such that B0y=zB_{0}y=z (since B0B_{0} has full column-rank) and then ∥y∥2=∥z∥2=c\|y\|_{2}=\|z\|_{2}=c (since B0B_{0} has orthonormal rows).

Since c=cos⁡θmax(R,S⊥)>0c=\cos\theta_{\mathsf{max}}(R,S^{\perp})>0, and y∈Ry\in R with ∥y∥=c\|y\|=c, from Lemma A.5 we can choose x∈S⊥x\in S^{\perp} with ∥x∥2≤1\|x\|_{2}\leq 1 and ΠR(x)=y\Pi_{R}(x)=y. Then, we have B0x=zB_{0}x=z.

From Proposition A.3, since x∈S⊥x\in S^{\perp}, B0B_{0} does not change in directions of xx when fine-tuning so we have: B0x=BfttxB_{0}x={B_{ft}^{t}}x.

The claim now follows from simple algebraic manipulation, following the intuition we described. The algebra just captures what ‘close’ means and adds up the error terms.

Which shows that ∥vftt−v⋆∥2≤(Δ+ϵ∥v⋆∥2)/c\|{v_{ft}^{t}}-v_{\star}\|_{2}\leq(\Delta+\epsilon\|v_{\star}\|_{2})/c.

Step 2A: Show that ∥Bftt∥F2\|{B_{ft}^{t}}\|_{F}^{2} is small: The key insight is to take the trace on both sides of Proposition A.4, which bounds the Frobenius norm of Bftt{B_{ft}^{t}} and therefore the operator norm.

Squares are non-negative, so we get the inequality:

Step 2B: Show that ∥B0⊤v⋆∥22−∥Bftt⊤v⋆∥22\|B_{0}^{\top}v_{\star}\|_{2}^{2}-\|{B_{ft}^{t}}^{\top}v_{\star}\|_{2}^{2} is small: This step doesn’t involve much insight, and is standard peturbation analysis—we simply factor the difference of squares and bound each term.

First, we bound ∥Bftt⊤vftt−Bftt⊤v⋆∥2\|{B_{ft}^{t}}^{\top}{v_{ft}^{t}}-{B_{ft}^{t}}^{\top}v_{\star}\|_{2}:

Next, we bound ∥B0⊤v⋆−Bftt⊤v⋆∥2\|B_{0}^{\top}v_{\star}-{B_{ft}^{t}}^{\top}v_{\star}\|_{2}:

Finally, we bound ∣∥B0⊤v⋆∥22−∥Bftt⊤v⋆∥22∣\lvert\|B_{0}^{\top}v_{\star}\|_{2}^{2}-\|{B_{ft}^{t}}^{\top}v_{\star}\|_{2}^{2}\rvert, using the identity:

Step 3: Use Proposition A.4 to show v0v_{0} and v⋆v_{\star} must be close: The key insight is that we start from Proposition A.4, and left and right multiply by v⋆v_{\star}, after that we use the previous steps and do some some standard perturbation analysis.

The key step is to left multiply both sides by v⋆⊤v_{\star}^{\top} and right multiply both sides by v⋆v_{\star} to get:

Rearranging, and then using Equation A.66, we get:

This is close to what we want, except we have (vftt⊤v⋆)2({v_{ft}^{t}}^{\top}v_{\star})^{2} on the LHS instead of (v⋆⊤v⋆)2(v_{\star}^{\top}v_{\star})^{2}. We previously showed that vftt{v_{ft}^{t}} and v⋆v_{\star} are close, in Step 1, so with some algebra we can bound the difference between (vftt⊤v⋆)2({v_{ft}^{t}}^{\top}v_{\star})^{2} and (v⋆⊤v⋆)2(v_{\star}^{\top}v_{\star})^{2}:

Above, from the third line to the fourth line, we used triangle inequality and Cauchy-Schwarz.

So finally, by triangle-inequality we can now bound ∣(v⋆⊤v⋆)2−(v0⊤v⋆)2∣\lvert(v_{\star}^{\top}v_{\star})^{2}-(v_{0}^{\top}v_{\star})^{2}\rvert:

Wrap up i.e., writing out Δ4+Δ3\Delta_{4}+\Delta_{3} explicitly: This is basically the bound we want, but we would like to express Δ3,Δ4\Delta_{3},\Delta_{4} in terms of Δ\Delta and ϵ\epsilon. Note that this step has no insight, and is just algebra—we include the details for reference and verifiability. We recall:

Since B0B_{0} has orthogonal rows (by assumption), B0⊤B_{0}^{\top} has orthogonal columns, so ∥w⋆∥2=∥B0⊤v⋆∥2=∥v⋆∥2\|w_{\star}\|_{2}=\|B_{0}^{\top}v_{\star}\|_{2}=\|v_{\star}\|_{2}. In addition, since B0B_{0} has kk orthogonal rows, ∥B0∥F=k\|B_{0}\|_{F}=\sqrt{k}. We also note that ∥B0∥F2+∥v⋆∥22≤∥B0∥F+∥v⋆∥2=k+∥w⋆∥2\sqrt{\|B_{0}\|_{F}^{2}+\|v_{\star}\|_{2}^{2}}\leq\|B_{0}\|_{F}+\|v_{\star}\|_{2}=\sqrt{k}+\|w_{\star}\|_{2}. Since c≤1c\leq 1, we have:

So for Δ2\Delta_{2}, up to constant factors we can ignore the ϵ∥v⋆∥2+Δ\epsilon\|v_{\star}\|_{2}+\Delta term—this means we get:

Using the fact that k+∥w⋆∥2≤k(1+∥w⋆∥)\sqrt{k}+\|w_{\star}\|_{2}\leq\sqrt{k}(1+\|w_{\star}\|) we get:

Then since Δ+ϵ∥w⋆∥2≤(1+∥w⋆∥2)(Δ+ϵ)\Delta+\epsilon\|w_{\star}\|_{2}\leq(1+\|w_{\star}\|_{2})(\Delta+\epsilon), we get:

Now for Δ3\Delta_{3}, first note that ϵ≤2\epsilon\leq 2, since B⋆B_{\star} and B0B_{0} have orthogonormal rows so ∥B⋆−B0∥2≤2\|B_{\star}-B_{0}\|_{2}\leq 2. This means that ϵ∥w⋆∥2≤∥w⋆∥2\epsilon\|w_{\star}\|_{2}\leq\|w_{\star}\|_{2}, so Δ3\Delta_{3} simplifies to:

Substituting the bound for Δ2\Delta_{2} into Δ3\Delta_{3}, we get:

Since Δ/c≤(Δ+ϵ)/c\Delta/c\leq(\Delta+\epsilon)/c and ∥w⋆∥22≤(1+∥w⋆∥2)2\|w_{\star}\|_{2}^{2}\leq(1+\|w_{\star}\|_{2})^{2} we have for the final error Δ3+Δ4\Delta_{3}+\Delta_{4}:

Wrap up i.e., taking the contrapositive: So we’ve shown that if ∥B⋆⊤v⋆−Bftt⊤vftt∥22≤Δ\|B_{\star}^{\top}v_{\star}-{B_{ft}^{t}}^{\top}{v_{ft}^{t}}\|_{2}^{2}\leq\Delta, then:

We’d like to flip this around: suppose ∣(v⋆⊤v⋆)2−(v0⊤v⋆)2∣≥φ2\lvert(v_{\star}^{\top}v_{\star})^{2}-(v_{0}^{\top}v_{\star})^{2}\rvert\geq\varphi^{2} for some φ\varphi. To lower bound ∥B⋆⊤v⋆−Bftt⊤vftt∥22\|B_{\star}^{\top}v_{\star}-{B_{ft}^{t}}^{\top}{v_{ft}^{t}}\|_{2}^{2}, we simply take the contrapositive of what we have proved. Let Δ\Delta be given by:

In this case with some algebra, we can show that:

To see this, we bound each of the terms in the RHS separately using our definition of Δ\Delta. Then, from the contrapositive of what we proved (compare with Equation A.92, we get:

Finally, we can massage Δ\Delta to combine terms and make it look slightly nicer:

Then applying Lemma A.7 we get the desired result. For even more interpretability, if ∥w∥2=1\|w\|_{2}=1 and φ\varphi is bounded above by some constant, then you can think of Δ\Delta as approximately ckφ2−ϵ\frac{c}{\sqrt{k}}\varphi^{2}-\epsilon. This completes the proof. ∎

A.3 LP vs. FT (OOD)

We now prove Theorem 3.5, which compares linear probing and fine-tuning in the linear overparameterized setting, when the ID data lies in a lower dimensional subspace.

We first state a more precise version of Theorem 3.5—basically we fix all problem parameters except B0B_{0} (which limits to B⋆B_{\star}). To define the limit, we consider a sequence of pretrained feature extractors: {B0i}i=1∞\{B_{0}^{i}\}_{i=1}^{\infty}. We define the corresponding limit points of fine-tuning and linear probing when we start from the ii-th pretrained feature extractor. That is, let vfti(t),Bfti(t){v_{\mathsf{ft}}}^{i}(t),{B_{\mathsf{ft}}}^{i}(t) denote the parameters at time tt of fine-tuning if we initialize with v0,B0iv_{0},B_{0}^{i} (see Equation 3.2 for the fine-tuning updates). Let vlp∞i,B0i{v_{\mathsf{lp}}^{\infty}}^{i},B_{0}^{i} be the linear probing solution when initialized with v0,B0iv_{0},B_{0}^{i} (see Equation 3.5 for the linear probing updates). We note that the LP iterates converge to vlp∞i,B0i{v_{\mathsf{lp}}^{\infty}}^{i},B_{0}^{i} as a result of gradient flow on a convex problem.

Finally, Theorem 3.5 says that as the pretrained representations get better, linear probing does much better than fine-tuning OOD:

In the linear overparameterized setting, under the ID subspace assumption, fix the dimensions of the setting d,k,md,k,m, number of examples nn, the ID subspace SS, ID distribution PidP_{\mathsf{id}}, the distribution over the head v0v_{0}, and the ground truth parameters v⋆,B⋆v_{\star},B_{\star}. Assume the non-degeneracy conditions cos⁡θmax(R∗,S)>0\cos\theta_{\mathsf{max}}(R_{*},S)>0 and cos⁡θmax(R∗,S⊥)>0\cos\theta_{\mathsf{max}}(R_{*},S^{\perp})>0 where R∗=\mboxrowspace(B⋆)R_{*}=\mbox{rowspace}(B_{\star}). Given a sequence of pretrained feature extractors {B0i}i=1∞\{B_{0}^{i}\}_{i=1}^{\infty} with B0i→B⋆B_{0}^{i}\to B_{\star}, where the limit is in the pseudometric given by Definition 3.1, the ratio of OOD errors of linear probing and fine-tuning converges in probability to :

The purpose of the infimum is to capture the fact that the bound holds for all times tt for fine-tuning (and therefore also for the limit vft∞,Bft∞{v_{\mathsf{ft}}^{\infty}},{B_{\mathsf{ft}}^{\infty}} when it exists). Note that the ratio is a random variable because the training data is sampled from PidP_{\mathsf{id}} and the head is sampled (v0∼N(0,σ2I)v_{0}\sim\mathcal{N}(0,\sigma^{2}I) for some σ2\sigma^{2}).

Recall that we say a sequence of real-valued random variables converges in probability to (written as Xi→p0X_{i}\overset{p}{\to}0) if for every ϵ′,δ>0\epsilon^{\prime},\delta>0, for all large enough ii (that is, for all i≥Nii\geq N_{i} for some NiN_{i}), we have:

Accordingly, fix arbitrary ϵ′,δ>0\epsilon^{\prime},\delta>0, and we will show that the ratio of errors is eventually smaller than ϵ′\epsilon^{\prime} with probability at least 1−δ1-\delta.

Lower bounding fine-tuning error: Since B0i→B⋆B_{0}^{i}\to B_{\star}, from Lemma A.10 we have that cos⁡θmax(Ri,S⊥)→cos⁡θmax(R∗,S⊥)\cos\theta_{\mathsf{max}}(R^{i},S^{\perp})\to\cos\theta_{\mathsf{max}}(R_{*},S^{\perp}) where Ri=\mboxrowspace(B0i)R^{i}=\mbox{rowspace}(B_{0}^{i}). Since cos⁡θmax(R∗,S⊥)>0\cos\theta_{\mathsf{max}}(R_{*},S^{\perp})>0, this means that for all large enough ii we have:

Next, from Lemma A.12, we have that with probability at least 1−δ/21-\delta/2, \mboxHead−Error(v0,v⋆)=∣(v0⊤v⋆)2−(v⋆⊤v⋆)2∣≥cδ\mbox{Head-Error}(v_{0},v_{\star})=\lvert(v_{0}^{\top}v_{\star})^{2}-(v_{\star}^{\top}v_{\star})^{2}\rvert\geq c_{\delta} for some cδ>0c_{\delta}>0. Plugging this into the fine-tuning bound in Theorem 3.3, this means that for all large enough ii with probability at least 1−δ/21-\delta/2:

for some cδ′>0c_{\delta}^{\prime}>0. But since B0i→B⋆B_{0}^{i}\to B_{\star} we have d(B0i,B⋆)→0d(B_{0}^{i},B_{\star})\to 0 as i→∞i\to\infty. So this means that for all large enough ii with probability at least 1−δ/21-\delta/2:

Upper bounding the linear probing error: Since B0i→B⋆B_{0}^{i}\to B_{\star}, from Lemma A.10 we have that cos⁡θmax(Ri,S)→cos⁡θmax(R∗,S)\cos\theta_{\mathsf{max}}(R^{i},S)\to\cos\theta_{\mathsf{max}}(R_{*},S) and so since cos⁡θmax(R∗,S)>0\cos\theta_{\mathsf{max}}(R_{*},S)>0, for all large enough ii we have:

Plugging this into the RHS of Lemma A.14, Equation A.132, which upper bounds the OOD error of linear probing, we get that for all large enough ii, with probability at least 1−δ/21-\delta/2:

for some uδ>0u_{\delta}>0. Again since d(B0i,B⋆)→0d(B_{0}^{i},B_{\star})\to 0 as i→∞i\to\infty, this means for all large enough ii, with probability at least 1−δ/21-\delta/2, d(B0i,B⋆)d(B_{0}^{i},B_{\star}) will be small enough so that:

Taking the ratio: So taking the ratio of the lower bound for fine-tuning, and upper bound for linear probing, we get with with probability at least 1−δ1-\delta:

We now prove the Lemmas that we used in the above proof.

Theorem 3.5 assumes conditions on the angle between the perfect feature extractor B⋆B_{\star} and the ID subspace SS. However, fine-tuning and linear probing start from features B0B_{0} with some error, and do not get access to B⋆B_{\star}. We show that if B0B_{0} and B⋆B_{\star} are close, then the angles between their rowspaces to a third subspace TT (which could be the the ID subspace SS) is similar.

Here in the first step we used the definition of cos⁡θmax\cos\theta_{\mathsf{max}} (Definition 3.2), and the fact that B0⊤B_{0}^{\top} has orthonormal columns which form a basis for R0R_{0} (the rowspace of B0B_{0}), so in Definition 3.2 we can subtitute E=B0⊤E=B_{0}^{\top}. To get Equation A.110 we used Weyl’s theorem, which bounds the singular value under perturbations: σr(A+B)≥σr(A)−σ1(B)\sigma_{r}(A+B)\geq\sigma_{r}(A)-\sigma_{1}(B). To get Equation A.111 we used the fact that ∥Fv∥2=∥v∥\|Fv\|_{2}=\|v\| since FF has orthonormal columns.

Since this holds for all rotation matrices UU, we can take the minimum over UU to get:

Since the relationship between B0B_{0} and B⋆B_{\star} are symmetric (and the distance dd is symmetric), this gives us the desired result:

This follows directly from Lemma A.9. B0i→B⋆B_{0}^{i}\to B_{\star} means d(B0i,B⋆)→0d(B_{0}^{i},B_{\star})\to 0. Then from Lemma A.9:

This means cos⁡θmax(Ri,T)→cos⁡θmax(R∗,T)\cos\theta_{\mathsf{max}}(R^{i},T)\to\cos\theta_{\mathsf{max}}(R_{*},T) as i→∞i\to\infty ∎

A.3.2 Bounding the head error

We prove a lower bound on \mboxHead−Error(v0,v⋆)=∣(v0⊤v⋆)2−(v⋆⊤v⋆)2∣\mbox{Head-Error}(v_{0},v_{\star})=\lvert(v_{0}^{\top}v_{\star})^{2}-(v_{\star}^{\top}v_{\star})^{2}\rvert, which was a key term in the fine-tuning lower bound (Theorem 3.3). Note that if the head is initialized as v0=0v_{0}=0, then \mboxHead−Error(v0,v⋆)=∥v⋆∥22=∥w⋆∥22\mbox{Head-Error}(v_{0},v_{\star})=\|v_{\star}\|_{2}^{2}=\|w_{\star}\|_{2}^{2}. In practice, the head is usually initialized randomly, for example normally distributed. Intuitively, the head error is still high because we do not know which direction the head is pointing in, so most of the time the initial (randomly sampled) head will be pointing in the wrong direction. If v0∼N(0,σ2I)v_{0}\sim N(0,\sigma^{2}I) can show that for any σ2\sigma^{2}, the head error will still typically be at least Ω(∥v⋆∥2)\Omega(\|v_{\star}\|_{2}) This is an illustrative result, one can show similar results for other random initializations as well.

We first prove an anti-concentration lemma, which says that if uu is univariate Gaussian, then it cannot be too close to any particular constant aa, no matter how the variance of the Gaussian is chosen.

For some universal constant cc, given a>0a>0, for all ν2\nu^{2} if u∼N(0,ν2)u\sim N(0,\nu^{2}) then for all 0≤δ≤10\leq\delta\leq 1:

Consider δ\delta such that δ≤1/10\delta\leq 1/10. Then for all uu with ∣u−a∣≤δa\lvert u-a\rvert\leq\delta a, we have u≥9a/10u\geq 9a/10. For all u≥9a/10u\geq 9a/10, the density f(u)f(u) is upper bounded (from the formula for the density of a Gaussian random variable) by:

We can maximize this explicitly (e.g., use Mathematica or by taking the logarithm and then setting the derivative to 0) and we get for some universal constant c′≥10c^{\prime}\geq 10 (it is OK to choose a larger universal constant than needed):

Since the density is less than c′/ac^{\prime}/a and if ∣u−a∣≤δa\lvert u-a\rvert\leq\delta a the size of the interval is 2δa2\delta a, we get for all δ≤1/10\delta\leq 1/10:

Now, we substitute δ′=2c′δ\delta^{\prime}=2c^{\prime}\delta. We get for all δ′≤2c′/10\delta^{\prime}\leq 2c^{\prime}/10:

Since c′≥10c^{\prime}\geq 10, 2c′/10≥12c^{\prime}/10\geq 1, so the statement is true for all 0≤δ′≤10\leq\delta^{\prime}\leq 1. ∎

We now bound the error in the head if the initialization is Gaussian. This bound holds for all initialization variances σ2\sigma^{2}. Similar bounds can be shown for other (non-Gaussian) head initializations using similar anti-concentration arguments.

First note that \mboxHead−Error(v0,v⋆)=\mboxHead−Error(−v0,v⋆)\mbox{Head-Error}(v_{0},v_{\star})=\mbox{Head-Error}(-v_{0},v_{\star}) and v0v_{0} is symmetric around (v0v_{0} and −v0-v_{0} have the same probability), and is almost surely not exactly . So without loss of generality, we can suppose that v0⊤v⋆≥0v_{0}^{\top}v_{\star}\geq 0.

Suffices to bound ∣v0⊤v⋆−v⋆⊤v⋆∣\lvert v_{0}^{\top}v_{\star}-v_{\star}^{\top}v_{\star}\rvert: We decompose the error:

So we bound ∣v0⊤v⋆−v⋆⊤v⋆∣\lvert v_{0}^{\top}v_{\star}-v_{\star}^{\top}v_{\star}\rvert.

v0⊤v⋆v_{0}^{\top}v_{\star} is normally distributed: We note that v0⊤v⋆v_{0}^{\top}v_{\star} is distributed as:

In other words, a normal with mean , and variance σ12=σ2v⋆⊤v⋆\sigma_{1}^{2}=\sigma^{2}v_{\star}^{\top}v_{\star}, and therefore standard deviation σ1=σv⋆⊤v⋆\sigma_{1}=\sigma\sqrt{v_{\star}^{\top}v_{\star}}.

Apply Gaussian anti-concentration lemma: Then, from Lemma A.11, we have for some universal constant cc that with probability at least 1−δ1-\delta:

So substituting this back into Equation A.124, we get the desired result:

A.3.3 Upper bounding linear probing error

We showed a lower bound for the OOD error of fine-tuning in Theorem 3.3. To compare this with linear probing, we prove an upper bound on the OOD error of linear probing.

For completeness we include an elementary lemma (note that the condition that the matrices are tall is important for composing σmin⁡\sigma_{\min}, unlike for σmax⁡\sigma_{\max}, and we included this lemma to be careful about these conditions):

Suppose we have two matrices AA, BB of shape (r,s)(r,s) and (s,t)(s,t) respectively, and they are tall matrices so r≥s≥tr\geq s\geq t. Then we have:

And min⁡∥x∥2≤1∥x∥2=1\min_{\|x\|_{2}\leq 1}\|x\|_{2}=1 which completes the proof. ∎

In the linear overparameterized setting, under the ID subspace assumption, fix arbitrary PzP_{z}. Then there exists cδc_{\delta} such that with probability at least 1−δ1-\delta, for all d,n,m,k,w⋆d,n,m,k,w_{\star}, feature extractors B⋆,B0B_{\star},B_{0}, and ID subspaces SS with corresponding FF (whose columns are orthonormal and form a basis for SS), if cos⁡θmax(S,R)>0\cos\theta_{\mathsf{max}}(S,R)>0, we have:

If PzP_{z} is isotropic Gaussian so N(0,Im)\mathcal{N}(0,I_{m}), then we derive a bound for cδc_{\delta} analytically: if n≥5mn\geq 5m and n≥10log⁡1δn\geq 10\log{\frac{1}{\delta}} then with probability at least 1−δ1-\delta, the linear probing OOD error is upper bounded by:

From the ID subspace assumption, the data matrix XX of shape (n,d)(n,d) can be written as X=ZF⊤X=ZF^{\top} where ZZ be a matrix of shape (n,m)(n,m) with each row ZiZ_{i} sampled iid from PzP_{z}, and FF is a matrix of shape (d,m)(d,m) whose columns are orthonormal and form a basis for the ID subspace SS.

Let ϵ=∥B⋆−B0∥2≤\epsilon=\|B_{\star}-B_{0}\|_{2}\leq. We first prove the bounds for ϵ\epsilon, in terms of d(B0,B⋆)d(B_{0},B_{\star}) and we later handle the fact that the feature extractor distance involves the min over rotation matrices UU: d(B0,B⋆)=min⁡U∥UB0−B⋆∥2d(B_{0},B_{\star})=\min_{U}\|UB_{0}-B_{\star}\|_{2}.

Bounding key singular values: Before proceeding with the proof, we examine a key quantity XB0⊤=ZF⊤B0⊤XB_{0}^{\top}=ZF^{\top}B_{0}^{\top} which comes up in the Hessian of the loss function. We will show that this is invertible almost surely, and get a lower bound on its min singular value.

First, we examine the shapes of the matrices. ZF⊤B0⊤ZF^{\top}B_{0}^{\top} has shape (n,d)(n,d) where ZZ has shape (n,m)(n,m) and F⊤B0⊤F^{\top}B_{0}^{\top} has shape (m,k)(m,k). Since n≥m>kn\geq m>k we have that ZZ and F⊤B0⊤F^{\top}B_{0}^{\top} are tall matrices, and so from Lemma A.13 we can write the min singular value of ZF⊤B0⊤ZF^{\top}B_{0}^{\top} as:

Now from the definion of the principal angle (Definition 3.2), we have:

Since we assumed PzP_{z} has density in the ID subspace assumption, from Lemma 3 in Xie et al. (2021a) we get that for some cδ′>0c_{\delta}^{\prime}>0 that depends on δ\delta and PzP_{z}, with probability at least 1−δ1-\delta:

Note that this also means that σmin⁡(ZF⊤B0⊤)>0\sigma_{\min}(ZF^{\top}B_{0}^{\top})>0 and so XB0⊤=ZF⊤B0⊤XB_{0}^{\top}=ZF^{\top}B_{0}^{\top} has full rank kk almost surely. This also implies that B0X⊤XB0⊤B_{0}X^{\top}XB_{0}^{\top} is a matrix of shape (k,k)(k,k) that is invertible almost surely.

Main proof Since B0X⊤XB0⊤B_{0}X^{\top}XB_{0}^{\top} is invertible almost surely, there is a unique global minimum (minimizing over vv) to the loss optimized by linear-probing:

We can see this by noting that the loss function on the LHS is strongly convex in vv since the Hessian B0X⊤XB0⊤B_{0}X^{\top}XB_{0}^{\top} is invertible. Then, gradient flow converges to the unique minimizer on the RHS, so:

We now bound the square-root OOD error (taking the square root makes it easier to apply triangle inequalities), starting with the definition:

We bound each term on the RHS of the last line. For term (1)(1):

Where we note that ∥v⋆∥2=∥w⋆∥2\|v_{\star}\|_{2}=\|w_{\star}\|_{2} because w⋆=B⋆⊤v⋆w_{\star}=B_{\star}^{\top}v_{\star} where the rows of B⋆B_{\star} (columns of B⋆⊤B_{\star}^{\top}) are orthonormal.

Let Σ=X⊤X\Sigma=X^{\top}X. For term (2)(2), we first subtitute vlp∞{v_{\mathsf{lp}}^{\infty}} and do some algebra (again noting that ∥v⋆∥2=∥w⋆∥2\|v_{\star}\|_{2}=\|w_{\star}\|_{2}) to get:

Where in the first line we subtituted in the closed form for vlp∞{v_{\mathsf{lp}}^{\infty}} from Equation A.137, and in the last line we used the fact that σmax⁡(ZF⊤)≤σmax⁡(Z)\sigma_{\max}(ZF^{\top})\leq\sigma_{\max}(Z) since F⊤F^{\top} has orthonormal rows, and σmin⁡(ZF⊤B⊤)=σmin⁡(Z)cos⁡θmax(R,S)\sigma_{\min}(ZF^{\top}B^{\top})=\sigma_{\min}(Z)\cos\theta_{\mathsf{max}}(R,S) as explained in Equation A.134 and Equation A.135.

So it suffices to bound the quantities in the RHS. Since B0B_{0} has orthonormal rows, σmax⁡(B0)=1\sigma_{\max}(B_{0})=1.

No Gaussian assumption: For the first part of the Theorem (Equation A.132 where we make no Gaussian assumptions, but give a less quantitative bound), we just use the fact that σmax⁡(Z)\sigma_{\max}(Z) is upper bounded almost surely, and σmin⁡(Z)≥cδ′\sigma_{\min}(Z)\geq c_{\delta}^{\prime} with probability at least 1−δ1-\delta. This implies that for some cδ>0c_{\delta}>0 with probability at least 1−δ1-\delta:

where ϵ=∥B0−B⋆∥2\epsilon=\|B_{0}-B_{\star}\|_{2}.

With a bit of algebra, this gives us that with probability at least 1−δ1-\delta:

We assumed n≥5mn\geq 5m and n≥10log⁡1δn\geq 10\log{\frac{1}{\delta}}, so we get:

The upper bound is a standard matrix concentration bound—we use the high probability bound in Theorem 4.1.1 from Tropp (2015) (see Section 4.2.2 which calculates the variance statistic for rectangular Gaussian matrices, also notice the square on the LHS below):

Substituting the lower and upper bounds on σmin⁡(Z)\sigma_{\min}(Z) into Equation A.145 we get:

Substituting into equation A.139, we have:

where ϵ=∥B0−B⋆∥2\epsilon=\|B_{0}-B_{\star}\|_{2}. Which completes the proof of the second part (Equation A.133).

Handling the rotation matrix UU: We now handle the fact that the feature extractor distance involves the min over rotation matrices UU: d(B0,B⋆)=min⁡U∥UB0−B⋆∥2d(B_{0},B_{\star})=\min_{U}\|UB_{0}-B_{\star}\|_{2}. Let vlp∞(B0){v_{\mathsf{lp}}^{\infty}}(B_{0}) denote the linear probing head solution if we use a pretrained feature extractor B0B_{0}. We first note that for any kk-by-kk rotation matrix UU, we have:

This follows from using the closed form we derived above for vlp∞(B0){v_{\mathsf{lp}}^{\infty}}(B_{0}) and some simple algebraic manipulation (e.g., recall that U−1=Y⊤U^{-1}=Y^{\top}):

So the final predictors in both cases, (UB0)⊤vlp∞(UB0)(UB_{0})^{\top}{v_{\mathsf{lp}}^{\infty}}(UB_{0}) and B0⊤vlp∞(B0)B_{0}^{\top}{v_{\mathsf{lp}}^{\infty}}(B_{0}) are identical. This means that the OOD error Lood(v,B)=∥B⊤v−B⋆⊤v⋆∥2L_{\mathsf{ood}}(v,B)=\|B^{\top}v-B_{\star}^{\top}v_{\star}\|_{2} is the same in both cases.

This means that we can just take the min over all rotation matrices UU (where the first step follows since the identity matrix is a rotation matrix, and the second step is from Equation A.154):

which is as desired. We repeat the same thing for Equation A.160 to get Equation A.133 in the Theorem statement. ∎

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

Theorem 3.5 showed an asymptotic result: if the error d(B0,B⋆)→0d(B_{0},B_{\star})\to 0, then linear probing (LP) achieves better out-of-distribution (OOD) error than fine-tuning (FT). Here we give a more quantitative version of Theorem 3.5 for Gaussian covariates. The result can be extended to the case there each entry of PzP_{z} is independent and identically distributed, mean-zero, constant non-zero variance, but instead of Gaussian is sub-Gaussian with constant sub-Gaussian variance / moment—this can be shown using Theorem 1.1 in Rudelson & Vershynin (2009), which is a different matrix concentration inequality.

We show that LP does better than FT out-of-distribution if the error is less than a specific quantity (in terms of the representation dimension kk, and the angles between the ID subspace SS and the important pretrained directions R∗=\mboxrowspace(B⋆)R_{*}=\mbox{rowspace}(B_{\star})).

In the linear overparameterized setting, under the ID subspace assumption, assume the non-degeneracy conditions cos⁡θmax(R∗,S)>0\cos\theta_{\mathsf{max}}(R_{*},S)>0 and cos⁡θmax(R∗,S⊥)>0\cos\theta_{\mathsf{max}}(R_{*},S^{\perp})>0 where R∗=\mboxrowspace(B⋆)R_{*}=\mbox{rowspace}(B_{\star}). Suppose the covariates are generated from a Gaussian distribution on the ID subspace SS, so Pz=N(0,Im)P_{z}=\mathcal{N}(0,I_{m}). Let ∥w⋆∥2\|w_{\star}\|_{2} be a fixed constant. Given failure probability 1≤δ>01\leq\delta>0, for all w⋆,B0,n,d,k,ϵw_{\star},B_{0},n,d,k,\epsilon, if n≥5mn\geq 5m, and n≥10log⁡1δn\geq 10\log{\frac{1}{\delta}}, if the error of the pretrained representation is not too high:

then with probability at least 1−δ1-\delta, the OOD error of linear probing is lower (better) than for fine-tuning at all time steps t≥0t\geq 0 in the fine-tuning trajectory:

Let ϵ=d(B0,B⋆)\epsilon=d(B_{0},B_{\star}). We first note that the condition in Equation A.170 implies that d(B0,B⋆)<O(cos⁡θmax(R∗,S⊥))d(B_{0},B_{\star})<O(\cos\theta_{\mathsf{max}}(R_{*},S^{\perp})) and d(B0,B⋆)<O(cos⁡θmax(R∗,S))d(B_{0},B_{\star})<O(\cos\theta_{\mathsf{max}}(R_{*},S)). This is because the cosine angles are between and 11, δ\delta is between and 11, and kk and nn are at least 11. We now simplify and combine the linear probing and fine-tuning bounds.

Let R0=\mboxrowspace(B0)R_{0}=\mbox{rowspace}(B_{0}). Warning: note that the Equation A.170 in the Theorem statement assumes conditions on the angles between R∗R_{*} (corresponding to the optimal representation) and the ID subspace SS. However, our results that bounded the fine-tuning (Theorem 3.3) and linear probing (Lemma A.133) errors require conditions on the angles between R0R_{0} (corresponding to the representation that linear probing and fine-tuning use) and SS. So we have to be careful about this distinction, and use Lemma A.9 to relate the two, which we do below.

Where φ\varphi is the head-error, which we lower bounded in Lemma A.12—subtituting this bound and noting that min⁡(φ,φ2)=O(φ2)\min(\varphi,\varphi^{2})=O(\varphi^{2}), ∥v⋆∥2=∥w⋆∥2\|v_{\star}\|_{2}=\|w_{\star}\|_{2} (which we assumed is a constant), this gives us:

Now, since d(B0,B⋆)=ϵd(B_{0},B_{\star})=\epsilon, we use Lemma A.9 to get that:

Subtituting this into Equation A.173, we get (notice the R∗R_{*} instead of R0R_{0} below):

Since ϵ≤O(cos⁡θmax(R∗,S⊥))\epsilon\leq O(\cos\theta_{\mathsf{max}}(R_{*},S^{\perp})), this can be simplified to:

Linear probing: From Lemma A.133, we get:

Substituting into Equation A.177, and using the fact that ϵ≤O(cos⁡θmax(R∗,S))\epsilon\leq O(\cos\theta_{\mathsf{max}}(R_{*},S)), and since we assumed ∥w⋆∥2\|w_{\star}\|_{2} is a constant, we get:

Combining the two: We want to show that the OOD error of LP is less than for fine-tuning:

We can bring the ϵ\epsilon to the LHS, so this is equivalent to showing:

Since log⁡(n/δ)≥1\log(n/\delta)\geq 1 and cos⁡θmax(R∗,S))2\cos\theta_{\mathsf{max}}(R_{*},S))^{2} is between and 11, this is equivalent to folding the ϵ\epsilon inside the big-oh on the LHS:

But assuming the condition on ϵ\epsilon in Equation A.170 of the Theorem statement, this is easy to show with a bit of algebra. ∎

A.5 Principal angles are likely non-zero

In Theorems 3.3, 3.5, and 3.6, we assumed the cosine of the largest principal angle between the representations and ID subspace (or complement of the ID subspace) was non-zero. For example, Theorem 3.5 assumed the largest principal angle between R∗=\mboxrowspace(B⋆)R_{*}=\mbox{rowspace}(B_{\star}) and the ID subspace SS is non-zero, and similarly for the angle between R∗R_{*} and S⊥S^{\perp}. Having an angle of 0 is a degenerate condition. As an example, look at Figure 2—here the input dimension d=2d=2, the representation dimension k=1k=1, and the ID subspace SS has dimension 1. The only way these angles can be 0 is if B⋆⊤B_{\star}^{\top} is exactly in the same direction as SS or S⊥S^{\perp}, which seems like too much of a coincidence. intuitively, if nature introduces even a small amount of randomness in either the optimal representation or ID subspace, the angle will be non-zero.

This example was in two dimensions—to make this intuition a bit more formal in higher dimensions, we prove a simple claim. Lemma A.16 shows that if the SS is a randomly selected mm dimensional subspace, then the angles cos⁡θmax(R∗,S)\cos\theta_{\mathsf{max}}(R_{*},S) and cos⁡θmax(R∗,S⊥)\cos\theta_{\mathsf{max}}(R_{*},S^{\perp}) are non-zero (and we get quantitative lower bounds on them).

In addition, we get that cos⁡θmax(R,S)>0\cos\theta_{\mathsf{max}}(R,S)>0 almost surely (with probability 1).

If m≥5km\geq 5k and m≥10log⁡1δm\geq 10\log{\frac{1}{\delta}}, then we get with probability at least 1−δ1-\delta:

Recall that big-oh notation here means that the RHS is true for some universal constant (independent of any other problem parameters).

Equivalently, let MRM_{R} be a dd-by-kk matrix, where each column is sampled independently from N(0,Id)N(0,I_{d})—since the columns of MRM_{R} span a uniformly random kk-dimensional subspace, we can let RR be range of MRM_{R}. This is equivalent to sampling each entry of MRM_{R} from N(0,1)N(0,1).

Let c=cos⁡θmax(R,S)c=\cos\theta_{\mathsf{max}}(R,S). From Lemma A.2, cc can be written as:

So every r∈Rr\in R can be written as MRλM_{R}\lambda where ∥λ∥2\|\lambda\|_{2} is lower bounded as above.

We now simplify the definition of cc, starting from Equation A.186.

So now we want to lower bound the ratio of two random matrices. We note that F⊤MRF^{\top}M_{R} is a matrix of size (m,k)(m,k) with each entry sampled independently from N(0,1)N(0,1) (this is because F⊤F^{\top} simple selects the first mm rows of MRM_{R}). MRM_{R} is a matrix of size (d,k)(d,k) with each entry sampled independently from N(0,1)N(0,1).

Now, as in the Gaussian assumption step of the proof of Lemma A.14, we can apply standard matrix concentration bounds (page 4, below Equation 1.11, in Rudelson & Vershynin (2009) for the bound on σmin⁡\sigma_{\min}, and Theorem 4.1.1 in Tropp (2015) for the bound on σmax⁡\sigma_{\max}). We get that with probability at least 1−δ1-\delta:

Note that we can use alternate bounds for σmin⁡\sigma_{\min} in Rudelson & Vershynin (2009) that are sometimes tighter.

For the ratio of the two, we get that with probability at least 1−δ1-\delta, we have:

For interpretability, ignoring log factors this is approximately:

The result when m≥5km\geq 5k and n≥10log⁡2δn\geq 10\log{\frac{2}{\delta}} follows with simple algebra.

For the result where we show cos⁡θmax(R,S)>0\cos\theta_{\mathsf{max}}(R,S)>0 almost surely, we recall that F⊤MRF^{\top}M_{R} is a matrix of size (m,k)(m,k) with each entry sampled independently from N(0,1)N(0,1). Then applying Lemma 3 in Xie et al. (2021a), we get that σmin⁡(F⊤MR)>0\sigma_{\min}(F^{\top}M_{R})>0 almost surely. Since σmax⁡(MR)\sigma_{\max}(M_{R}) is finite, this gives us cos⁡θmax(R,S)>0\cos\theta_{\mathsf{max}}(R,S)>0 almost surely.

In our case, the dimension of the ID subspace SS is mm, and the dimension of R∗=\mboxrowspace(B⋆)R_{*}=\mbox{rowspace}(B_{\star}) is kk, with k<mk<m and k<d−mk<d-m. If SS is a uniformly random mm-dimensional subspace, then S⊥S^{\perp} is a uniformly random d−md-m dimensional subspace. In this case, Lemma A.16 tells us that cos⁡θmax(R∗,S)>0\cos\theta_{\mathsf{max}}(R_{*},S)>0 and cos⁡θmax(R∗,S⊥)>0\cos\theta_{\mathsf{max}}(R_{*},S^{\perp})>0 almost surely, and gives us quantitative lower bounds for these angles.

A.6 LP vs. FT (ID)

We prove Proposition 3.6, where we show that if the representation is imperfect, then fine-tuning does better than linear probing, in-distribution.

In the linear overparameterized setting, under the ID subspace assumption (Assumption 3.4), let R0=\mboxrowspace(B0)R_{0}=\mbox{rowspace}(B_{0}), and Raug=\mboxSpan({w⋆}∪R0){R_{\mathsf{aug}}}=\mbox{Span}(\{w_{\star}\}\cup R_{0}). Suppose w⋆∉R0w_{\star}\not\in R_{0}, cos⁡θmax(S,Raug)≠0\cos\theta_{\mathsf{max}}(S,{R_{\mathsf{aug}}})\neq 0, and that fine-tuning converges to a local minimum of its loss, then fine-tuning does better ID almost surely: Lid(vft∞,Bft∞)<Lid(vlp∞,B0)L_{\mathsf{id}}({v_{\mathsf{ft}}^{\infty}},{B_{\mathsf{ft}}^{\infty}})<L_{\mathsf{id}}({v_{\mathsf{lp}}^{\infty}},B_{0}) with probability 1 (over the randomness of the training examples).

Fine-tuning gets ID loss: It is well known from prior work (Laurent & von Brecht, 2018) that all local minima are global for optimizing two layer linear networks under convex losses (which is our setting), so if fine-tuning converges to a local minimum, it actually converges to a global minimum of the train loss. Since there exists parameters that achieve loss on the training data (namely, B⋆,v⋆B_{\star},v_{\star}), this means fine-tuning gets loss on the training data as well. So for all training examples xx (that is, rows of XX):

Since the models are linear, this implies that fine-tuning gets all examples in the span of the training examples correct as well. Since PzP_{z} has density, and the number of training examples nn is at least as large as the ID subspace dimension mm, the training examples span the ID subspace almost surely, so fine-tuning gets every example in x∈Sx\in S correct almost surely, giving us:

Linear probing gets positive ID loss: Lemma A.19 shows that the ID error of linear probing is greater than zero under the same assumptions as this Proposition, so

We now state and prove the Lemmas that we used to lower bound the ID error of linear probing.

Lemma A.17 gives conditions for when the projection F⊤wF^{\top}w of a vector ww is not contained in the projection \mboxRange(F⊤E0)\mbox{Range}(F^{\top}E_{0}) of the column space of a matrix E0E_{0}.

For (b), let a1,…,aka_{1},\ldots,a_{k} be the columns of E0E_{0}, which form a basis for \mboxRange(E0)\mbox{Range}(E_{0}). Then F⊤a1,…,F⊤ak,F⊤wF^{\top}a_{1},\ldots,F^{\top}a_{k},F^{\top}w spans \mboxRange(F⊤Eaug)\mbox{Range}(F^{\top}E_{\mathsf{aug}}), while F⊤a1,…,F⊤akF^{\top}a_{1},\ldots,F^{\top}a_{k} spans \mboxRange(F⊤E0)\mbox{Range}(F^{\top}E_{0}). So (notice the first list of vectors has an additional F⊤wF^{\top}w) this means that dim⁡(\mboxRange(F⊤Eaug))≠dim⁡(\mboxRange(F⊤E0))\dim(\mbox{Range}(F^{\top}E_{\mathsf{aug}}))\neq\dim(\mbox{Range}(F^{\top}E_{0})) iff F⊤wF^{\top}w is linearly independent from the rest, that is, F⊤w∉\mboxRange(F⊤E0)F^{\top}w\not\in\mbox{Range}(F^{\top}E_{0}). Note that the rank of a matrix is the dimension of its range (column space), that is, dim⁡(\mboxRange(A))=\mboxrank(A)\dim(\mbox{Range}(A))=\mbox{rank}(A) so this is what we wanted to show. ∎

The next Lemma says that if the projection F⊤w⋆F^{\top}w_{\star} of the optimal linear model w⋆w_{\star} onto the ID subspace SS, is not contained in the projection \mboxRange(F⊤E0)\mbox{Range}(F^{\top}E_{0}) of the features, then linear probing incurs non-zero ID error.

We prove the contrapositive. Suppose Lid(vlp∞,B0)=0L_{\mathsf{id}}({v_{\mathsf{lp}}^{\infty}},B_{0})=0. This means that:

Since the squared error is always non-negative, this means that vlp∞⊤B0x=w⋆⊤x{v_{\mathsf{lp}}^{\infty}}^{\top}B_{0}x=w_{\star}^{\top}x almost surely when x∼Pidx\sim P_{\mathsf{id}} (recall that we defined w⋆=B⋆⊤v⋆w_{\star}=B_{\star}^{\top}v_{\star}). Recall PidP_{\mathsf{id}} is defined as: first pick z∈Pzz\in P_{z} (which has density) and then output x=Fzx=Fz. Since PzP_{z} has density, this implies that we get all examples in the ID subspace SS correct:

Since the columns of FF form an orthonormal basis for SS, this gives us (since each column of FF is in SS):

Note that the rows of B0B_{0} also form an orthonormal basis for R0R_{0} just like the columns of E0E_{0}. So we can choose vv with v⊤E0⊤=vlp∞⊤B0v^{\top}E_{0}^{\top}={v_{\mathsf{lp}}^{\infty}}^{\top}B_{0}. Then we have:

where we took the transpose of both sides in the first step. This finishes the proof of the contrapositive. ∎

Finally, Lemma A.19 combines Lemma A.17 and Lemma A.18 to give a more interpretable condition for the ID error of linear probing: when the ID subspace SS has some components along the optimal linear model w⋆w_{\star} and the feature rowspace R0R_{0}, then linear probing has non-zero error. This is measured in terms of the principal angle cos⁡θmax(Raug,S)\cos\theta_{\mathsf{max}}({R_{\mathsf{aug}}},S) between the ID subspace SS and Raug{R_{\mathsf{aug}}} which is the span of R0R_{0} combined with w⋆w_{\star}. This angle will typically be non-zero—as an illustrative example, from Lemma A.16 we have that this angle will be non-zero almost surely if the ID subspace SS is a uniformly random subspace.

In the linear overparameterized setting, under the ID subspace assumption, let R0=\mboxrowspace(B0)R_{0}=\mbox{rowspace}(B_{0}), and Raug=\mboxSpan({w⋆}∪R0){R_{\mathsf{aug}}}=\mbox{Span}(\{w_{\star}\}\cup R_{0}). If w⋆∉R0w_{\star}\not\in R_{0} and cos⁡θmax(Raug,S)>0\cos\theta_{\mathsf{max}}({R_{\mathsf{aug}}},S)>0, then Lid(vlp∞,B0)>0L_{\mathsf{id}}({v_{\mathsf{lp}}^{\infty}},B_{0})>0.

A.7 LP-FT

We start by showing a simple proposition, that if the initial feature extractor is perfect, then linear probing recovers the optimal weights.

In the overparameterized linear setting, let R=\mboxrowspace(B0)R=\mbox{rowspace}(B_{0}). If B0=B⋆B_{0}=B_{\star}, and cos⁡θmax(S,R)>0\cos\theta_{\mathsf{max}}(S,R)>0, then Lood(vlp∞,B0)=0L_{\mathsf{ood}}({v_{\mathsf{lp}}^{\infty}},B_{0})=0 for all tt.

We first show that because cos⁡θmax(R,S)>0\cos\theta_{\mathsf{max}}(R,S)>0, the training loss for linear probing is strongly convex. Recall that the training loss is:

Linear probing keeps BB fixed as B0=B⋆B_{0}=B_{\star} and only tunes vv, so we are interested in the Hessian of the loss with respect to vv evaluated at v,B⋆v,B_{\star}:

For strong convexity, it suffices to show that the min singular value of the Hessian is bounded away from 0 by a constant. Recall the definition of cos⁡θmax(R,S)\cos\theta_{\mathsf{max}}(R,S). For some FF whose columns form an orthonormal basis for SS, we have (since the rows of B⋆B_{\star} form an orthonormal basis for RR):

Note that B⋆FB_{\star}F is a kk-by-nn matrix, so if the kk-th singular value is positive it must be full rank. Since the columns of X⊤X^{\top} span FF (since we defined FF to be such that the columns of FF are an orthonormal basis for SS, i.e. the rows of XX), this means B⋆X⊤B_{\star}X^{\top} is rank kk. But that means the Hessian (B⋆X⊤)(B⋆X⊤)⊤(B_{\star}X^{\top})(B_{\star}X^{\top})^{\top} is rank kk as well. So the linear probing loss is strongly convex.

Since the loss is strongly convex, there is a unique minimizer, and gradient flow converges to that. However, since we are in the well-specified setting, we know the training loss is:

So v=v⋆v=v_{\star} achieves 0 loss and must be the (unique) minimizer. Therefore we have shown that linear probing converges to the unique minimizer vlp∞=v⋆{v_{\mathsf{lp}}^{\infty}}=v_{\star}, which attains 0 loss, as desired.

Note that the entire proof works out if B0=UB⋆B_{0}=UB_{\star} for some rotation matrix UU. In that case, the Hessian becomes 2U(B⋆X⊤)(B⋆X⊤)⊤U⊤2U(B_{\star}X^{\top})(B_{\star}X^{\top})^{\top}U^{\top} which is still rank kk, since multiplying by square rotation matrices does not change the rank. In this case, the minimizer of the loss is v=Uv⋆v=Uv_{\star}, since (UB⋆)⊤(Uv⋆)=B⋆⊤v⋆(UB_{\star})^{\top}(Uv_{\star})=B_{\star}^{\top}v_{\star}. So linear probing converges to vlp∞=Uv⋆{v_{\mathsf{lp}}^{\infty}}=Uv_{\star}, which achieves 0 loss, as desired. ∎

Suppose we have perfect pretrained features B0=UB⋆B_{0}=UB_{\star} for some rotation UU. Let R0=\mboxrowspace(B0)R_{0}=\mbox{rowspace}(B_{0}). Under the non-degeneracy conditions cos⁡θmax(R0,S)≠0,cos⁡θmax(R0,S⊥)≠0\cos\theta_{\mathsf{max}}(R_{0},S)\neq 0,\cos\theta_{\mathsf{max}}(R_{0},S^{\perp})\neq 0:

We first use Proposition A.20, which in the proof we showed still works if B0=UB⋆B_{0}=UB_{\star} for some rotation matrix UU (which doesn’t have to be identity). We get that vlp∞=Uv⋆{v_{\mathsf{lp}}^{\infty}}=Uv_{\star}. Then we have B0⊤vlp∞=B⋆⊤v⋆=w⋆B_{0}^{\top}{v_{\mathsf{lp}}^{\infty}}=B_{\star}^{\top}v_{\star}=w_{\star}.

We now just show that the gradients with respect to the training loss L^\widehat{L} at (vlp∞,B0)({v_{\mathsf{lp}}^{\infty}},B_{0}) is 0, so gradient flow does not update the parameters at all.

Then since B0⊤vlp∞=B⋆⊤v⋆B_{0}^{\top}{v_{\mathsf{lp}}^{\infty}}=B_{\star}^{\top}v_{\star}, we have:

Next, the derivative with respect to BB is:

Then since B0⊤vlp∞=B⋆⊤v⋆B_{0}^{\top}{v_{\mathsf{lp}}^{\infty}}=B_{\star}^{\top}v_{\star}, we have:

So since both the derivatives are , we have ∂tvft(t)=0\partial_{t}{v_{\mathsf{ft}}}(t)=0 and ∂BBft(t)=0\partial_{B}{B_{\mathsf{ft}}}(t)=0, which means the parameters don’t change at all—at all times tt we have vft(t)=Uv⋆{v_{\mathsf{ft}}}(t)=Uv_{\star} and Bft(t)=UB⋆{B_{\mathsf{ft}}}(t)=UB_{\star} which gives us zero OOD loss: Lood(Bft(t)⊤vft(t))=0L_{\mathsf{ood}}({B_{\mathsf{ft}}}(t)^{\top}{v_{\mathsf{ft}}}(t))=0 as desired. ∎

Appendix B More information on experiments

In this Appendix, we include more details on the datasets, pretraining methods, and adaptation methods. We also include the OOD accuracies for fine-tuning and linear-probing if we early stop and choose the learning rate based on OOD data, where we see that linear-probing is still typically better than fine-tuning OOD. Finally, we include results for additional baselines, pretraining models, and conclude with a discussion about the effective robustness of LP-FT.

We use a diverse range of datasets and pretraining strategies.

CIFAR-10 →\to STL: We fine-tune or linear probe on CIFAR-10 (Krizhevsky, 2009) and test on STL (Coates et al., 2011). This is a benchmark used in domain adaptation papers (French et al., 2018). CIFAR-10 and STL share 9 classes, so we follow the common practice of omitting the unshared class in STL (which is the ‘monkey’ class) when reporting accuracies. We use a publicly available MoCo-v2 ResNet-50 checkpoint pretrained on unlabeled examples from ImageNet-1k (Russakovsky et al., 2015), and fine-tune for 20 epochs.

DomainNet: We use the dataset splits in Tan et al. (2020) which is also used by follow-up work, e.g., in Prabhu et al. (2021). This is different from the original version of the DomainNet dataset (Peng et al., 2019), specifically Tan et al. (2020) note that some domains and classes contain many mislabeled outliers, so they select the 40 most common classes from the ‘sketch’, ‘real’, ‘clipart’ and ‘painting’ domains. We use the ‘sketch’ domain as ID, and all other domains (‘real’, ‘clipart’, ‘painting’) as OOD, and in the main paper we report the average accuracies across the OOD domains. In Table 3 we see that the same trends hold for each of the three OOD domains. We use a CLIP (Radford et al., 2021) pretrained ResNet-50 model, and fine-tune for 50 epochs (since this is a smaller dataset).

Living-17 and Entity-30: We use a publicly available MoCo-v2 ResNet-50 checkpoint pretrained on unlabeled examples from ImageNet-1k (Russakovsky et al., 2015), and fine-tune for 20 epochs. Note that Living-17 and Entity-30 are subpopulation shifts derived from ImageNet, but the pretraining is done on unlabeled data and does not see any OOD labels, following the pretraining and fine-tuning strategy in Cai et al. (2021). Entity-30 is a relatively large dataset that contains around 140K training examples.

FMoW Geo-shift: We adapt the version of the dataset from (Koh et al., 2021). We use training data from ‘North America’ to fine-tune or linear probe, and then evaluate on validation data from Africa and Europe. We use a MoCo-TP (Ayush et al., 2020) checkpoint, pretrained on unlabeled FMoW satellite images. We fine-tune for 50 epochs here since the ID training dataset is smaller (around 20K examples).

CIFAR-10 →\rightarrow CIFAR-10.1 (Recht et al., 2018): We follow the same protocols as CIFAR-10 →\to STL, except we test on CIFAR-10.1.

ImageNet: we linear probe or fine-tune on ImageNet (Russakovsky et al., 2015), and evaluate on ImageNetV2 (Recht et al., 2019), ImageNet-R (Hendrycks et al., 2020), ImageNet-A (Hendrycks et al., 2019b), and ImageNet-Sketch (Wang et al., 2019). We use a CLIP pretrained ViT-B/16 (vision transformer), the largest publicly available CLIP model (Radford et al., 2021). We ran fine-tuning for 10 epochs, linear probing for 10 epochs. To equalize the runtime for LP-FT, we ran the linear probing stage for 5 epochs, and then the fine-tuning stage for 5 epochs. We used a batch size of 128 for all methods.

Tuning for ImageNet experiments. We swept over three learning rates for fine-tuning (0.0001, 0.0003, 0.001) and linear probing (0.01, 0.03, 0.1)—as is standard we use larger learning rates for linear probing. For LP-FT, we swept over 3 learning rates (0.01, 0.03, 0.1) for the 5-epoch linear probing step. We took the run that had the best ImageNet (ID) validation accuracy, and then swept over 3 learning rates (0.00001, 0.00003, 0.0001) for the 5-epoch fine-tuning step—we use a lower learning rate for LP-FT since the experiments on the other datasets suggested that the optimal learning rate that maximizes ID validation accuracy for LP-FT is smaller. We did not find the comparisons to be particularly sensitive to learning rate choice.

Augmentations for ImageNet experiments. We used augmentations for fine-tuning, and no augmentations for linear probing, following Kornblith et al. (2019). This might raise a question of whether linear probing and LP-FT do better OOD because of the lack of augmentations. So as an ablation we also tried fine-tuning without augmentations, however that led to worse accuracy (than fine-tuning with augmentations) both ID and OOD. We now give details on the preprocessing and augmentations that we used. On ImageNet, for linear probing and LP-FT, we used no augmentations—we just resized each image so that the smaller side has size 224 with bicubic interpolation, and then center-crop to a 224-by-224 image. For fine-tuning, we used augmentations: specifically we use RandomResizedCrop in TorchVision, with the default arguments and setting the size of the crop to 224, and then apply a random horizontal flip.

Notes on pretrained model choice. We note that our results say that the pretraining has to be good (e.g., at least get reasonable accuracy ID) for linear probing to outperform fine-tuning OOD. So, for example, we use a model pretrained on unlabeled satellite images for the satellite image dataset—if we pretrain the model on ImageNet, we expect that fine-tuning might do better. Similarly, for DomainNet we use a CLIP pre-trained model, which is pretrained on the very large WebImageText dataset, and sees a variety of photo and sketch like images. Pretraining on ImageNet alone does not lead to high accuracies on DomainNet (features are not very good), so we do not necessarily expect linear probing to outperform fine-tuning with these lower quality features (for example, see the MoCo ablation in our main paper where we used a worse pretrained model, and fine-tuning did better OOD).

Sanity check of fine-tuning implementation. As a sanity check of our implementation, fine-tuning did substantially better than training from scratch on all datasets (both ID and OOD) and matched existing fine-tuning numbers where available (e.g. ResNet50 on CIFAR-10 (Chen et al., 2020b) and Entity-30 (Cai et al., 2021)). Fine-tuning and linear probing also both do substantially better than training from scratch, ID and OOD, across the datasets. For example, on Living-17, training from scratch gets 89.3% ID and 58.2% OOD (Santurkar et al., 2020) which is over 5% worse ID and nearly 20% worse OOD, than all the adaptation methods. For reference linear probing gets 96.5% ID and 82.2% OOD, and fine-tuning gets 97.1% ID and 77.8% OOD. This is even though training from scratch was run for 300 epochs, which is 15 times longer than fine-tuning and LP-FT.

B.2 Target early stopping

In the main paper, one ablation we mention is early stopping each fine-tuning method and choose the best learning rate based on target validation accuracy. As expected, fine-tuning does improve a little, but linear probing (average accuracy: 67.1%) is still better than fine-tuning (average accuracy: 61.3%). Table 4 shows the full results for all datasets.

B.3 Feature change

We examine how much the features changed for ID and OOD examples in each dataset. Specifically, for each dataset, for each input example in the held out validation set, we computed the Euclidean distance of the ResNet-50 features before and after fine-tuning. We averaged these numbers across the dataset, showing the results for ID validation examples in Table 5, and for OOD examples in Table 6.

The feature distortion theory predicts that the features for ID examples change more than for OOD examples. This bears out in 9 out of 10 cases, that is all cases except for FT on FMoW. To see this, compare each cell in Table 5 with the corresponding cell in Table 6—the former is higher in 9 out of 10 cases.

The feature distortion theory says that this large feature change is caused because the head is randomly initialized—since the head needs to be updated by a large amount, the feature extractor is also updated a lot because the updates are coupled. Our theory predicts that if the head is initialized via linear probing then the feature extractor should change a lot less for both ID and OOD examples. As predicted by the theory, across all the datasets in Table 5 and Table 6, the features change a lot less for LP-FT than for FT. For example, on CIFAR-10, the features change 30×\times less for LP-FT than for FT.

These results suggest that fine-tuning underperforms OOD, and LP-FT does well ID and OOD, for the reasons predicted by the feature distortion theory.

B.4 Additional architectures, fine-tuning methods

The main contributions of our paper are conceptual understanding and theory. However, to strengthen the empirical investigation we ran two additional models (a CLIP vision transformer and CLIP ResNet-50), as well as three additional fine-tuning heuristics. We focus on the Living-17 dataset because some of these ablations require lots of compute and can take a long time to run on all the datasets.

Architectures and pretraining source: In the main paper, we showed results when initializing with a MoCo-v2 ResNet-50 model pretrained on unlabeled ImageNet examples. Here we examine how the results change when we 1. Use a ResNet-50 model pretrained on CLIP’s WebImageText dataset (Table 7), and, 2. Use a much larger vision transformer model (ViT-B/16) pretrained on CLIP’s WebImageText dataset (Table 8)—this is the largest publicly available CLIP model at the time of writing. We see that similar findings to our main paper hold—fine-tuning does better than linear probing ID, but does worse than linear probing (‘underperforms’) OOD. Finally, LP-FT does better than both methods ID, and closes most (75%-90%) of the gap OOD.

These results are from early stopping on ID validation data. If we early stop on OOD validation data, LP-FT achieves 87.9±0.487.9\pm 0.4% OOD accuracy, and LP gets 88.3±0.288.3\pm 0.2% OOD accuracy and here there is no statistically significant difference between the two. On the other hand, even if we early stop on OOD validation data, fine-tuning gets 84.4±0.584.4\pm 0.5% OOD accuracy which is lower.

Fine-tuning heuristics: Transfer learning (initializing with a pretrained model, and then adapting it to a downstream task) is the standard way to build modern ML models, because it improves accuracy and speeds up training. Since this paradigm is so widely used, there are many heuristics people use when training their models (as mentioned in the main paper, LP-FT has sometimes been used as a heuristic as well, although not in the context of OOD). We showed that LP-FT is one way to do well ID and OOD, but we hope that our theory leads to even better fine-tuning algorithms.

In this section, we compare LP-FT with additional fine-tuning heuristics: using a larger learning rate for the head layer, regularizing the features towards their original values, and side-tuning (Zhang et al., 2020) where we freeze the features but add a side-network.

The intuitions from our theory suggest two other potential ways to improve OOD accuracy: 1. We could use a higher learning rate on the linear layer, so that the linear layer learns quicker and the features do not get as distorted, and 2. We could regularize the weights of the feature extractor towards the pretrained initialization, to prevent feature distortion. These heuristics have been used in prior work on fine-tuning as well, for example method 2 corresponds to L2-SP in (Li et al., 2018).

We run these two approaches on Living-17. For approach (1), we use a 10×\times higher learning rate for the linear layer, and for approach (2) we regularize the Euclidean distance between the current feature extractor weights (so ignoring the linear head) from the pretrained weights, multiplying by a hyperparameter λ\lambda. We grid search over the same learning rates as fine-tuning for both methods, and in addition for (2) we grid search over λ∈{1.0,0.1,0.01,0.001,0.0001}\lambda\in\{1.0,0.1,0.01,0.001,0.0001\}, so this amounts to sweeping over 30 hyperparameters as opposed to just 6 for fine-tuning and LP-FT. For each hyperparameter configuration we run 33 replication runs with different seeds to reduce the estimation variance, and early stop and model select using ID data just like for fine-tuning and LP-FT. Just like for fine-tuning and LP-FT, we use a cosine learning rate decay and train for the same number of epochs. Indeed, we find that both (1) and (2) are able to close part of the OOD gap between fine-tuning and linear-probing. However, LP-FT does better than both methods ID and OOD. The full results are in Table 9.

We also compare with another method, (3) side-tuning (Zhang et al., 2020). Side-tuning freezes the pretrained features g(x)g(x) but trains another ‘side’ model s(x)s(x), and then outputs v⊤(g(x)+h(x))v^{\top}(g(x)+h(x)), where the head vv and the parameters of the side model ss are tuned. The intuition for trying this is that side-tuning also preserves the pretrained features which likely reduces feature distortion. In the supplementary of Zhang et al. (2020) they use a ResNet-50 for both the original model and the side model in their vision experiments, so we do the same. We sweep over twelve learning rates (3⋅10−5,1⋅10−4,3⋅10−4,…,1.0,3.0,10.03\cdot 10^{-5},1\cdot 10^{-4},3\cdot 10^{-4},\ldots,1.0,3.0,10.0), with three replication runs with different seeds for each learning rate. Just like for fine-tuning and LP-FT, we use a cosine learning rate decay and train for the same number of epochs, and we early stop and model select using ID validation data. We checked that the best learning rate was not at the boundary of the grid search. On OOD, side-tuning (81.0%) improves over fine-tuning (77.7%). However, side-tuning doesn’t do as well ID. LP-FT did better ID and OOD. This could be because side-tuning does not get to refine the pretrained features for the ID task—while the side-network is powerful enough to learn good features, it is initialized randomly and effectively trained from scratch, so it might not be able to learn these good features on the limited sized training dataset (around 40K examples). The results are also in Table 9.

We also include results for training from scratch in Table 9—these results are from Santurkar et al. (2020). Note that training from scratch was done for 450 epochs, whereas fine-tuning was done for 20 epochs. As a sanity check, all the fine-tuning methods and linear probing do substantially better than training from scratch, both ID and OOD.

B.5 Discussion of effective robustness

LP-FT gets higher OOD accuracy than fine-tuning, but it sometimes gets higher ID accuracy as well. Taori et al. (2020) and Miller et al. (2021) show that OOD accuracy can often be correlated with ID accuracy, and suggest examining the effective robustness: intuitively the extra gain in OOD accuracy than can be predicted from improved ID accuracy alone. Is LP-FT simply better in-distribution, or does it have higher effective robustness as well?

We start out by noting that linear probing clearly has higher effective robustness in most of our datasets. Linear probing does worse than fine-tuning ID so based on the effective robustness framework we would expect it to do worse than fine-tuning OOD as well. However, linear probing does better than fine-tuning OOD and therefore has higher effective robustness.

The solutions found by LP-FT also appear to have higher effective robustness than fine-tuning, because when they have similar ID accuracy, LP-FT does much better OOD. For a few pieces of evidence:

On CIFAR-10 →\to STL, there is no statistically significant difference between FT and LP-FT on ID, but LP-FT gets 8% higher accuracy OOD in Table 2.

If we look at checkpoints earlier in training for CIFAR-10 →\to STL we can exactly equalize ID accuracy and compare OOD accuracies. In-distribution, LP-FT and FT both get 97.2% accuracy, but OOD, LP-FT (90.2%) is much better than FT (81.8%).

Finally, in Figure 3 we plot the OOD accuracy against the ID accuracy for fine-tuning and LP-FT on Living-17. We plot these for three different pretrained models (CLIP ResNet-50, CLIP ViT-B/16, MoCo-V2 ResNet-50). We see that the ID-OOD line for LP-FT is above the line for FT indicating effective robustness.

Note that higher effective robustness does not mean a method is better. For example, a method A can have higher effective robustness B by doing a lot worse in-distribution even when they have the same OOD accuracy. In this case, A is clearly inferior since it does worse ID and same OOD, but has higher effective robustness because of its worse ID accuracy.

We believe the finding that linear probing and LP-FT has higher effective robustness than fine-tuning when the distributon shift is large is particularly interesting because Taori et al. (2020) and Miller et al. (2021) show that it is uncommon for methods to have higher effective robustness. In our case linear probing and LP-FT appear to consistently have higher effective robustness which suggests that with good transfer learning methods we can get both high in-distribution accuracy and higher effective robustness.

Appendix C Additional related work

Modern deep learning presents an interesting paradigm for theoretical analysis where the number of parameters is much larger than the number of training points. The model class is highly expressive and several solutions obtain zero training loss even in the presence of noise. Such overparameterized models have received a lot of interest recently especially with a focus on understanding “benign overfitting” or the phenomenon where fitting noisy training data to zero loss leads to classifiers that generalize well. By analyzing different linear overparameterized settings Belkin et al. (2019); Hastie et al. (2019); Bartlett et al. (2019); Muthukumar et al. (2020); Mei & Montanari (2019); Bibas et al. (2019) study various statistical properties such as the “double descent curve” in addition to benign overfitting. One important aspect of overparameterized models is that there is no unique minimizer of the training loss. We need some inductive bias which is typically implicit via the optimization procedure. Prior works study the statistical properties of the explicit inductive bias of minimum norm interpolation. In contrast, we study the effect of gradient based optimization from a particular pretrained initialization where we effectively capture the exact implicit inductive bias of gradient based fine tuning.