A Layer Selection Approach to Test Time Adaptation
Sabyasachi Sahoo, Mostafa ElAraby, Jonas Ngnawe, Yann Pequignot, Frederic Precioso, Christian Gagne
TL;DR
The paper tackles distribution shift in Test Time Adaptation by showing that not all network layers respond equally to adaptation and that misaligned gradient updates can degrade performance. It introduces Gradient-Aligned Layer Adaptation (GALA), a cosine-distance–based layer selection criterion that ranks layers by gradient alignment and applies a binary mask to update only the most beneficial layer per sample, with a reset window to accommodate direction changes. Through extensive experiments on DomainBed and Continual TTA benchmarks, GALA consistently outperforms ERM and all-layers baselines across backbones and losses, and approaches or surpasses oracle layer strategies without requiring target labels. The results reveal that good layers vary with shift and loss, and that the reset mechanism further boosts performance in multi-domain settings, highlighting GALA’s practical potential as a robust, flexible plug-in for TTA systems.
Abstract
Test Time Adaptation (TTA) addresses the problem of distribution shift by adapting a pretrained model to a new domain during inference. When faced with challenging shifts, most methods collapse and perform worse than the original pretrained model. In this paper, we find that not all layers are equally receptive to the adaptation, and the layers with the most misaligned gradients often cause performance degradation. To address this, we propose GALA, a novel layer selection criterion to identify the most beneficial updates to perform during test time adaptation. This criterion can also filter out unreliable samples with noisy gradients. Its simplicity allows seamless integration with existing TTA loss functions, thereby preventing degradation and focusing adaptation on the most trainable layers. This approach also helps to regularize adaptation to preserve the pretrained features, which are crucial for handling unseen domains. Through extensive experiments, we demonstrate that the proposed layer selection framework improves the performance of existing TTA approaches across multiple datasets, domain shifts, model architectures, and TTA losses.
