Foundations to Frontier
Tests
E. Deep Learning › E5 Normalization Layers (one page each)

Group Normalization

Group normalisation splits each example's channels into groups and standardises each group over its channels and spatial positions. Like LayerNorm it needs no batch statistics, so it works at any batch size, and with one group it is LayerNorm while with one channel per group it is InstanceNorm. It was designed for convolutional networks trained with tiny batches, such as detection and segmentation, where BatchNorm fails. This page covers the computation, the choice of group count, and how it relates to the other normalisations. In the exercises you show its special cases and batch independence, then compare it in a deep MLP and find, honestly, that with only 8 units per group it was no better than BatchNorm at batch size 2, while LayerNorm was clearly better.

Level 0: Foundation

★☆☆☆☆ Introductory⏱ 5 minGeneral audience. No mathematics required.

Normalise groups of channels within each example

GroupNorm takes the channels of one example, splits them into groups (say 32 groups of 8), and standardises each group using all its values across the image. No other example is involved, so it does not care about batch size. It sits between LayerNorm (all channels in one group) and InstanceNorm (each channel its own group).

Normalisation layers: which values share a mean and variance?
channels →ex 1ex 2ex 3ex 4ex 5ex 6
Click a cell. Highlighted cells (16 values each) are pooled to compute the mean and variance used to normalise it.
per-example mean / sd after normalising0.00/1.00 -0.00/1.00 0.00/1.00 -0.00/1.00 0.00/1.00 -0.00/1.00
per-channel mean / sd after normalising0.58/0.28 0.53/0.78 -0.04/1.23 -1.06/0.25 -1.02/0.64 -0.27/0.97 0.52/0.23 0.77/0.79
BatchNorm noise: with batch size 6, a channel's batch mean is off from its population mean by 0.288 on average.
BatchNorm makes every channel have mean 0 and sd 1 across the batch, but each example's own statistics still vary, and its statistics depend on which other examples are in the batch: shrink N to 1 or 2 and watch the noise grow. LayerNorm, InstanceNorm and GroupNorm compute everything within one example, so they work the same at any batch size and at test time; they differ in which channels they pool.
Why engineers care

Object detectors, segmentation networks and 3-D or video models are often trained with only 1–2 images per GPU because each image is huge. BatchNorm breaks down there; GroupNorm is the standard replacement and appears in Mask R-CNN variants, many diffusion-model U-Nets and medical-imaging networks.

📝 Quick check (Level 0)
0/3 answered
  1. 1. GroupNorm statistics come from…
  2. 2. GroupNorm with one group is…
  3. 3. GroupNorm was designed for…

Level 1: Beginner

★★☆☆☆ Basic⏱ 20 minSecondary-school mathematics: arithmetic and elementary algebra.

By hand

  • Groups: C channels in G groups of C/G. Channel c belongs to group ⌊c/(C/G)⌋; with C = 64, G = 32, channel 5 is in group 2.
  • Statistics: for each example and group, mean and variance over C/G channels × H × W positions. For 64 channels of 56 × 56 with 32 groups, each group has 2 × 3136 = 6272 values.
  • Example: an example with channels (1, 3, 10, 30) and G = 2 gives groups (1, 3) and (10, 30), each normalised to (−1, 1).
  • Special cases: G = 1 is LayerNorm over (C, H, W); G = C is InstanceNorm.
  • Parameters: per-channel γ and β, 2C in all (512 for C = 256).
  • Default: G = 32 (Wu and He found results insensitive between about 8 and 64 groups).
📝 Quick check (Level 1)
0/3 answered
  1. 1. Group of channel 5 with C = 64, G = 32:
  2. 2. Values per group for 64 × 56 × 56, G = 32:
  3. 3. GN with G = C is…

Level 2: Intermediate

★★★☆☆ Intermediate⏱ 25 minUndergraduate students and practising engineers.

GroupNorm in code

Exercise 1.

  • GroupNorm with one group equalled LayerNorm over (C, H, W), and with eight groups of one channel it equalled InstanceNorm.
  • Every group of every example had mean 0 and standard deviation 1.
  • One example’s output was unchanged when the other example was replaced by large random values.

