Perceptually Weighted Gain in Layer Normalization

Vision Transformers (image models that split a picture into patches and process them as a sequence of tokens) use layer normalization. This operation rescales each token by the total spread of its own feature channels. That makes it a crude version of the divisive normalization neurons perform in visual cortex, where a cell's response is divided by the pooled activity of its neighbors. The crude version differs from the biological one in two ways. Biological pooling is tuned to the frequencies the eye actually sees well, and it includes a "semi-saturation" constant that stops weak, noisy inputs from being amplified. Layer normalization pools every channel equally and has essentially no such constant. We hypothesize that this is a specific way Transformers break under corruption. When noise, JPEG artifacts, or pixelation add energy to channels tuned to fine, barely visible detail, that energy inflates the shared denominator. The result is that the meaningful mid-frequency signal in every token gets turned down.

The proposal is to fix this after training, with no data and no gradients. We probe a frozen Transformer with sinusoidal gratings, as in human psychophysics, to measure which channels respond to perceptually important frequencies. We then recompute each layer normalization's denominator from a weighted pool that down-weights the channels tuned to imperceptible frequencies. The weights are fixed per model and need no test batch, so the method works one image at a time and on correlated streams. Those are the settings where adaptation based on batch statistics fails. The mechanism also makes a falsifiable prediction about which normalization layers are affected. Batch normalization normalizes each channel separately, so it has no shared cross-channel denominator to contaminate, and the fix should help Transformers but do nothing for CNNs that use batch normalization.

Core Claim

The claim has two parts. The first is diagnostic. Under high-frequency corruptions, a disproportionate share of the layer-normalization denominator in a Vision Transformer comes from channels whose grating tuning lies above the frequencies humans see best. This "denominator contamination" accounts for a measurable part of the accuracy drop.

The second is constructive. Replacing the uniform pool with a perceptually weighted pool recovers part of that drop at batch size one, and it stacks with existing test-time adaptation methods. The modified normalization for token features $x \in \mathbb{R}^D$ with mean $\mu$ is

$$ y_c = \gamma_c \frac{x_c - \mu}{\sqrt{k \sum_{j} w_j (x_j - \mu)^2 / \sum_j w_j + \sigma^2}} + \beta_c, $$

The symbols are defined as follows:

  • $w_j \ge 0$ is a fixed perceptual weight for channel $j$, taken from grating responses.
  • $k$ is a per-layer scalar chosen so that the new denominator equals the original one on synthetic natural-statistics images, which keeps clean behavior intact.
  • $\sigma$ is a per-layer semi-saturation constant, calibrated the same way.
  • $\gamma_c$ and $\beta_c$ are the unchanged learned affine parameters.

The numerator is left alone. Every channel still carries its information, and only the gain is set by perceptually relevant energy. This is what separates the method from simply blurring the input.

Relation to Prior Work

Four lines of HVS work motivate the method or supply its pieces:

  • Gratings and channel ranking. Tariq et al. used sinusoidal gratings to rank CNN channels by "perceptual efficacy." The highest-ranked channels peak at frequencies where human sensitivity is highest and favor luminance edges. They used this ranking only to read out quality scores from frozen AlexNet and VGG. We reuse their probe on Transformers and put the ranking inside the normalization itself.
  • Bandwidth and robustness. Bayazi et al. found that networks use frequency channels two to four times wider than the roughly one-octave human channel. Narrower bandwidth predicts out-of-distribution robustness ($r = -0.43$) far better than shape bias. They treat models as black boxes and estimate that scaling alone would need about 31 billion parameters to reach human bandwidth. We test whether a single change to the gain pathway narrows bandwidth in a fixed model.
  • Early filtering. Venkataramanan et al. and Xue et al. showed that filtering imperceptible frequencies early keeps quality metrics from overreacting to fine-scale perturbations. That is the principle we transfer from metrics to activations.
  • Learned divisive normalization. Veerabadran et al. trained a learnable cortical divisive normalization layer into VGG-9 and gained 1.8 points on ImageNet-100. That requires retraining and has never touched Transformers or distribution shift. Our version is post hoc and works on Transformers.

Work on normalization dependency both motivates and constrains the design:

  • Batch-statistics adaptation. DUA shows that recalibrating batch-normalization statistics alone gives large gains, for example CIFAR-10-C severity-5 error falling from 49.2% to 26.8%. Such statistics do not exist in layer-normalized models.
  • The non-i.i.d. constraint. NOTE shows that batch recalibration collapses on temporally correlated streams, with TENT reaching 76.4% error. This constrains us toward a fixed, batch-free mechanism.
  • Transformer-specific adaptation. CFA matches stored source moments, NEO re-centers the final embedding, and FOA searches input prompts and activation shifts without gradients. All three work on uniform representations and need either source statistics, a test stream, or evolutionary search. Ours needs none of these and acts at every layer, so it is complementary rather than a replacement.
  • Learned input normalization. ALCN showed that learned, adaptive contrast normalization beats fixed difference-of-Gaussians filtering on illumination shifts. It operates only on the input image of CNNs.

Research Program

Phase 1: diagnosis. We take ImageNet-1k Vision Transformers (ViT-B/16, DeiT-S, and a Swin-T for a hierarchical comparison) and run Tariq-style grating sweeps. Frequencies run from 1 to 8 cycles per patch, across orientations, and in both luminance and color-opponent versions. This yields a tuning curve per channel per layer.

