TL;DR
When evaluating pretrained Vision Transformers (ViTs) on downstream tasks, standard practice is to probe the final output of the transformer blocks. This paper reveals that out-of-distribution (OOD) shift causes deep transformer layers to degrade significantly, and probing block outputs is suboptimal. Under severe distribution shifts, probing the internal activation of intermediate feedforward layers delivers substantially better accuracy, while LayerNorm outputs are preferable when the shift is weak.
What Problem Does This Paper Address?
Recent findings in large language models showed that intermediate layers often produce more useful, linearly separable representations than final layers. However, earlier studies suggested this was a quirk of autoregressive pretraining—noting that standard ViTs evaluated on ImageNet achieved their best accuracy at the very final layer.
The authors show that this conclusion was biased by evaluating ViTs only on in-distribution (ID) data. In real-world deployment, foundation models inevitably face distribution shifts. This paper investigates how distribution shift between pretraining and downstream tasks impacts linear probing across both depth (layer-by-layer) and architectural components (module-by-module).
Methods
The authors evaluate an 86M-parameter ViT-Base pretrained on ImageNet-21k using linear probing (pooling the [CLS] token embedding and training a logistic regression classifier via L-BFGS).
Rather than treating each transformer block as a black box (which typically outputs the second residual connection, RC2), the authors track representations at 8 internal operations within every block:
LN1: Pre-attention Layer NormalizationMHA: Multi-Head Self-Attention outputRC1: First Residual ConnectionLN2: Pre-feedforward Layer NormalizationFC1: First fully connected layer ($d \to 4d$)Act: GeLU non-linear activationFC2: Second fully connected layer ($4d \to d$)RC2: Second Residual Connection (standard block output)
They compare frozen pretrained ViT representations against fully finetuned models across layers to quantify how distribution shift dictates layer optimality.
Datasets
The backbone model is pretrained on ImageNet-21k. Downstream linear probing and finetuning evaluations span 11 image classification benchmarks with varying degrees of distribution shift:
- Standard vision benchmarks: CIFAR-10, CIFAR-100, Flowers102, Oxford-IIIT Pet.
- Corrupted benchmarks (Severity 5): CIFAR-10-C variants (Contrast, Gaussian Noise, Motion Blur, Snow, Speckle Noise).
- Domain shift benchmarks: DomainNet subsets (Clipart, Sketch).
Key Insights and Ideas
- Distribution shift is the real culprit: In ID or near-ID settings (e.g., Flowers102, CIFAR-10), representations improve monotonically with depth, making final layers optimal. As distribution shift increases (e.g., corrupted CIFAR or Sketch), final-layer performance plunges, making intermediate layers significantly superior.
- The standard block output (
RC2) is suboptimal: Across almost all evaluated downstream datasets, probing the standard transformer block output (RC2) did not achieve optimal accuracy. Actthrives under distribution shift: Probing immediately after the feedforward GeLU activation (Act) yields the overall highest win-rate across datasets and heavily outperforms other modules under strong distribution shift. Expanding the representation to higher dimension ($4d$) followed by non-linear gating appears to disentangle semantic features useful for linear probing.FC2is consistently the worst probe location: Probing after the second linear projection (FC2, which compresses $4d \to d$) produced the lowest accuracy in 10 out of 12 downstream evaluations.- A safer heuristic: If a practitioner cannot accurately gauge the severity of test-time distribution shift, probing
LN2provides consistently competitive, stable representations without the sharp layer-dependent degradation seen in raw feedforward activations.
Key Results
- OOD Performance Gains via
Act: On high-shift corruptions and domains, probing intermediateActsignificantly outperformed standard block outputs (RC2): - Motion Blur:
Actachieves 71.15% vs.RC2's 67.75%. - Gaussian Noise:
Actreaches 61.85% vs.RC2's 58.20%. - Speckle Noise:
Actachieves 63.35% vs.RC2's 59.80%. - DomainNet Sketch:
Actreaches 34.90% vs.RC2's 32.99%. - Low-Shift / ID Tasks: On near-ID datasets,
LN2orRC2performs best, whereasActsuffers (e.g., CIFAR-10:FC192.28%,LN292.20%,RC292.07% vs.Act85.30%). - Module Win-Rate: Out of all 8 probed modules across 11 datasets,
Actwon on 6 benchmarks,LN2won on 3,FC1on 1, andRC2tied for 1 (Flowers102).
Limitations and Future Work
- Architecture and Scale Diversity: Experiments focus solely on an 86M-parameter ViT-Base; results remain to be validated across larger foundation scales (e.g., ViT-Large, ViT-Giant) or alternative vision architectures (e.g., ConvNeXt, Swin).
- Probing Modality: The study focuses exclusively on linear probing via the
[CLS]token with frozen backbones. Downstream parameter-efficient finetuning (PEFT, e.g., LoRA) was not analyzed. - Theoretical Formalization: Hypotheses regarding representation dimension expansion ($4d$), noise filtering in activations, and key-value memory dynamics currently rely on empirical observations rather than rigorous information-theoretic proofs. Extending this analysis with geometric and invariance metrics represents an open research direction.
Summary updated