Abstract
Test-time augmentation—the aggregation of predictions across transformed versions of a test input—is a common practice in image classification. Traditionally, predictions are combined using a simple average. In this paper, we present 1) experimental analyses that shed light on cases in which the simple average is suboptimal and 2) a method to address these shortcomings. A key finding is that even when test-time augmentation produces a net improvement in accuracy, it can change many correct predictions into incorrect predictions. We delve into when and why test-time augmentation changes a prediction from being correct to incorrect and vice versa. Building on these insights, we present a learning-based method for aggregating test-time augmentations. Experiments across a diverse set of models, datasets, and augmentations show that our method delivers consistent improvements over existing approaches.
Introduction: The Hidden Cost of Test-Time Augmentation
Test-Time Augmentation (TTA) is a widely used technique to boost the performance of image classifiers without retraining the underlying model. By passing multiple transformed versions of a single image (e.g., various crops and flips) through the model and averaging the results, practitioners can often achieve a "free" increase in accuracy.
However, this paper reveals a significant downside to standard TTA: corruptions. While the net accuracy usually improves, simple averaging frequently turns a correct "raw" prediction into an incorrect one. This occurs because uniform averaging assumes all augmentations are equally valid for all classes, which is often not the case in practice.
Smarter Aggregation: AugTTA and ClassTTA
To address the limitations of simple averaging, we propose moving toward a weighted aggregation scheme. Instead of treating every augmentation as equal, we learn weights that reflect the reliability of different transformations. We introduce two primary variants:
- AugTTA (Augmentation-Weighted TTA): This method learns a single weight for each transformation type (e.g., horizontal flip, center crop) that is applied globally across all classes.
- ClassTTA (Class-Weighted TTA): This more granular approach learns specific weights for every (augmentation, class) pair. This allows the model to recognize that certain transformations, like a tight crop, might be highly beneficial for identifying a "rose" but detrimental for identifying "bougainvilleas."
These weights are optimized using a small, held-out validation set while the base classifier remains frozen. This makes the approach a lightweight, "plug-and-play" layer that can be added to any existing model with minimal computational overhead during training.
Key Insights: The "Net Improvement" Illusion
A central finding of our research is that standard TTA metrics often hide the true dynamics of model behavior. For instance, on a ResNet-18 model trained on ImageNet, over one-third of the labels changed by TTA were actually corruptions.
Our analysis identifies several reasons for these failures:
- Inductive Bias of Crops: TTA policies rely heavily on cropping, which can bias the model toward smaller or uncentered objects, leading to errors in images with hierarchical labels or multiple classes.
- Scale Sensitivity: Learned weights often penalize high-scale augmentations (extreme zooming) because they remove the context necessary to differentiate between similar species.
- Efficiency and Pruning: Our learned weights often go to zero for redundant or harmful augmentations. For a ResNet-50 on ImageNet, the model learned to ignore 72% of the augmentations in an expanded policy, suggesting that smarter aggregation can actually reduce test-time latency by pruning useless computations.
Experimental Results
Our method demonstrated consistent improvements over standard averaging and Greedy Policy Search (GPS) across four diverse datasets: ImageNet, Flowers-102, CIFAR-100, and STL-10.
Key highlights include:
- Accuracy Gains: We observed Top-1 accuracy increases of up to 2.5%.
- Model Scaling: Smarter TTA allows smaller, more efficient models (like MobileNetV2) to match or exceed the performance of much larger architectures (like ResNet-50) that do not use TTA.
- Dataset Specificity: We found that ClassTTA is particularly effective for specialized datasets with fewer classes and more samples per class (like Flowers-102), while AugTTA is more robust for high-class, data-sparse environments like ImageNet.
Conclusion and Future Work
By shifting from simple averaging to learned aggregation, we can significantly mitigate the corruption of correct predictions and improve the overall reliability of TTA. While our current method requires a representative validation set to learn weights, future work could explore instance-aware TTA, where weights are dynamically adjusted for each individual image. This would further refine the model's ability to handle complex visual scenes where the optimal transformation is highly dependent on the specific input.
Summary updated