Distilling Test-Time Augmentation Without Its Corruptions

Test-time augmentation (TTA) runs a trained image classifier on several transformed copies of each test image (flips, crops, rescalings) and averages the predictions. It reliably buys accuracy and better uncertainty estimates, but it has two costs. Inference compute grows with the number of views. Averaging can also flip correct predictions into wrong ones: on ImageNet, over one-third of the labels that TTA changes are these "corruptions" (Better Aggregation in Test-Time Augmentation). The natural fix for the compute cost is knowledge distillation, which trains a single-pass "student" network to imitate the averaged multi-view "teacher." That has been done, but only with uniform averaging over four rotations (Rethinking Data Augmentation: Self-Supervision and Self-Distillation).

This note argues that naive TTA distillation is weak for two reasons, and that both can be fixed. First, if the teacher labels its own training images, its augmented views almost all agree, because it has memorized those images. The distillation target then carries little beyond what the single-view teacher already outputs. Diversity Matters When Learning From Ensembles reports exactly this "hidden diversity" problem for deep ensembles. Second, uniform averaging passes the corruptions on to the student. Distillation also has an advantage that test-time aggregation lacks: when the targets are built, the true label is known. We propose to build distillation targets from the teacher's views on images it did not train on (cross-fitting), and to weight each view per image by how much probability it gives the true label. This keeps the views that correct errors and drops the ones that corrupt, and a student run once per image then learns from the result.

Core Claim

A single-pass student trained on cross-fitted, label-weighted TTA targets can match or exceed the accuracy of multi-pass TTA with learned aggregation weights (ClassTTA) at one forward pass. It should also have a lower corruption rate relative to the single-view teacher than either uniform TTA or ClassTTA. Two ablations test the mechanism. Removing cross-fitting should shrink the gain toward plain self-distillation. Removing label weighting should bring back TTA's corruptions in the student. The contrast with prior work is specific. SLA+SD distills uniform, label-blind targets computed on training images. AugTTA and ClassTTA (When and Why Test-Time Augmentation Works) learn weights that are fixed across images and still require $M$ passes. Our weights vary per image, use the label, and are consumed only during training.

Research Program

We first train a teacher classifier with standard training-time augmentation. We then produce distillation targets by K-fold cross-fitting. The training set is split into $K$ folds, one teacher is trained per held-out fold, and each teacher computes its $M$ augmented-view predictions only on the fold it never saw. We use $K=2$ by default and $K=5$ as a variant. These held-out views disagree the way test-time views do. That is the reason ClassTTA fits its weights on a validation set, and we extend the same logic to the whole distillation set. As a cheaper variant, we also run a single full-data teacher whose targets are computed at an early-stopped checkpoint.

For a training image $x$ with true label $y^*$, let $p_m(\cdot \mid x)$ be the held-out teacher's prediction on view $m \in \{1,\dots,M\}$, with $m=1$ the unaugmented view. The target is

$$q(y \mid x) \propto \sum_{m=1}^{M} p_m(y^* \mid x)^{\beta}\, p_m(y \mid x),$$

where $\beta \ge 0$ controls how strongly views are weighted by their confidence in the true label. Setting $\beta=0$ gives uniform TTA. A large $\beta$ approaches selecting the best view for each image. This keeps the full soft distribution of the trusted views, including which other classes they find similar, rather than collapsing to the label. The student is trained on unaugmented and lightly augmented inputs with a temperature-scaled KL divergence to $q$, plus cross-entropy on the hard label. This is the loss form of Transferring knowledge from a RNN to a DNN.

Label-aware weighting can distort the ranking of the non-true classes. Isotonic Data Augmentation for Knowledge Distillation documents this kind of teacher "order violation" for Mixup and CutMix. We therefore measure Kendall's $\tau$ between $q$ and the single-view teacher over the non-true classes. If it drops sharply, we test IDA's cheap penalty variant (KD-p), which that paper reports adds only 1% to 2% training time.

A secondary arm asks whether the spread across views can replace a physical ensemble for uncertainty. Here the student instead predicts Dirichlet parameters fit to the weighted per-view predictions, following Ensemble Distribution Distillation. The motivation is the finding in Pitfalls of In-Domain Uncertainty Estimation and Ensembling in Deep Learning that TTA rivals small deep ensembles on calibrated log-likelihood.

Baselines

