Vision transformers are image models that cut a picture into small square patches and let every patch exchange information with every other patch from the first layer onward. On large datasets this all-to-all mixing makes them unusually tolerant of local damage such as a blurred region, an air bubble on a slide, or a pen mark, because evidence is pooled from the whole image. Clinical imaging tasks, however, often have fewer than a hundred labeled cases. In that regime practitioners either restrict attention to local windows to make training stable, or accept that the model will latch onto spurious cues. Nobody has measured what either choice does to corruption robustness. We propose to measure it, and to test a cheap training signal that only exists because corruptions are synthesized: when we paste an artifact onto an image, we know exactly which patches it covers. We use that free location information to penalize any increase in attention paid to corrupted patches.
The core bet is simple. With few training samples, attention collapses onto a handful of patches. One cue is whether the damaged region sits on those patches, but even then the model does not necessarily fail; the failure we target is the model actively redirecting attention toward the artifact, which is what makes it fragile. Supervising the location of attention on artifacts, rather than only the consistency of the output, should constrain where the model takes its evidence from. Output-level consistency, by contrast, can be satisfied through shortcuts when data are scarce. If this holds, a small-cohort transformer can keep the robustness that global attention provides on large data, without the locality restrictions that small-data medical architectures adopt.
What the literature establishes and leaves open
Several papers motivate the idea. On large data, transformers resist natural corruption better than convolutional networks. In digital pathology, Benchmarking the Robustness of Deep Neural Networks to Common Corruptions in Digital Pathology built PatchCamelyon-C and LocalTCT-C: nine corruption types (blur, color shifts, JPEG, bubbles, pen marks) at five severities. In that benchmark, transformers outperformed convolutional networks on localized slide artifacts, error rates roughly doubled under corruption for all models, and models stayed confidently wrong. The study used data-rich training only. Are Vision Transformers Robust to Patch Perturbations? explains the mechanism with two contrasting results. Naturally corrupted patches receive low attention, giving DeiT-small a 1.8% fooling rate versus 3.7% for ResNet50 with 32 corrupted patches. An optimized patch instead "hijacks" attention, giving a 61.5% versus 30.6% fooling rate. Robustifying Token Attention for Vision Transformers names the related failure "token overfocusing": attention concentrates on a sparse, fragile set of patches. That paper fixes it with an attention diversification loss and token-aware pooling, improving mean corruption error by 2.4% on ImageNet-C. Its fix is location-agnostic and was tested only on large datasets.
Other papers constrain the design. The small-data medical transformers both retreat from global attention. Medical Transformer splits attention into gated row and column operations and adds a local branch over sub-patches, reaching 81.02 F1 on GlaS with 85 training images. NA-UNETR calls global attention noisy and restricts it to local 3D neighborhoods for 20-scan coronary artery segmentation. Neither was evaluated under corruption, so whether locality reintroduces the single point of failure seen in convolutional networks is unknown. Unveiling COVID-19 from Chest X-ray shows small cohorts drive models toward source-hospital and hardware shortcuts. Limitations of Synthetic Data Generation in Specialized Data-Scarce Domains shows generative augmentation produces idealized images and fails to beat AugMix. AugMix is a stochastic augmentation method that mixes randomly chained image operations. That result is why we use structured corruption models rather than generators, and why AugMix is our main rival.
Two works are closest to ours, and we differ from each in a specific way. Token-overfocusing regularization spreads attention everywhere without knowing which patches are damaged. The mixed-supervision extension of attention pooling on whole-slide images, Attention-based Multiple Instance Learning with Mixed Supervision on the Camelyon16 Dataset, does supervise where attention goes, raising slide AUC from 0.895 to 0.924 with 10% annotated slides. It needs pathologist patch labels, however, and it targets lesion evidence rather than artifacts. Our signal requires no human annotation, and it says where the model should not look.
Core Claim
The claim has two parts. First, when a pretrained vision transformer is fine-tuned on progressively smaller training sets, the concentration of its attention rises. Its error on held-out corruption types rises with that concentration, and does so more steeply than it does for a convolutional network or a locally windowed transformer. Second, an attention-mass penalty that uses known artifact locations closes more of this gap on unseen corruption types than output-consistency augmentation or location-agnostic attention diversification, at equal compute.
The penalty is defined as follows. Let $x$ be a clean image and $\tilde{x}$ the same image with a localized synthetic artifact covering the patch set $M$. Let $a^{l,h}_j(\cdot)$ be the average attention that patch $j$ receives in layer $l$, head $h$. For classification this is attention from the class token; for segmentation it is the average over all query patches. We add
$$\mathcal{L}_{\text{mass}} = \frac{1}{LH}\sum_{l,h} \max\Big(0,\ \sum_{j\in M} a^{l,h}_j(\tilde{x}) - \sum_{j\in M} a^{l,h}_j(x)\Big),$$
where $L$ and $H$ are the numbers of layers and heads. This term penalizes only an increase in attention to the damaged region relative to the clean view. That increase is the signature of hijacking. The term does not force the region to zero, so the model can still use tissue that is partly visible under a bubble. Some corruptions cover the whole image, such as defocus or a hue shift, and have no mask. For those we fall back to a divergence between clean and corrupted attention maps.
Research Program
The program has three stages. The first is a measurement study. We fine-tune ImageNet-pretrained DeiT-small, a SegFormer encoder (SegFormer), MedT, a windowed-attention variant matched in parameters, and ResNet-18 or U-Net references. Training uses class-balanced subsets of the PatchCamelyon training set of 50, 100, 500 and 5,000 images, plus the full set, and the 85 GlaS training images. For each model and size we record attention entropy and the share of attention held by the top 1% of patches. We also record corruption error on PatchCamelyon-C and on a GlaS-C we construct, applying the same nine corruption generators and five severities to the GlaS test parts. This answers the open question about locality directly.
The second stage trains with the penalty. Corruption families are split by kind. Bubbles, pen marks and pixelation are used in training. Defocus, motion blur, JPEG and the color shifts are held out entirely for testing. This prevents any method from winning simply by having seen the test corruption.
The third stage runs two secondary probes. One is the single-patch adversarial attack of Gu et al. on the small-data classifiers, which tests whether the penalty reduces hijacking it was never trained on. The other is the corruption error of confidence metric from Zhang et al., which tests whether the models stop being confidently wrong. We report the confidence result whichever way it comes out; it is not part of the core claim.
Baselines
The naive reference is standard fine-tuning with flips, rotations and elastic deformation, the recipe the GlaS challenge found necessary on 85 images. We run it at every training size with the same epochs and learning-rate sweep as all other methods.
The strongest competitor is AugMix with its clean-versus-augmented output consistency loss, applied to the same backbone. To make the comparison fair, AugMix's operation pool is extended to include the training-split corruption generators, so it sees exactly the same corrupted images as our method. Limitations of Synthetic Data Generation found that no generative method consistently beat AugMix in scarce, high-variance domains. No reported corruption-error result was found on Lacuna for AugMix or any method on PatchCamelyon-C or GlaS. The digital-pathology benchmark summary gives only that error roughly doubles under corruption. Our baseline numbers will therefore be produced in-house under one protocol.
The second strong competitor is token-aware pooling with attention diversification. Its reported gains are a 2.4% mean corruption error improvement on ImageNet-C and 2.4% mIoU on Cityscapes-C. We also run it combined with AugMix, since that pairing is the obvious off-the-shelf answer.
The inference-time competitor is smoothed attention, which raises the softmax temperature above 1. Gu et al. report it cut DeiT-small's adversarial fooling rate from about 60% to 40%. We tune its temperature on a corrupted validation split built only from training corruption families.
Architectural competitors are MedT, at its reported GlaS F1 of 81.02, and the windowed variant. Every method receives the same corrupted images and a 20-configuration tuning budget, and is run with five seeds.
Two ablations isolate the key ingredient. The first applies the mask penalty with the mask randomly relocated. It tests whether the true location matters, or whether any attention regularization under augmentation suffices. The second removes the masked term and keeps only the clean-versus-corrupted attention divergence.
We count the proposal as beating the baselines only under three conditions. It must lower mean corruption error on held-out corruption families relative to AugMix plus diversification at training sizes of 100 or fewer. The margin must exceed the across-seed standard deviation. Clean accuracy, or clean F1 on GlaS, must not drop by more than one point.
Why not just…?
Why not just use AugMix with the corruption generators? This is the most serious threat. At larger training sizes it may well match our method, since output consistency over many images can indirectly shape attention. Our argument is specific to small data. With 50 to 100 images, output consistency can be met by a shortcut that ignores the artifact region by coincidence on training images but not on new ones; the shortcut findings of Tartaglione et al. suggest this pattern. The held-out-family comparison across training sizes decides the question. If AugMix matches us at every size, the location signal adds nothing, and the paper reduces to the measurement study.
Why not just restrict attention locally, as MedT and NA-UNETR do, or use a convolutional network? These designs train well on small data. Neither has been evaluated under corruption, however, and the large-data evidence from Gu et al. and Zhang et al. says local processing is what fails under localized damage. Stage one measures this directly. If windowed models prove as robust as global ones at small training sizes, we report that, and the case for keeping global attention weakens.
Why not just smooth attention at test time? Smoothing flattens attention uniformly. It can dilute the small, local evidence that matters in pathology, such as a few tumor cells in a patch, and it left a gap to ResNet50 of 40% versus 30.6% under attack in Gu et al. It needs no training data, so it is cheap. We include it at a tuned temperature and report its cost in clean accuracy.
Why not just apply attention diversification as published? Diversification spreads attention without knowing where damage is. Our random-mask ablation is effectively a location-blind version of our own penalty. The gap between the true-mask and random-mask runs measures what location knowledge buys over diversification.
Decisive checks
Three results decide the outcome. The first is whether attention concentration and held-out corruption error both rise as the training set shrinks, more steeply for global transformers than for convolutional networks. If not, the premise fails. The second is whether the true-mask penalty beats the random-mask penalty and AugMix plus diversification on unseen corruption families at 100 or fewer images. This is the core claim. The third is whether the single-patch attack's fooling rate falls on small-data DeiT-small trained with the penalty, despite no adversarial training. A positive result here would tie the artifact-location signal to the hijacking mechanism that Gu et al. identified, rather than to augmentation volume.
References
- Benchmarking the Robustness of Deep Neural Networks to Common Corruptions in Digital Pathology
- Are Vision Transformers Robust to Patch Perturbations?
- Robustifying Token Attention for Vision Transformers
- Medical Transformer: Gated Axial-Attention for Medical Image Segmentation
- A Neighborhood Attention Transformer Network for Enhanced 3D Segmentation of the Left Anterior Descending Artery
- Unveiling COVID-19 from CHEST X-Ray with Deep Learning: A Hurdles Race with Small Data
- Attention-based Multiple Instance Learning with Mixed Supervision on the Camelyon16 Dataset
- SegFormer: Simple and Efficient Design for Semantic Segmentation with Transformers
- Gland segmentation in colon histology images: The glas challenge contest