TL;DR
A convolutional network stores its activations as a stack of channels, each a grid of values. Group normalization splits those channels into a few fixed groups and standardises each group, for one example at a time, to mean 0 and variance 1, then applies a learned scale and shift. Because it never looks at other examples in the batch, it works when the batch is tiny.
Builds on: Batch Normalization, Layer Normalization, Mean and Variance · Leads to: the Group Normalization paper
Where it's used
Object detection and segmentation. Detectors such as Mask R-CNN process high-resolution images, so a single GPU can hold only one or two images per step. Batch normalization estimates its statistics from that tiny batch, and the estimates become noisy. Group normalization was proposed partly for this setting and keeps accuracy on COCO when the batch is small.
Video and 3D models. A video clip or a volumetric scan produces many more activations per example than a single photograph. Memory limits force small batches, which is the same problem as detection, and the same fix applies.
Models trained one example at a time. Some systems update a network on each sample as it arrives, or on a shard of data split across machines. Batch statistics are then either unavailable or change with the partition. Group normalization gives the same output for an example no matter which other examples share its step, so training and inference behave the same way.
How it works
Take a tiny feature map: one image, four channels, and each channel a row of two values. Write the values as they sit in memory.
- Channel 1:
- Channel 2:
- Channel 3:
- Channel 4:
Use groups, so channels 1 and 2 form group A and channels 3 and 4 form group B.
- Collect the group. For group A, gather every value in channels 1 and 2: . Check: four values, two channels times two positions each.
- Compute the mean of the group. . Check: the mean lies between the smallest and largest value.
- Compute the variance of the group. The squared distances from 4 are , and their average is . Check: the standard deviation is .
- Standardise each value in the group. The value becomes , and becomes . Check: the four results average to 0.
- Repeat for group B. Its values have mean 3 and variance 5, so the same arithmetic gives .
- Apply the learned scale and shift to each channel. With scale 1 and shift 0, nothing changes further. In a real network the scale and shift are trained, one pair per channel.
flowchart LR
A[Feature map: C channels, one example] --> B[Split the C channels into G groups]
B --> C[For each group: mean and variance over its channels and positions]
C --> D[Standardise every value in the group]
D --> E[Learned scale and shift per channel]
E --> F[Normalised feature map, same shape as input]
The key property is in step 1. The statistics come only from one example's group. Put a different image beside this one in the batch and the output for this image does not change.
The math
Let an input for one example be a tensor with channels and spatial positions indexed by . Split the channels into groups of channels each. Assume is divisible by .
For example , group , let be the set of all values where channel belongs to group and ranges over all positions. Then
and the normalised value is , where is a tiny constant that prevents division by zero. The output is , with one learned scale and one shift per channel.
The size of each group is , where and are the height and width of the feature map.
Step 1 in symbols: collect the group
Group A corresponds to with channels . The set contains the four values , , and . Its size is .
Step 2 and 3 in symbols: mean and variance
Step 4 in symbols: standardise
With set to 0 for hand computation,
Each group has mean 0 and variance 1 after this step, which is what the definition guarantees.
Step 6 in symbols: scale and shift
For and , . In training, and are updated by gradient descent, so the network can undo the normalisation where it does not help.
Special cases
Two familiar methods are special cases of this definition:
- puts all channels in one group. Each example is then normalised over its entire feature map, which is layer normalization.
- puts each channel in its own group. Each channel of each example is normalised over its own spatial grid, which is instance normalization.
Group normalization interpolates between these two by choosing between 1 and . The paper uses as its default.
Why batch statistics are absent
Batch normalization computes and over the set for each channel, so it averages across examples. Group normalization averages over within one example . The expression for has no sum over , which is why its value for example is fixed by that example alone.
Worked examples
A single example with four channels and one value per channel, so . The values are for channels 1 to 4. Use , so groups are and . Take and , .
- Group 1 holds the values and . Their mean is .
- Their squared distances from 2 are and , so the variance is .
- Normalise: and .
- Group 2 holds and . Their mean is .
- Their squared distances from 12 are and , so the variance is and the standard deviation is .
- Normalise: and .
- The output is .
Interpretation: the two groups had very different scales (values near 2 and values near 12), and after normalisation both look the same. The network now sees each group on the same footing.
One example with four channels and two spatial positions, so and . Values: channel 1 is , channel 2 is , channel 3 is , channel 4 is . Use .
- Group A is channels 1 and 2, which holds . Its size is .
- The mean is .
- The variance is , so the standard deviation is .
- Normalise the four values: , , , .
- Group B is channels 3 and 4, which holds . Its mean is and its variance is .
- Normalise: , , , .
- Check: in group A the four normalised values sum to , as required.
Interpretation: each output value says how far it sits from the mean of its own group, measured in that group's spread. Group A and group B have the same spread here, so their outputs look alike even though their raw values differ.
A detector's backbone produces a feature map with channels, , and groups. Each step processes a batch of images on one GPU.
- Group size: each group has channels. The spatial grid has positions. So each group holds values for one image.
- Batch normalization would compute each channel's statistics from values. Those values come from only two images, so the estimate changes whenever the second image changes.
- Group normalization computes its statistics from values belonging to one image. Those values do not depend on the second image at all.
- Consequence: if you swap the image beside a given photo, its group-normalized activations stay identical, while its batch-normalized activations shift.
Try it: a feature map has channels, , and groups. How many values are in one group for one image? Answer: each group has channels and positions, so values.
Common mistakes and tradeoffs
Mistake: group normalization is always more accurate. It is tempting to think a method that avoids batch statistics must win. In fact, when the batch is large and well-tuned, as in standard ImageNet classification, batch normalization is typically as accurate or slightly better. Group normalization's advantage appears when the batch is small, which is exactly where batch statistics become unreliable.
Mistake: the groups are chosen from the data. It is tempting to think the channels are clustered by similarity. In fact the groups are fixed blocks of consecutive channels, set before training. The method never looks at the values when forming them.
Mistake: it averages across the batch. It is tempting to think any normalisation must use other examples. In fact the statistics come only from one example's group, so its output needs no running averages at inference time. The same formula runs in training and in testing.
Mistake: can be any number. must be divisible by . A common default of 32 works for widths like 64, 128 and 256 but not for every layer width. Choosing too small makes groups large and close to layer normalization, while too large makes them close to instance normalization, which removes useful channel-wise information.
When to use it. Use group normalization when the batch is small, when the model processes high-resolution inputs, or when you need the same behaviour at training and inference. When not to use it. When the batch is large and batch normalization is already tuned, it remains a strong default. For sequence models such as transformers, Layer Normalization is the usual choice, because the feature dimension is the natural unit.
History
Batch normalization was introduced by Ioffe and Szegedy in 2015. It worked very well for large-batch image classification and quickly became standard, but its dependence on batch statistics caused trouble wherever batches were small. Ba, Kiros and Hinton proposed layer normalization in 2016 for recurrent networks, where batch statistics across time steps were awkward. Ulyanov, Vedaldi and Lempitsky proposed instance normalization in 2016 for image stylisation, where each image's own contrast and brightness should be removed. Yuxin Wu and Kaiming He proposed group normalization in 2018 as a single method that covers the space between layer and instance normalization, and showed that it matches batch normalization on large batches and is more stable on small ones. It caught on because detection and segmentation pipelines kept hitting the small-batch problem.
Recap
- Group normalization splits channels into fixed groups and standardises each group within one example.
- Its statistics come only from that example, so the output does not depend on the batch.
- gives layer normalization; gives instance normalization.
- It shines with small batches, as in detection, segmentation and video, and it behaves the same at training and inference.
- Read next: the Group Normalization paper, which runs the experiments that compare it with batch normalization.