Practice.

  • nn.GroupNorm(32, C); C must be divisible by G.
  • Use it in place of BatchNorm when per-device batches are tiny; the same learning-rate schedule usually works.
  • It is common in diffusion U-Nets and in detection heads; weight standardisation (normalising conv weights) is often paired with it.
block = torch.nn.Sequential(torch.nn.Conv2d(64, 128, 3, padding=1, bias=False), torch.nn.GroupNorm(32, 128), torch.nn.ReLU())
🐍 Exercise 1: GroupNorm and its special cases
Implement GroupNorm and check that it reduces to LayerNorm and InstanceNorm and is independent of the rest of the batch.
📝 Quick check (Level 2)
0/3 answered
  1. 1. nn.GroupNorm requires C to be…
  2. 2. GroupNorm is often paired with…
  3. 3. A common default number of groups is…

Level 3: Advanced

★★★★☆ Advanced⏱ 25 minGraduate level, with full derivations and proofs.

Theory

Why groups. Wu and He argued that channels are not independent: related features (for example, edge detectors at different orientations, or the outputs of one filter bank) form natural groups whose statistics should be normalised together. LayerNorm treats all channels as one group, which can let a few dominant channels set the scale for everything; InstanceNorm treats each channel alone, losing information about relative channel strength. Groups are a compromise.

Batch independence. Like LayerNorm, it computes everything within an example, so there are no running statistics and no train–test discrepancy.

Statistic quality. A group’s mean and variance are estimated from (C/G)·H·W values. In a convolutional layer that is thousands of values, so the estimates are stable. In a fully connected layer it is only C/G values, which can make the estimates noisy and the normalisation erratic, which is a likely reason for exercise 2’s result.

Results. On ImageNet with ResNet-50 at batch size 2 per GPU, Wu and He reported 24.1% error for GroupNorm against 34.7% for BatchNorm, while at batch 32 the two were within 0.5%.

📝 Quick check (Level 3)
0/3 answered
  1. 1. GroupNorm's motivation is that channels…
  2. 2. A group's statistics in a conv layer come from…
  3. 3. ResNet-50 at batch 2 per GPU: GN vs BN error:

Level 4: Expert

★★★★★ Expert⏱ 25 minResearchers: original papers and open problems.

GroupNorm in a deep MLP

History.

  • Y. Wu and K. He (2018) introduced GroupNorm.
  • S. Qiao et al. (2019) introduced weight standardisation, often paired with GroupNorm.
  • J. Ho, A. Jain and P. Abbeel (2020) used GroupNorm in diffusion-model U-Nets.

Exercise 2. The 8-layer ReLU MLP of E5-1 (width 32): GroupNorm uses 4 groups of 8 units. Mean test accuracy of three seeds:

normalisation batch 2, η = 0.01 batch 32, η = 0.03
none 0.709 0.999
BatchNorm 0.399 0.999
LayerNorm 0.612 0.993
GroupNorm (4 × 8) 0.421 0.949
  • With batches of 2, BatchNorm collapsed and LayerNorm was much better, as expected from batch independence.
  • GroupNorm was no better than BatchNorm here, and the weakest at batch 32. Each group’s statistics come from only 8 numbers in an MLP, which likely makes its normalisation noisy (not tested directly here).
  • The plain network was best at batch 2: this small network did not need normalisation at a small learning rate.
  • Lesson: GroupNorm’s advantage depends on having many values per group, as in convolutional layers; it does not transfer to small fully connected layers.
🐍 Exercise 2 (research): GroupNorm in a deep MLP
Train a deep MLP with no normalisation, BatchNorm, LayerNorm and GroupNorm at batch sizes 2 and 32, and compare test accuracy.

GroupNorm in AI, robotics and aerospace

  • Detection and segmentation for autonomous vehicles and drones, trained with large images and tiny batches.
  • Diffusion models for image generation and data synthesis use GroupNorm in their U-Nets.
  • 3-D and video perception (lidar, volumetric medical or inspection data) where memory allows only a few samples per device.

References

  1. Y. Wu, K. He (2018). “Group normalization.” Proc. ECCV.
  2. S. Qiao, H. Wang, C. Liu, W. Shen, A. Yuille (2019). “Micro-batch training with batch-channel normalization and weight standardization.” arXiv:1903.10520.
  3. J. Ho, A. Jain, P. Abbeel (2020). “Denoising diffusion probabilistic models.” Advances in NeurIPS.