Home Knowledge Base Batch normalization normalizes each feature across the batch dimension.

Normalization layers are the quiet workhorses that make deep networks trainable at all. Left alone, the activations flowing through a deep stack drift in scale and distribution from layer to layer, so gradients explode or vanish and the optimizer stalls. A normalization layer re-centers and re-scales those activations back to a well-behaved range at every step, which smooths the loss landscape, lets you use a much higher learning rate, and makes training far less sensitive to weight initialization. The whole transformer era rests on getting this one detail right.\n\nBatch normalization normalizes each feature across the batch dimension. For a given channel it computes the mean and variance over all the examples in the mini-batch, standardizes, then applies a learnable scale and shift. It was the breakthrough that made very deep CNNs trainable, but it has two awkward properties: it needs a reasonably large batch to estimate stable statistics, and it behaves differently at training time (batch statistics) than at inference (running averages), which makes it a poor fit for sequence models and small-batch or variable-length workloads.\n\nLayer normalization normalizes across the feature dimension instead, one token at a time. Because it computes statistics within a single example, it is completely independent of batch size and behaves identically in training and inference. That batch-independence is exactly what recurrent and Transformer architectures need, which is why LayerNorm — not BatchNorm — is the default inside every attention block.\n\nRMSNorm strips LayerNorm down to just the scaling term. It drops the mean-subtraction step and rescales purely by the root-mean-square of the activations, with a single learnable gain and no bias. It costs less compute and memory while matching LayerNorm's quality in practice, which is why modern large models such as the LLaMA family and many others adopt it as the default. GroupNorm sits between BatchNorm and LayerNorm by normalizing over groups of channels, and is common in vision models where batches are small.\n\nWhere you place the normalization matters as much as which one you pick. The original Transformer used post-norm (normalize after the residual add), which is expressive but needs careful learning-rate warmup and can be unstable at depth. Nearly every modern large model instead uses pre-norm (normalize inside the residual branch, before each sublayer), which keeps a clean gradient path through the residual stream and trains stably to hundreds of layers. The learnable gain and bias parameters mean a normalization layer can always undo its own normalization if the network needs to, so it never costs the model representational power.\n\n| Norm | Reduces over | Batch-dependent? | Train == inference? | Typical home |\n|---|---|---|---|---|\n| BatchNorm | Batch (per channel) | Yes | No (running stats) | CNNs, large batches |\n| LayerNorm | Features (per token) | No | Yes | Transformers, RNNs |\n| RMSNorm | Features, no mean | No | Yes | Modern LLMs (LLaMA-style) |\n| GroupNorm | Channel groups | No | Yes | Vision, small batches |\n\n``svg\n\n \n Normalization — Same Recipe, Different Slice\n every norm re-centers & re-scales activations to keep them well-behaved; they differ only in which slice they average over\n\n \n grid = one activation tensor: features (C) across →, batch samples (N) down ↓\n\n \n BatchNorm\n \n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n \n \n N\n μ,σ over the batch,\n per feature (a column)\n\n \n LayerNorm\n \n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n μ,σ over the features,\n per sample (a row)\n\n \n RMSNorm\n \n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n same row as LayerNorm,\n but scale only — no mean\n\n \n \n The shared recipe\n \n raw x\n shifted, wide\n \n subtract μ\n (center)\n \n divide √(σ²+ε)\n (unit scale)\n \n ×γ + β (learnable)\n restore useful range\n \n ŷ = γ·(x−μ)/σ + β\n\n \n \n \n BatchNorm\n great for CNNs, but it ties each\n sample to its batch-mates. Needs\n running stats for inference and\n breaks with tiny batches or\n variable-length sequences.\n\n \n LayerNorm\n normalizes each token on its own,\n so it's batch-independent and\n identical at train and test time.\n That's why transformers put it\n before each block (pre-norm).\n\n \n RMSNorm\n drops the mean-subtraction and\n the β bias — just divides by the\n root-mean-square and scales by γ.\n Fewer ops, same stability; the\n default in LLaMA-era LLMs.\n\n``\n\nThe temptation is to think of normalization as a preprocessing nicety — something you sprinkle in because a paper did. It is better read as optimization infrastructure: the layer that keeps the activation distribution conditioned so the optimizer sees a smooth, well-scaled loss surface at every depth. Which variant you reach for, and where you place it, is a statement about how you want gradients to flow. Read normalization through a conditioning-the-optimization lens rather than a fixing-covariate-shift lens, and the choice between BatchNorm, LayerNorm, and RMSNorm — and between pre-norm and post-norm — stops being folklore and becomes a direct consequence of your batch structure and your network depth.

batch normalizationbatchnormbatch normlayer normalizationnormalization technique

Explore 500+ Semiconductor & AI Topics

From EUV lithography to CUDA optimization — search the full knowledge base or chat with our AI assistant.