Spec²R Repairs Supervised Vision Transformers to Boost Robustness by 23.7%
A spectral analysis pinpoints MLP layers as the reason supervised Vision Transformers lack DINO-style object-aligned features, and fixes it with lightweight fine-tuning.
Takeaways
- Spec²R recovers DINO-like object-aligned features in supervised ViTs without changing attention weights.
- Spectral analysis shows MLP layers in supervised ViTs inject high-frequency noise that destroys patch structure.
- Fix: fine-tune only MLPs and classification head with radial, angular, and KL regularization losses.
- Preserves ImageNet-1K top-1 accuracy within 0.4 points on DeiT-III, DeiT-Distilled, FlexiViT.
- Improves APGD-CE adversarial robustness by 9.5 to 23.7 percentage points, largest gain on DeiT-III.
- Boosts Energy Pointing Game, VOC foreground IoU, and TokenCut CorLoc for unsupervised object discovery.
Vision Transformers with nearly identical architectures can learn very different internal representations. A DINO-trained ViT often produces attention maps that concentrate on objects and patch tokens that cluster by semantic part. A supervised ViT trained on the same ImageNet-1K images, patch size, and depth can produce grid-like features with little object alignment. The Spec²R paper traces that gap to the model’s multilayer perceptron blocks, or MLPs, and proposes repairing a supervised checkpoint by retraining those blocks while freezing self-attention.
A ViT divides an image into patches, converts each patch into a token, and adds a CLS token that summarizes the image for classification. Every transformer block contains self-attention, which mixes information across tokens, and a position-wise MLP, which transforms each token. Spec²R separates those two residual branches to identify which one disrupts spatial structure.
Augmentation leaves the gap open
DINO’s emergent object alignment appears in two measurable forms: the leading principal components of its patch tokens follow object boundaries, and some CLS-token attention heads act like unsupervised foreground segmenters. Supervised recipes including DeiT-III, DeiT-Distilled, and FlexiViT do not consistently develop those properties, despite strong data augmentation.
Object-aligned representations can support unsupervised segmentation, object discovery, localization, and tools that inspect attention for model behavior. Teams seeking those capabilities have typically needed a separate self-supervised checkpoint or a new pretraining run. Spec²R instead starts from an existing supervised ViT.
The noise starts in the MLP
The paper visualizes every transformer block by projecting its patch tokens onto the top three principal components of the final representation and rendering those components as RGB. DINO progressively sharpens object structure across its blocks. In the supervised models, later blocks add high-frequency spatial patterns that obscure the coarse object layout.
A radial spectral moment quantifies that pattern by applying a spatial-frequency analysis to the patch-token grid. The scalar rises as spectral energy moves toward higher frequencies. Measuring it separately for each MLP and attention residual branch shows that MLP branches drive the increase across DeiT-III, DeiT-Distilled, and FlexiViT. The attention branches contribute much less to the measured degradation.
Three losses target one branch
Spec²R fine-tunes the MLP layers and classification head of a pretrained supervised ViT while keeping self-attention and all remaining parameters fixed. The trainable scope is selective, although MLPs still account for a substantial share of a ViT’s parameters.
| Objective term | Purpose |
|---|---|
| Radial spectral loss | Penalizes MLP updates that shift patch-token energy toward high spatial frequencies. |
| Angular spectral loss | Constrains how spectral energy is distributed by direction in the two-dimensional frequency plane. |
| KL-divergence loss | Keeps the revised model’s output distribution close to that of the original supervised checkpoint. |
Freezing the attention parameters still allows attention maps to change because earlier MLP updates alter the hidden states entering each attention layer. After those inputs become spatially cleaner, CLS attention concentrates more strongly on objects. The result indicates that useful object-selective behavior can remain latent in supervised attention heads while noisy token representations obscure it.
Small clean-accuracy cost, larger robust gains
Across the three supervised baselines, ImageNet-1K top-1 accuracy falls by roughly 0.4 percentage points or less after fine-tuning. Under the paper’s APGD-CE evaluation, an iterative projected-gradient adversarial attack using cross-entropy loss, robust accuracy rises by 9.5 to 23.7 percentage points. DeiT-III records the largest gain.
| Evaluation | Reported result | What it measures |
|---|---|---|
| ImageNet-1K top-1 | About 0.4 points of loss or less | Clean classification accuracy |
| APGD-CE | 9.5 to 23.7 points of improvement | Accuracy under the paper’s adversarial threat model |
| Energy Pointing Game | Improves for all three baselines | Share of attention mass inside a ground-truth box |
| PASCAL VOC foreground IoU | Improves for all three baselines | Overlap between predicted and ground-truth foreground regions |
| TokenCut CorLoc | Improves on VOC07 and VOC12 | Frequency with which unsupervised object discovery localizes the main object correctly |
Object-centric gains are strongest in deeper blocks, where the supervised checkpoints previously showed the greatest structural degradation. The adversarial results apply to the paper’s stated APGD-CE configuration and establish robustness within that threat model.
Best fit and open gaps
Existing supervised ViT deployments are the clearest use case. A team can retain a DeiT-III, DeiT-Distilled, or FlexiViT classifier while adding stronger inputs for TokenCut, unsupervised segmentation, localization, or attention-based inspection. The method also isolates the intervention to MLPs and the classifier head, which makes the paper’s causal claim testable during reimplementation.
- Evaluated architecture: ViT-B/16 variants.
- Starting point: supervised checkpoints trained with strong augmentation.
- Reference tasks: ImageNet-1K classification, APGD-CE robustness, PASCAL VOC foreground alignment, and TokenCut object discovery.
- Unresolved scope: larger ViTs, other patch sizes, and broader representation benchmarks remain unevaluated in this version.
- Availability: the paper version cited here provides no official code or pretrained weights, so adopters must implement the spectral objectives from the method description.
The evidence supports a focused conclusion: supervised ViTs can retain useful attention behavior while their MLP branches degrade spatial structure. Spec²R recovers much of that structure by constraining the frequency content introduced by those branches, with a small reported cost to clean classification accuracy.