Skip to content
AI & Machine Learning Medium #layernorm#normalization#transformer

Layer Normalization

Normalize per example over the feature axis. Batch-size-agnostic, transformer default.

A free, animated layer normalization you can read here or embed on any website, from Scrollchart.

Layer Normalization

Layer NormalizationNormalize per example across features (rows), not across the batch (columns). Transformer default.f1f2f3f4f5f6f7f8x1x2x3x40.82.41.13.60.32.01.70.91.40.62.81.23.20.41.92.52.11.80.52.71.33.10.72.20.63.01.50.92.41.63.31.0<-- LN normalizes this rowμ=1.75 σ=0.96BN columnμ=2.10 σ=1.10Feature dimension (D)Batch (B)LayerNorm:y = (x − μ_i) / σ_i · γ + βRMSNorm drops the mean: y = x / RMS(x) · γ (LLaMA, Mistral)LN vs BNAxis normalizedLN: features (D)BN: batch (B)Batch size dep.LN: noneBN: yes (B >= 8)Works at B=1LN: yesBN: noRNNs / XformersLN: yesBN: poorCNNs / visionLN: uncommonBN: yesRMSNormDrops mean shift; onlyscales by RMS. Faster,used in LLaMA / Gemma.LayerNorm (row)BatchNorm (column)

A single example normalized across its feature dimension. Compared with BatchNorm side by side: BN normalizes across batch, LN across features. RMSNorm shown as a popular simplification dropping the mean.

Good for

  • Transformer and attention mechanism explainers connecting normalization to training stability
  • Comparison articles contrasting LayerNorm, BatchNorm, GroupNorm, and RMSNorm design choices
  • LLM architecture deep-dives explaining why LLaMA and GPT-4 use RMSNorm over the original LayerNorm

Source & accuracy

This layer normalization is an editorial illustration built to represent the concept accurately. Where it shows figures, they are typical or representative values chosen to make the relationship clear, not a single underlying dataset. The diagram and its explainer are reviewed and maintained centrally, and updated over time as understanding improves.

Normalization across features, not batches

Layer normalization normalizes each example independently over the feature dimension. For a batch of 32 examples with 768 features, layer norm computes the mean and variance of the 768 values within each example and normalizes. This differs from batch norm, which pools statistics across the 32 examples. Layer norm is invariant to batch size: the same example produces the same normalized representation whether you run it alone or with a thousand others. This property makes it ideal for scenarios with variable batch sizes, small batches, or at inference time where batch statistics are meaningless.

Why transformers standardized on layer norm

Transformers use layer norm because it stabilizes training, permits higher learning rates, and is deterministic at inference time (no train-test mismatch like batch norm). The normalization happens after the linear projection, creating a stable distribution for downstream attention and feedforward operations. Empirically, layer norm enables training very deep transformer models (100+ layers) without gradient collapse. Batch norm was tried in early transformer experiments and underperformed. Layer norm became the de facto standard for transformer architectures and has since been adopted in other modern networks. Some variants (like root mean square layer norm in recent models) simplify the computation further while maintaining the same benefits.

Embed this diagram

Add this animated layer normalization to your own site. Copy one line of HTML, or use the embed builder for theme and sizing options.

Reference

What this is
A free, embeddable, animated layer normalization for any website.
Who uses it
AI/ML blogs, CS educators.
How to embed
Copy one line of HTML. No signup. No watermark. Works in WordPress, Webflow, Ghost, Substack, plain HTML.
File size
iframe embed, ~80 KB gzipped (loads on demand, does not block your page paint).
License
Free forever. Editorial explainer text included; updated centrally over time.

Embed format options

Copy the universal HTML snippet, the WordPress shortcode, or an iframe fallback - see the WordPress plugin page for details. Any format keeps the same Core Web Vitals profile and the same explainer text.

Embed snippet
<div data-scrollchart="layer-norm" data-scrollchart-v="1"></div>
<script src="https://scrollchart.com/embed.js" async></script>

Frequently asked questions

Where can I get a free animated "Layer Normalization" for my website?
Scrollchart provides "Layer Normalization" as a free, embeddable animated diagram you can add to any website with one line of HTML. No signup is required and there is no watermark. The diagram and its explainer text are served from scrollchart.com, so the embed stays current without any maintenance on your end.
How do I embed a layer normalization in a developer or tech blog?
Copy the one-line snippet from the Scrollchart diagram page and paste it into your post HTML. It works in any static site generator, CMS, or hand-coded HTML page. The embed is a thin loader, not an iframe, so the content is fully in your DOM.