Layer by layer, module by module: Choose both for optimal OOD probing of ViT

Ambroise Odonnat, Vasilii Feofanov, Laetitia Chapel, Romain Tavenard, Ievgen Redko

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:

  1. LN1: Pre-attention Layer Normalization
  2. MHA: Multi-Head Self-Attention output
  3. RC1: First Residual Connection
  4. LN2: Pre-feedforward Layer Normalization
  5. FC1: First fully connected layer ($d \to 4d$)
  6. Act: GeLU non-linear activation
  7. FC2: Second fully connected layer ($4d \to d$)
  8. 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.
  • Act thrives 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.
  • FC2 is 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 LN2 provides 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 intermediate Act significantly outperformed standard block outputs (RC2):
  • Motion Blur: Act achieves 71.15% vs. RC2's 67.75%.
  • Gaussian Noise: Act reaches 61.85% vs. RC2's 58.20%.
  • Speckle Noise: Act achieves 63.35% vs. RC2's 59.80%.
  • DomainNet Sketch: Act reaches 34.90% vs. RC2's 32.99%.
  • Low-Shift / ID Tasks: On near-ID datasets, LN2 or RC2 performs best, whereas Act suffers (e.g., CIFAR-10: FC1 92.28%, LN2 92.20%, RC2 92.07% vs. Act 85.30%).
  • Module Win-Rate: Out of all 8 probed modules across 11 datasets, Act won on 6 benchmarks, LN2 won on 3, FC1 on 1, and RC2 tied 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

BibTeX
@inproceedings{odonnat2026layer,
  author = {Ambroise Odonnat and Vasilii Feofanov and Laetitia Chapel and Romain Tavenard and Ievgen Redko},
  title = {{Layer by layer, module by module: Choose both for optimal OOD probing of ViT}},
  booktitle = {CAO @ ICLR},
  year = {2026},
  url = {https://openreview.net/forum?id=4lT3aScsRJ},
}

Loading related content...

Figure