Tracking the Label Prior by Mirror Descent to Stop Test-Time Adaptation from Collapsing

A model deployed in the world often adapts itself on the fly to unlabeled incoming data. A common way to do this is to make its own predictions more confident. This works when test images arrive shuffled, but it fails badly when they arrive the way real data does: in correlated runs, such as video frames or a ward full of the same diagnosis, with a few classes dominating at any moment. The model mistakes "many recent images look like class 7" for "everything is class 7," and its accuracy collapses. We propose to make one quantity explicit: the label prior, meaning the fraction of current test inputs belonging to each class. We estimate it online with mirror descent on the probability simplex, an update that changes the estimate multiplicatively rather than additively. We then use this estimate to decide how much each class should be allowed to dominate the adaptation signal. Because the estimate comes from the frozen source model rather than from the model being adapted, it cannot be pulled along by the adaptation's own errors.

The bridge to optimization theory is specific. Expectation-Maximization for mixture models is exactly mirror descent under the Kullback–Leibler (KL) divergence with step size one, and the likelihood is "relatively smooth" with respect to that geometry. Relative smoothness means the loss curves no faster than the chosen distance measure, so steps can stay large without diverging. This was shown for mixtures of experts in Learning Mixtures of Experts with EM: A Mirror Descent Perspective. Estimating a test-time label prior is the simplest such mixture problem, so the same theory gives a tuning-free safe step and a principled way to trade tracking speed against noise. This replaces the momentum heuristics that current non-IID adaptation methods rely on.

Core Claim

Under temporally dependent, class-imbalanced test streams, the dominant failure of entropy-based test-time adaptation is a feedback loop: the adapted model's skewed predictions are treated as evidence of a skewed distribution, and that further skews the model. We claim three things. First, a label-prior estimate that is decoupled from the adapted model and updated by KL mirror descent breaks this loop. Second, the estimate needs only O(C) memory for C classes. Third, it matches or beats the strongest current reweighting method on the non-IID benchmarks where Tent collapses, while not hurting performance on IID streams.

The update is the following. Let $p_s(c\mid x)$ be the frozen source model's predicted probability of class $c$, $\pi_s$ the source class frequencies, $\pi_t$ the current prior estimate, $B_t$ the incoming batch, and $\eta\in(0,1]$ a step size. Each sample first gets a prior-corrected posterior $r_i(c)\propto p_s(c\mid x_i)\,\pi_t(c)/\pi_s(c)$. The prior then moves by a KL-proximal step:

$$\pi_{t+1}(c)\;\propto\;\pi_t(c)^{1-\eta}\Big(\tfrac{1}{|B_t|}\textstyle\sum_{i\in B_t} r_i(c)\Big)^{\eta}.$$

At $\eta=1$ this is one EM step on the current batch. Smaller $\eta$ blends geometrically with the past. The update is closed-form, keeps $\pi$ strictly inside the simplex, and involves no exponentials of unbounded quantities. That last property mirrors the overflow-free design of A Geometry-Aware Efficient Algorithm for Compositional Entropic Risk Minimization.

The adapted network is updated as in Tent: entropy minimization on batch-normalization scale and shift parameters. The difference is that each sample's entropy term is weighted by $\pi_t(\hat c)/m_t(\hat c)$. Here $\hat c$ is the adapted model's predicted class and $m_t$ is a running estimate of how often the adapted model predicts each class. A class the adapted model over-predicts, relative to what the decoupled prior supports, therefore loses influence on the gradient.

Relation to Prior Work

The closest method is DELTA (DELTA: DEGRADATION-FREE FULLY TEST-TIME ADAPTATION). DELTA diagnosed that dependent streams and class imbalance break test-time adaptation. Its remedies are batch renormalization plus Dynamic Online re-weighTing, which tracks class prediction frequencies with a momentum vector. That paper motivates our proposal and supplies our main baseline. We differ in two ways. Its frequency vector is an additive moving average of the adapted model's own predictions, so it inherits that model's bias. It also has no notion of a true local prior distinct from the uniform target. We separate the "what is actually arriving" estimate from the "what is the adapted model doing" estimate, and we derive the former as a mirror-descent likelihood step rather than a smoothing heuristic.