The do-nothing reference is the teacher architecture trained normally and run on the unaugmented image. For ImageNet with ResNet-50, Learning Instance-Specific Augmentations by Capturing Local Invariances reports 80.43% top-1, and it reports that random-crop TTA falls below this. InstaAug TTA itself reaches 81.18%. We treat that result as a multi-pass reference, not a single-pass competitor.

The strongest multi-pass competitor is ClassTTA, which learns weights per transformation and class on a validation set. We run it on the same teacher, with the same $M$-view policy and the same validation data. The file reports gains of "up to 2.5%" top-1 but no per-dataset figure: no reported result found on Lacuna for ClassTTA's standalone CIFAR-100 or ImageNet top-1. We will therefore reproduce it. Uniform TTA over the same views is also run.

The strongest single-pass competitors come from three lines of work. The first is SLA+SD, rerun with our view policy as well as its native rotations. The second is naive distillation from uniform TTA computed on the teacher's own training images. The third is distillation of ClassTTA's outputs, which is the obvious "Gap 1" method. For reference on CIFAR-100 distillation strength, Diversity Matters When Learning From Ensembles reports 80.51% with standard ensemble KD and 81.88% with ConfODS, for a WideResNet-28x10 ensemble distilled into a BatchEnsemble student. We will run deep-ensemble distillation with the same backbone and report it against the training compute it uses.

The key ablation is plain self-distillation: the same student trained on the single-view teacher's outputs, with the same cross-fitting, schedule, and augmentation. This isolates the contribution of multiple views from the known benefit of re-training on a teacher's soft labels. A further ablation drops cross-fitting and keeps label weighting, and a third varies $\beta$ from 0 up.

All students share the same architecture, epochs, training augmentation, and a tuning budget for the temperature, $\beta$, and loss weights, tuned on the same held-out split. We report training compute, counting the extra teacher runs from cross-fitting. Beating ClassTTA means equal or higher top-1 at one pass, with a lower corruption rate. Beating self-distillation means a gain outside the seed-to-seed spread over at least three seeds.

Why not just…?

Why not just train with heavier training-time augmentation? The student already trains with the teacher's augmentation, so any gain is on top of it. There is also evidence that TTA adds benefit beyond training-time augmentation. Data Augmentation for Skin Lesion Analysis reached 0.882 AUC with training-time augmentation plus TTA, above the 0.874 of the ISIC 2017 winner. We also include a student trained with the full TTA view set as training-time augmentation and no distillation.

Why not just do born-again self-distillation? This is the main threat, because a single-view soft-label teacher often improves the student by itself. The self-distillation ablation, with matched cross-fitting, settles the question. If it matches our method, then the views contribute nothing and the claim fails.

Why not just distill ClassTTA or run it at test time? ClassTTA's weights are fixed across images and cannot see the label, so its targets still carry corruptions on individual images. Running it at test time costs $M$ passes. We compare against both, and the corruption and correction rates relative to the single-view teacher show directly whether per-image label weighting is what matters.

Why not just distill a deep ensemble? It requires $K$ full trainings, and on training data its members agree for the same memorization reason (Diversity Matters When Learning From Ensembles). Cross-fitting has a cost too, so we compare methods at matched training compute rather than claim the ensemble is automatically worse.

Proposed Experiments

The benchmarks are CIFAR-100 and CIFAR-100-C with a WideResNet, Tiny-ImageNet, and ImageNet with ResNet-18 and ResNet-50, plus ISIC 2017 as a medical case where TTA is known to help. On CIFAR-100-C, the multi-pass reference from Learning Loss for Test-Time Augmentation is 45.15% error, falling to 41.92% when it selects one predicted-best view. That method needs an extra auxiliary network at test time; our student needs one pass and nothing else. Uncertainty is evaluated by negative log-likelihood, expected calibration error, and out-of-distribution detection AUROC on LSUN, where EnD² reports about 94% from a physical ensemble.

The first decisive check comes before any student is trained. We measure how much the teacher's views disagree on its own training images versus held-out images. If the training-image disagreement is not much lower, cross-fitting is unnecessary and we drop it. The second check compares corruption rates of the student, uniform TTA, and ClassTTA against the same single-view reference. The third tests whether the gap over self-distillation holds on ImageNet, where the file's TTA corruption statistics were measured. The proposal succeeds if a one-pass student recovers most of the TTA gain on at least ImageNet and CIFAR-100-C, beats self-distillation outside seed noise, and inherits fewer corruptions than TTA itself.