In the world of computer vision, we often face a double-edged sword. On one side, we have Unsupervised Domain Adaptation (UDA), which helps models trained on one dataset (like synthetic images) work on another (like real-world photos). On the other side, we have Anytime Prediction, which allows a model to scale its complexity up or down depending on available battery or processing power.
Until now, these two fields lived in separate neighborhoods. If you adapted a model for a new domain, it was usually stuck at one specific size. If you wanted a smaller version for a mobile phone, you had to start the adaptation process all over again.
A new paper from ICLR 2023, "AnyDA: Anytime Domain Adaptation," bridges this gap. The authors introduce a framework that creates a single model capable of adapting to new domains while remaining "switchable" across a wide range of computational budgets on the fly.
TL;DR
AnyDA is the first framework to combine anytime prediction with unsupervised domain adaptation, allowing a single neural network to handle domain shifts while dynamically adjusting its width, depth, and resolution. By using a novel "bootstrapped recursive distillation" technique, it achieves state-of-the-art accuracy across varying hardware constraints without needing to retrain for every specific device.
What Problem Does This Paper Address?
Standard UDA methods are "static." They assume you know exactly what hardware your model will run on. However, real-world applications are messy. An AI model might run on a high-powered cloud server one minute and a low-power edge device the next.
Adapting a model independently for every possible hardware configuration is expensive and slow. Ideally, we want a model that can run in "high-accuracy mode" when plugged into a wall and "low-power mode" when running on a battery, all while maintaining its ability to understand a new target domain. The challenge is that shrinking a model often breaks the delicate domain alignment achieved during training.
Methods
The authors propose AnyDA, which uses a "Supernet" architecture—a single large network that contains many smaller "subnetworks" within it.
1. Multi-Dimensional Flexibility
Unlike previous works that only varied one aspect of a network, AnyDA allows for three-way flexibility:
- Width: Choosing how many channels to use in a layer.
- Depth: Choosing how many layers to execute.
- Resolution: Adjusting the input image size.
2. Bootstrapped Recursive Distillation
This is the "secret sauce." To train the student network, the authors use a teacher network that is an Exponential Moving Average (EMA) of the student’s own past weights.
- The Minnet (the smallest possible subnetwork) is trained to mimic the average prediction of all teacher subnetworks.
- The Intermediate Subnetworks are trained to mimic the largest "Supernet" of the teacher.
This creates a "recursive flow of knowledge," ensuring that even the tiniest version of the model benefits from the features learned by the largest version.
3. Domain-Specific Switchable Batch Normalization
To handle the distribution shift between the source and target domains, AnyDA maintains separate Batch Normalization (BN) statistics for each domain and each subnetwork size. This ensures that the internal data scaling remains accurate regardless of which "slice" of the model is being used.
4. The Sandwich Rule
To make training efficient, they don't train every possible subnetwork. Instead, they train the largest (Supernet), the smallest (Minnet), and two random sizes in between. This "sandwiches" the performance of all other possible configurations.
Datasets
The authors evaluated AnyDA on four standard UDA benchmarks:
- Office-31: A classic dataset with images from Amazon, DSLR cameras, and Webcams.
- DomainNet: A massive dataset with six domains (Clipart, Infograph, Painting, Quickdraw, Real, Sketch).
- Office-Home: 65 categories across four domains (Art, Clipart, Product, Real-World).
- ImageCLEF-DA: A benchmark featuring three common datasets (Caltech-256, ImageNet, Pascal VOC).
Key Insights and Ideas
- Alignment is not enough: Simply aligning the domains for a large model doesn't mean the smaller sub-models will be aligned. You must explicitly distill that "alignment knowledge" down the ladder.
- Recursive is better than direct: Training a small model to mimic a giant one directly is hard. Training it to mimic an ensemble of slightly larger models (recursive distillation) provides a more stable learning signal.
- No Discriminator Needed: Surprisingly, AnyDA achieves excellent domain alignment without using a standard "domain discriminator" (a common but often unstable component in UDA). Instead, it relies on self-supervision and distillation.
Key Results
AnyDA consistently outperformed existing methods, especially at lower computational budgets:
- Office-31: At a budget of 0.2G MACs (very low power), AnyDA outperformed the previous state-of-the-art (DDA) by 8%.
- Office-Home: At the lowest budget settings, AnyDA's average accuracy was a staggering 30% higher than DDA.
- Graceful Degradation: While other models see their accuracy "fall off a cliff" when reduced in size, AnyDA showed a very minimal drop (only 1.1% on Office-31) even when the budget was slashed by 8x.
Limitations and Future Work
- Training Overhead: While the "sandwich rule" helps, training a Supernet is still more computationally expensive than training a single static model.
- Fixed Budget Range: The range of budgets (min and max) must be defined during training. If a device requires a budget even smaller than the "Minnet," the model won't be optimized for it.
- Future Directions: The authors suggest exploring even more extreme values of width and depth, and potentially applying this "anytime" logic to other tasks like semantic segmentation or object detection.
AnyDA represents a significant step toward making domain adaptation practical for the diverse world of mobile and edge computing. It proves that we don't have to choose between a model that is smart and a model that is fast—we can have both in a single package.
Summary updated