Tent (Tent: Fully Test-Time Adaptation by Entropy Minimization) supplies the adaptation backbone, which we keep unchanged. Two lines of work fight collapse at higher cost, and they constrain how much overhead we can justify. CoTTA (Continual Test-Time Domain Adaptation) uses a teacher network, up to 32 augmentations per step, and stochastic weight restoration. REM (Ranked Entropy Minimization for Continual Test-Time Adaptation) uses masked-view entropy ranking on Vision Transformers and admits it has no account of why ranking prevents collapse. Neither targets label-prior skew directly. Our method adds one gradient-free forward pass and a length-C vector.

On the optimization side, two papers supply the method. The mixture-of-experts EM paper gives the EM-equals-mirror-descent identity and the relative-smoothness argument. SCENT (A Geometry-Aware Efficient Algorithm for Compositional Entropic Risk Minimization) shows that Bregman proximal updates on dual variables tame exponential-family objectives. SCENT, however, keeps one dual variable per training sample and notes this fails for unbounded streams. Our dual object is per class, which is what makes the streaming setting feasible. Bregman-Riesz regression (Learning density ratios in causal inference using Bregman-Riesz regression) estimates density ratios offline for covariate shift. We estimate the label-shift ratio $\pi_t/\pi_s$ online and nonstationarily.

The research file also suggests running mirror descent directly on Tent's parameters, on the grounds that entropy lives on the simplex. We think that idea is misplaced. Batch-normalization scales and shifts are unconstrained real numbers, and the simplex geometry belongs to the predicted distributions, not to the parameters. We test this variant as an ablation rather than build on it.

Research Program

The work has three parts.

The first is analysis. For a stream whose true prior drifts, we will show that the per-batch label-shift log-likelihood is relatively smooth, with constant one, with respect to negative entropy, adapting the mixture-of-experts argument. This justifies $\eta=1$ as the largest stable step. We will then bound the tracking error of the update above as a function of $\eta$, batch size, and drift rate. The expected trade-off is the standard one for constant-step online mirror descent: a noise term growing with $\eta$, from averaging over roughly $1/\eta$ batches, against a lag term growing with drift divided by $\eta$. This predicts an optimal $\eta$ scaling like the square root of drift per batch, which we will test directly. The assumption that the source model is reasonably calibrated under covariate shift is the weak point. We will measure how prior-estimate error grows with corruption severity, and we expect the analysis to hold only up to moderate severity.

The second part is the method itself. It consists of the decoupled prior tracker, the entropy reweighting by $\pi_t/m_t$, and optionally a prior-corrected final prediction using $r_i$ in place of the adapted posterior. The third part is the empirical study described below.

Baselines

The naive reference points are the unadapted source model and test-time batch-norm statistics re-estimation with no gradient steps. Both run on identical streams. The second is the "do nothing clever" option a reviewer would raise first. On IID ImageNet-C, Tent reports 49.9% error for test-time normalization against 44.0% for Tent itself.

Tent is the backbone baseline and the method we must repair. DELTA reports that Tent's accuracy collapses to 6.0% on ImageNet-C under dependent stream plus class imbalance, and reaches 23.7% on CIFAR-100-C under dependent stream with balanced classes.

DELTA is the strongest competitor on exactly this question, because it targets the same non-IID failure with a comparable budget. Its reported numbers are 36.7% accuracy on ImageNet-C under dependent stream plus class imbalance, 64.1% on CIFAR-100-C under dependent stream with balanced classes, and 75.7% on YTBB-sub versus Tent's 51.7%. We will rerun DELTA from its released protocol on the same backbones, stream orderings, and seeds, with the same hyperparameter search budget as our method. We will also build a hybrid that keeps DELTA's batch renormalization and swaps only its reweighting for ours, so that normalization gains are not credited to the prior tracker. Beating DELTA means higher mean accuracy across at least three seeds on all three non-IID settings, with no IID loss larger than seed variance. A tie on accuracy with clearly lower prior-tracking error would count only as a partial result.