We then decompose each layer-normalization denominator into contributions from channel groups binned by peak frequency, on clean versus ImageNet-C images. The prediction is that noise, pixelate, and JPEG corruptions raise the high-frequency-group share far more than blur, fog, or contrast corruptions do. We correlate that share with per-corruption accuracy loss.

As the dependency control, we run the same analysis on BN ResNet-50, computing per-channel batch statistics. The prediction is that there is no comparable cross-channel coupling to contaminate.

Phase 2: weights and calibration. We set $w_j$ by a smooth function of each channel's grating peak: a contrast-sensitivity-shaped profile, low for channels tuned above the mid band. Luminance and chromatic weighting are kept as separate factors so they can be ablated. We calibrate $k$ and $\sigma$ per layer on synthetic $1/f$-spectrum noise images. Because these are data-free, the method uses no source data.

Phase 3: evaluation. We evaluate standalone and combined with NEO, CFA, and FOA. We also measure Bayazi-style bandwidth before and after, to test whether the gain change narrows the effective frequency channel. A secondary study fine-tunes with the weighted normalization in place, to separate the post-hoc effect from what training would do.

Baselines

Unmodified source model (the do-nothing reference). The same frozen checkpoint is evaluated at batch size one. For ViT-Base on ImageNet-C, NEO reports 55.6% top-1 for the source model (NEO). We rerun our own checkpoint rather than borrow this figure.

NEO, the strongest forward-only competitor. NEO re-centers test embeddings by their running mean. It is forward-only, cheap, and Transformer-native, which makes it the method we most need to beat or complement. It reports 59.2% top-1 on ImageNet-C with ViT-Base after 64 samples (NEO). We run it on the identical checkpoint, corruption order, and severity-5 stream. Our method beats it if it exceeds NEO at batch size one, where NEO has no running mean to work with, and if the combination exceeds NEO alone at 64 samples.

CFA and FOA, the higher-cost competitors. CFA reports 19.8% error with BEiT-L/16 (CFA). FOA reports 63.5% with an 8-bit ViT against 59.6% for full-precision TENT (FOA). These use source statistics or populations of forward passes. We run them with their published hyperparameters and report accuracy against forward passes and memory. We claim complementarity if adding our normalization raises their accuracy at no extra cost; we do not claim to beat them outright.

TENT on layer-normalization affine parameters. We run it with a small learning-rate sweep, giving every method the same tuning budget on a held-out corruption.

Ablations isolating the key ingredient. Each keeps the identical calibration procedure and changes only the weights:

  • uniform weights with only $\sigma$, which tests whether semi-saturation alone suffices;
  • random weights with the same sparsity;
  • inverted weights that emphasize high-frequency channels;
  • weights computed from the test stream by per-channel variance shift, a data-driven alternative.

Why not just…?

Why not just low-pass or CSF-filter the input image? This is the most serious threat for noise corruptions, and we run it directly with matched cutoffs. The evidence that fixed input filtering underperforms is indirect. CLAHE moved ResNet-50 mCE only from 76.7 to 74.5 (Hendrycks and Dietterich), and fixed difference-of-Gaussians reached 0.611 AUC against ALCN's 0.787 (ALCN). Our specific argument is different. Prefiltering deletes fine detail from the numerator, so it should cost clean accuracy and fail on blur. Our method only changes the gain. If prefiltering matches us on clean accuracy and on all four corruption families, the gain-pathway story is wrong, and we will say so.

Why not just select channels from the test data instead of from gratings? NEO already observes that shift concentrates in a few embedding dimensions, so a data-driven choice of channels is plausible. We include it as an ablation. Its structural weakness is that it needs a batch, and NOTE shows batch-derived statistics break on correlated streams. If data-driven weights win at large i.i.d. batches but lose at batch size one and on correlated streams, that defines exactly where the perceptual prior earns its place.

Why not just scale the model, or train with augmentation? Bayazi et al. extrapolate about 31 billion parameters to reach human bandwidth. COLORSENSE finds that scaling and robustness augmentation shrink the low-contrast gap by at most 0.58%. We still test the method on larger checkpoints. If it adds nothing to ViT-L or BEiT-L, its value is limited to compact models, which is still the regime where edge deployment matters.

Proposed Experiments and Decisive Checks

Main benchmark. ImageNet-C at all 15 corruptions and 5 severities, reporting top-1 accuracy and mCE. We compare batch size one with 64-sample streams, and i.i.d. order with a temporally correlated order constructed as in NOTE.

Secondary benchmarks. CIFAR-10-C with a ViT trained on CIFAR-10, ImageNet-P flip probability for stability, and COLORSENSE-C for the easy-versus-hard contrast gap. For COLORSENSE we found no reported result on Lacuna for a ViT gap specifically. The file gives 3.12% average and 6.59% for land vehicles on ResNet-50, and we will measure the ViT gap ourselves.

Decisive check 1: corruption-family selectivity. Gains should concentrate on noise and digital corruptions, which are high-frequency, and be near zero on fog and contrast. Uniform gains across all corruptions would suggest generic regularization rather than the proposed mechanism.

Decisive check 2: normalization dependency. Applying the analogous weighting to BN ResNet-50 should yield roughly nothing. A large gain there would falsify the claim that the effect is specific to the cross-channel denominator.

Decisive check 3: bandwidth. The Bayazi bandwidth of the modified model should narrow toward one octave. Its change across corruptions should track the accuracy change.

Exploratory check: chromatic weighting. On COLORSENSE HARD images, down-weighting chromatic channels in the gain could either preserve luminance contrast or suppress the color cues those images depend on. Either outcome tells us whether layer normalization's flattening of luminance and chromatic channels is part of the low-contrast failure.