← Blog/blog/tent-confidently-wrong

The test-time learner that can become confidently wrong

A camera model trained on clear daytime images may meet fog, sensor noise, or a new lens after deployment. That mismatch is a distribution shift: the inputs at test time no longer look like the training inputs. Retraining would help, but the original data—and labels for the new stream—may be unavailable.

Tent adapts anyway. It updates only each normalization channel's scale and shift, using the model's own uncertainty as the loss. The bet is simple: on a coherent unlabeled batch, a better alignment should move examples away from an indecisive boundary.

01

Confidence supplies the gradient

For class probabilities p, entropy is H(p) = −Σ p log p. It is largest when the model is undecided and smallest at a one-hot prediction. In the binary case, differentiating through the sigmoid gives the exact logit gradient below.

def entropy_gradient(logit):
    probability = sigmoid(logit)
    if probability == 0 or probability == 1:
        return 0
    return probability * (1 - probability) * log((1 - probability) / probability)

The site runs the tested TypeScript implementation; Python and C++ are faithful translations. Notice what the function never receives: a true label. It knows how to increase certainty, not how to recognize truth.

02

The batch gives confidence a direction

Our deterministic illustration starts with two balanced classes on a one-dimensional feature. Deployment shifts every feature two units to the right. The frozen source boundary now predicts almost everything as class 1. Re-estimating the batch mean and variance recenters the two groups; Tent's affine update then pushes their logits farther from the boundary.

Deterministic illustrative shift, not a paper result. Every value is computed by the tested core. Target-batch normalization fixes the global offset; entropy minimization sharpens the already-correct split.
mean entropy
Mean prediction entropy across 20 tested affine updates on the same illustrative batch. Accuracy is already perfect after recentering; Tent keeps lowering uncertainty.
03

The corruption results were substantial

Paper benchmark (severity 5)MethodError (%)
CIFAR-10-C, Gaussian noiseSource only67.2
CIFAR-10-C, Gaussian noiseTest batch norm25.4
CIFAR-10-C, Gaussian noiseTent20.2
CIFAR-100-C, Gaussian noiseSource only89.9
CIFAR-100-C, Gaussian noiseTest batch norm55.8
CIFAR-100-C, Gaussian noiseTent46.8
ImageNet-C, Gaussian noiseSource only94.2
ImageNet-C, Gaussian noiseTest batch norm88.1
ImageNet-C, Gaussian noiseTent74.3
Selected Gaussian-noise columns from the paper's Table 1. These are paper-reported error rates, not outputs of the illustrative reconstruction.

The gap over test-time batch normalization matters: on severe Gaussian noise, Tent cut ImageNet-C error from 88.1% to 74.3%. Across the full corruption table it won most conditions. For SVHN-to-MNIST adaptation, the widest ResNet's error fell from 16.8% source-only to 8.7% with Tent, using target data but no target labels.

The bill is deployment compute. The paper used batches of 512, Adam at learning rate 0.001, and one target-data epoch. Its simplest schedule needs two inference passes plus one gradient pass per point, rather than ordinary single-pass inference.

04

One point can only applaud itself

Now remove the batch. Our single illustrative point truly belongs to class 0, but the frozen model gives class 1 probability 0.599. Entropy minimization has no counterevidence. After 12 updates, the wrong-class probability is 0.929; entropy fell while accuracy stayed zero.

Illustrative wrong single point, computed by the same core. Lower entropy is not lower error when the initial prediction points the wrong way.
05

What I would probe next

  • Vary batch size and class balance, not only corruption severity.
  • Track accuracy and calibration alongside entropy.
  • Reset the adaptor when the stream changes regime.
  • Measure latency and energy against the unadapted model.

Tent's update flows through an ordinary classifier. Explore those logits on the logistic-regression page, or inspect normalization and gradients on the neural-network page.

References

  1. Dequan Wang, Evan Shelhamer, Shaoteng Liu, Bruno Olshausen, Trevor Darrell (2021). Tent: Fully Test-time Adaptation by Entropy Minimization. ICLR 2021 (Spotlight)