For the continual multi-domain setting we include CoTTA, which reports 16.2% CIFAR-10-C error and 32.5% CIFAR-100-C error, and REM, which reports 39.2% ImageNet-C error and 9.4% CIFAR-10-C error. They serve as cost-accuracy reference points, run on their native architectures, with latency and peak memory reported. Matching them is not required, but a practical claim should come out ahead of them per unit of compute.

Two ablations isolate the key ingredient. The first replaces the mirror-descent prior with DELTA-style momentum averaging of the adapted model's predictions. The second keeps mirror descent but feeds it the adapted model's posteriors instead of the frozen source model's. Together these separate "multiplicative likelihood update" from "decoupling from the adapted model." A third ablation runs mirror descent on the batch-norm parameters themselves, to test the obvious geometric idea we argue against.

Why not just…?

Why not just re-estimate batch-norm statistics and skip optimization? DELTA reports that batch statistics fluctuate wildly on correlated streams such as YTBB-sub, because a batch of consecutive frames does not resemble the population. Re-estimation therefore inherits exactly the skew we want to correct. We include it as a baseline, but the evidence predicts it fails in the regime that matters.

Why not just use DELTA's momentum reweighting, which already tracks class frequencies? This is the real threat. An exponential moving average and our geometric blend may behave similarly when the source model is accurate. The difference should appear when the adapted model starts over-predicting a class: momentum on its predictions reinforces that, while a source-driven likelihood estimate does not. The two ablations above settle this. If the momentum-on-source-posteriors variant matches ours, the contribution reduces to decoupling, and we will report it that way.

Why not just add a penalty pushing the adapted model's average prediction toward uniform? Under class imbalance and dependent streams the true local prior is not uniform. A uniform target fights correct predictions on runs of the same class. No reported result was found on Lacuna for such a uniform-marginal penalty on these non-IID benchmarks, so we will implement it with the same budget. We expect it to help on IID-but-shifted streams and to hurt under class imbalance, and the class-imbalance split tests exactly that prediction.

Why not just lower the learning rate or reset weights periodically, as CoTTA does? Smaller steps slow collapse but also slow adaptation. CoTTA's restoration works but carries teacher and augmentation costs. We will sweep Tent's learning rate and add a 1% stochastic-restoration arm under matched compute, and check whether either closes the gap to our method on dependent streams.

Proposed Experiments

All image experiments follow DELTA's non-IID protocols on CIFAR-10-C, CIFAR-100-C, and ImageNet-C at severity 5: IID, dependent stream, class-imbalanced, and dependent stream plus class imbalance. We add YTBB-sub for natural video dependence and the CoTTA continual corruption sequence for nonstationary covariate shift.

Beyond accuracy, we report three diagnostics. The first is prior-tracking error, the KL divergence between $\pi_t$ and the true label frequencies in a sliding window; this is measurable because benchmark labels are known. The second is the collapse rate, the fraction of runs in which more than half of predictions fall into one class. The third is per-batch latency and peak memory.

A controlled experiment then injects label-prior drift at chosen rates into CIFAR-100-C streams. It checks whether the accuracy-optimal $\eta$ follows the predicted square-root scaling with drift, and whether $\eta=1$ is stable everywhere as relative smoothness predicts.

Three outcomes would be decisive. The first is that decoupling, with or without the multiplicative update, accounts for most of the gain over DELTA. That would refute the claim that the mirror-descent update itself matters. The second is that the method degrades IID accuracy relative to Tent. That would show the reweighting is not neutral when the prior is stable. The third is that prior-tracking error grows so fast with corruption severity that the source model's posteriors become useless. That would bound where the approach can work, and it would point toward estimating the prior from adapted features with a separate calibration step.