When an image classifier meets corrupted or restyled inputs at deployment, a popular fix is test-time adaptation: the model nudges a few of its own parameters on the unlabeled test stream, usually by making its predictions more confident. This works until the model becomes confidently wrong. Its errors then reinforce themselves, and in long deployments accuracy can collapse toward zero. Current safeguards anchor each class to a single reference point, such as a class centroid or a classifier weight vector, and pull adapted features toward it. A class, however, is not a point. The features of "dog" vary along a handful of directions (pose, breed, scale). Our proposal represents each class by the small linear subspace those features span, computed once from the source training data. During adaptation we ask a simple question of every test feature: how much of its energy lies inside the subspace of the class it is assigned to, and how much lies outside every class subspace?
The core idea fits in two sentences. Energy that falls outside all source class subspaces is a measure of semantic drift that does not depend on the model's own confidence, so it should spot "confident but wrong" samples that entropy misses. We use this residual both to choose which test samples are trusted during adaptation and as a consistency penalty that pulls adapted features back into their class's low-dimensional semantic span. The work is valuable if subspaces beat points: if a rank-$k$ class model catches failure modes and prevents collapse in ways that a centroid or a full covariance estimate does not, at negligible cost.
Core Claim
Fix a frozen source feature extractor and compute, for each class $c$, an orthonormal basis $U_c \in \mathbb{R}^{d \times k_c}$ for the top $k_c$ principal directions of that class's penultimate-layer features. Here $d$ is the feature dimension and $k_c$ is chosen so that the basis explains a fixed fraction of within-class variance. For a test feature $z$ produced by the model being adapted, the semantic residual is
$$ \rho(z) = 1 - \max_c \frac{\lVert U_c^\top z \rVert^2}{\lVert z \rVert^2}, $$
which is the fraction of the feature's energy that no class subspace explains. The class achieving the maximum is the subspace assignment $\hat c(z)$. The adaptation objective updates only the normalization-layer affine parameters, as in Tent:
$$ \mathcal{L} = \frac{1}{|B|}\sum_{x \in B} w(x)\, H\big(p(x)\big) \;+\; \lambda\, \rho\big(z(x)\big) \;-\; \mu\, H\big(\bar p_B\big). $$
In this objective, $B$ is the current test batch, $H(p(x))$ is the entropy of the model's prediction, and $w(x) = \mathbb{1}[\rho(z(x)) < \tau]$ keeps only samples whose features sit close to some class subspace. $\lambda$ weights the subspace-consistency penalty. The last term rewards a diverse batch-average prediction $\bar p_B$, weighted by $\mu$, so that the model cannot satisfy the residual penalty by sending every feature into one class's subspace. We make two testable claims. First, on a frozen source model under corruption, $\rho$ flags misclassified samples better than entropy does, especially among confident ones. Second, rank $k_c > 1$ class subspaces stabilize long-horizon adaptation better than rank-1 anchors under an identical training loop.
The three research directions play different roles here. Latent semantic dimensionality reduction supplies the mechanism: the low-rank class bases. The semantic consistency constraint is the form the mechanism takes: staying inside one's class span. Domain shift is the regime: continual corruption streams and style shifts.
Why This Is Not Already Done
The closest work splits into two groups, and neither combines what we combine. The first group anchors semantics to points. T3A replaces classifier weights with centroids of confident target features, and its authors note that averages ignore distribution geometry. DPL decouples class updates through a prototype contrastive loss and a momentum memory of centroids. STAG aligns entropy gradients with anchors derived from classifier weight vectors. ProtoTTA minimizes entropy over prototype activations, but only in architectures built with prototype layers. All four motivate this proposal, since they show that class-grounded anchors reduce semantic drift. All four use one vector per class.
The second group uses low-rank structure without class semantics. LCoTTA projects test-time gradients onto a subspace tracked from recent gradients. It finds that trustworthy gradients concentrate in about ten principal components on ImageNet-C. Its subspace, however, is learned from the same unsupervised gradients that early errors can pollute. PACE searches a random low-dimensional parameter subspace without backpropagation. TTAwPCA filters first-layer activations on a clean PCA basis and drifts over long runs. These papers supply method: low-rank structure is real and cheap to exploit at test time. None of them ties the subspace to class identity.
The subspace representation itself comes from Representing Sentences as Low-Rank Subspaces. That work found sentence semantics in rank-3 to rank-5 subspaces and compared them by principal angles, but only for static text similarity with no shift. The idea of scrubbing a concept by singular directions comes from Li et al., who worked in text-to-image generation rather than robustness. Our contribution is to move class-level subspaces into the test-time loop, as both a reliability signal and a constraint.
One assumption must be stated plainly. The method stores a small source summary, $k_c \times d$ numbers per class: roughly 1000 × 8 × 2048 floats for a ResNet-50 on ImageNet. This is a stronger assumption than fully source-free Tent, and comparable to methods that keep source normalization statistics. We report it as a cost and do not hide it.
Research Program
The first stage is a measurement study that needs no adaptation. For ResNet-50 and ViT-Base on ImageNet and CIFAR-100, we compute per-class principal components of penultimate features and report how many directions reach 70% and 90% of within-class variance. Mu et al.'s rank 3–5 is for word vectors, and vision features may need more. On a frozen source model evaluated on all ImageNet-C corruptions at severity 5, we then compare four scores by misclassification-detection AUROC: $\rho$, prediction entropy, rank-1 cosine-to-centroid, and the idempotence error that IT$^3$ reports correlating with accuracy at $r=-0.94$. We compute this AUROC overall and specifically within the most confident 30% of predictions. That subset is where the entropy-deceptive samples described by LCoTTA live, and it is where $\rho$ must win for the idea to matter.
The second stage is the adaptation method itself. It reuses Tent's parameterization and adds the residual filter and penalty above, at the cost of one batched projection per step. We also build a dense-prediction variant for GTA5→Cityscapes. That variant uses per-class subspaces of pixel features from the segmentation head and computes the residual per pixel, which T3A-style centroid methods cannot easily support.
The third stage is analysis. We track, over many cycles of a continual stream, the mean principal angle between subspaces re-estimated from target features with confident pseudo-labels and the source subspaces. The aim is to show directly whether drift in class geometry predicts the collapse LCoTTA observes, and whether our penalty delays it.
Baselines
The naive reference is the unadapted source model, together with test-time BatchNorm recalibration as in DUA. DUA reports CIFAR-10-C severity-5 error falling from 49.2% to 26.8%. Tent reports 49.9% error for test-time normalization on ImageNet-C. Any method that cannot beat recalibration does not justify gradient steps.
The primary gradient baseline is Tent, which reports 44.0% ImageNet-C error. Our method is Tent plus two terms, so Tent run on the identical parameter set, learning rate grid, and batch schedule isolates exactly what the subspace terms add.
The strongest existing competitor for the semantic-anchor question is STAG. In the file it is the best-documented anchor method, reporting ViT-Base ImageNet-C accuracy rising from 48.0% (Tent) to 59.2% (Tent+STAG) with 0.2% time overhead. Beating it means exceeding its accuracy in our own reproduction on the same ViT-Base checkpoint and stream, and doing so in both the standard and the B=1 regimes, since STAG's B=1 gains are a highlighted strength. We also include DPL, which reports 64.7% ImageNet-C error against an 82.0% source baseline in its own protocol. On domain generalization, DPL reports a 73.3% four-benchmark average and T3A reports 80.0% on VLCS. We use these as reported reference points, but rank methods only by our reruns. For continual stability the competitor is LCoTTA; no reported final accuracy found on Lacuna for LCoTTA, so we rely on reproduction and on its qualitative claim that baselines collapse toward 0% within early cycles.
Every method receives the same backbone checkpoints, test streams and orderings, batch sizes, and number of updated parameters where applicable. Each also gets an equal hyperparameter budget: a fixed number of grid points tuned on a held-out corruption subset, following the common practice of using ImageNet-C's extra noise corruptions for validation, never the test corruptions.
Three ablations isolate the key ingredient. Setting $k_c=1$ turns the class model into a centroid direction. Replacing class subspaces with random orthonormal bases of the same rank tests whether any low-rank projection helps. Replacing them with one global PCA subspace of total rank $\sum_c k_c$ tests whether class structure matters or merely global low-rankness, which would bring us close to a deep-layer TTAwPCA. We also run the filter alone and the penalty alone.
Why not just…?
Why not just use class centroids, as T3A and DPL do? This is the comparison the proposal lives or dies on, and the $k_c=1$ ablation settles it under identical code. The case for rank above one is that a feature can be far from a centroid yet well inside its class's span. A rotated or rescaled dog is still a dog, and a centroid treats it as drift. T3A's own authors flag that centroids ignore class geometry. If rank 1 matches rank $k$ on both the AUROC study and continual accuracy, we will report that the extra rank is unnecessary and drop the subspace claim.
Why not just fit a full class-conditional Gaussian and use Mahalanobis distance? This is a real threat, because a Gaussian captures everything a subspace does plus per-direction scale. In 768 or 2048 dimensions, with roughly 1300 source images per class, full covariances are poorly conditioned. Estimating them from target features during adaptation is hopeless at small batch sizes. We therefore include a shrinkage-regularized Mahalanobis residual as a baseline with the same storage budget. If it matches our method, the honest conclusion is that low-rank class geometry is what helps, whichever form it takes, and we would adopt the simpler of the two.
Why not just filter gradients through a tracked subspace, as LCoTTA does, or align them with classifier weights, as STAG does? Both protect the update direction. Neither checks whether individual features remain semantically placed. LCoTTA's subspace is estimated from the very gradients that corrupted pseudo-labels produce, and STAG's anchors are single weight vectors. Our anchors are fixed by clean source data and are class-structured. The continual multi-cycle stream is where this difference should appear. The methods are also not exclusive, so we test our loss with LCoTTA's projection added to see whether the gains stack.
Why not just recalibrate normalization statistics? Recalibration is cheap and strong on CIFAR-10-C. On ImageNet-C, however, Tent's numbers show that gradient adaptation beats test-time normalization (44.0% against 49.9% error). Recalibration also cannot separate overlapping class clusters. It remains the floor every result is reported against.
Proposed Experiments
The main benchmarks are ImageNet-C and CIFAR-100-C at severity 5, run in three settings. The first is standard per-corruption adaptation. The second is a continual stream through all 15 corruptions repeated for ten cycles without resets, following the lifelong setting where LCoTTA reports collapse. The third is single-sample (B=1) streams on ResNet-50 with GroupNorm and on ViT-Base, following STAG. Style shift is tested on ImageNet-R and on PACS and OfficeHome, using the domain-generalization protocol shared with T3A and DPL. Dense prediction is tested on GTA5→Cityscapes, where Tent reports mIoU rising from 28.8% to 35.8%. We report top-1 error or accuracy (mIoU for segmentation), accuracy at the last cycle of the continual stream, the cycle at which accuracy first drops below the source model, and wall-clock overhead per batch.
The first decisive check comes before any adaptation. On frozen source models, $\rho$ must beat entropy in misclassification AUROC within the most confident predictions. If it does not, the reliability half of the method has no basis, and we narrow the claim to the penalty alone.
The second decisive check is the rank ablation on the continual stream. Full-rank class subspaces must delay or prevent collapse relative to $k_c=1$, random bases, and the global PCA basis, under matched tuning. They must also match or exceed shrunk Mahalanobis.
The third check is the geometry analysis. If the measured principal-angle drift between target and source class subspaces rises before accuracy collapses, and our penalty flattens that curve, then we have shown the mechanism and not only a score.
Success means accuracy higher than our STAG reproduction on ViT-Base ImageNet-C, no collapse over ten continual cycles where Tent collapses, and overhead small enough (one projection per sample) to remain deployable.
References
- Tent: Fully Test-Time Adaptation by Entropy Minimization
- Test-Time Classifier Adjustment Module for Model-Agnostic Domain Generalization
- Decoupled Prototype Learning for Reliable Test-Time Adaptation
- Gradient Alignment with Prototype Feature for Fully Test-time Adaptation
- ProtoTTA: Prototype-Guided Test-Time Adaptation
- Lifelong Test-Time Adaptation via Online Learning in Tracked Low-Dimensional Subspace
- Subspace Optimization for Backpropagation-Free Continual Test-Time Adaptation
- Test-Time Adaptation with Principal Component Analysis
- Representing Sentences as Low-Rank Subspaces
- Get What You Want, Not What You Don't: Image Content Suppression for Text-to-Image Diffusion Models
- IT3: Idempotent Test-Time Training
- The Norm Must Go On: Dynamic Unsupervised Domain Adaptation by Normalization