TL;DR
Batch normalization made deep image networks easy to train, but it measures its statistics across the batch, and those statistics become noisy when the batch is small. Large images, object detectors and video models all force small batches. Wu and He split the channels of each example into groups and normalize inside each group, so every image is normalized only by its own numbers. With ResNet-50 on ImageNet, the method is 0.5 points worse than batch normalization at batch size 32 and has 10.6 points lower error at batch size 2.
Builds on: batch normalization, layer normalization, Instance Normalization, Convolutional Neural Network · Leads to: Object Detection, Image Segmentation, where the same layer is used when training with small batches.
Why it mattered
Group normalization is now a standard option in vision code. Most major deep learning libraries ship it as a layer next to batch normalization. The only change from batch normalization is which axes the mean and variance are taken over, so the code change is small.
The paper's main evidence comes from three tasks where batch normalization is hard to use:
- ImageNet classification with ResNet-50. Batch normalization needs 32 or more images per GPU to match its usual accuracy. GN matches it at 32 and stays flat down to 2.
- Object detection and instance segmentation on COCO with Mask R-CNN (a detector that also predicts a pixel mask for each object). Detectors use one or two high-resolution images per GPU, so their batch normalization layers are usually frozen (their statistics and scale are fixed and not trained). GN is trained as part of the model and beats the frozen baseline.
- Video classification on Kinetics with 3D convolutions (filters that slide over time as well as space). A 3D network spends its memory on time as well as space, so the batch is small. GN gives better accuracy with longer clips, because it does not trade clip length against batch size.
History
By 2017 batch normalization was the default normalization in convolutional networks. It worked well for large batches, but people who trained detectors, segmentation models and video networks were forced to use one or two images per GPU, and in that setting BN either had to be frozen or gave worse results. Layer normalization and instance normalization had appeared as batch-free alternatives, but they had been designed for recurrent and generative models and did poorly on image recognition.
Wu and He published the paper in 2018 on arXiv, and the work was later published in the International Journal of Computer Vision (2020). Its central observation was that classical image features such as SIFT and HOG are already grouped, so grouping channels is a natural design rather than a hack. The method caught on because it required no new hyper-parameters beyond the group count, and because the experiments showed it matching BN on the standard setting and beating it on the tasks where BN struggled.
The problem
A normalization layer takes a tensor of activations and shifts and rescales it so that its mean is 0 and its variance is 1. Batch normalization does this for each channel using the values from every image in the batch. Three things follow, and the paper is written against all three.
- The statistics depend on the batch. With a batch of 2 images per GPU, the mean and variance of one channel come from two images. The estimate is noisy, and the network sees a different normalization each step. The paper's Table 2 shows the error of ResNet-50 rising from 23.6 percent at batch size 32 to 34.7 percent at batch size 2.
- Small batches limit model design. Memory grows with the batch, so a researcher who wants a bigger model or a bigger input is pushed to a smaller batch, and then batch normalization gets worse. 3. Some layers have no batch. Layer normalization and instance normalization already avoid the batch axis. But the authors found that layer normalization loses about 1.7 points on ImageNet at batch size 32 and instance normalization loses about 4.8, so neither was a replacement for batch normalization in image recognition.
The question is therefore: can a method keep the accuracy of batch normalization in the normal regime and not depend on the batch at all?
How it works
Take one convolutional layer that outputs 4 channels, with one spatial position so that each channel is a single number. Use 2 groups of 2 channels. The numbers below are one image's activations.
- Input. The layer produces the four numbers 2, 4, 10 and 16, one per channel. Their mean is , so the layer is not centred.
- Split into groups. Channels 1 and 2 form group 1, with values 2 and 4. Channels 3 and 4 form group 2, with values 10 and 16. Only channels in the same group are normalized together.
- Statistics per group. Group 1 has mean 3 and variance 1. Group 2 has mean 13 and variance 9. The batch is not used anywhere in this step. Another image in the batch would have no effect.
- Normalize. Each value becomes (value minus group mean) divided by the group standard deviation. Group 1 gives -1 and +1. Group 2 gives -1 and +1, because 10 minus 13 is -3 and -3 divided by 3 is -1. The output has mean 0 and variance 1 inside each group.
- Scale and shift. Each channel has its own learned numbers γ and β. They restore whatever scale the layer needs. With γ = 1 and β = 0 the output is simply the normalized values.
- Check. Repeat for a second image. Its groups are normalized with its own means, so the first image's output is the same whether the second image is present or not.
The picture below shows which values share statistics. For this layer, the channels are grouped and each group pools its values over space and over the channels in it, but never over the batch.
flowchart LR A["Activations x with axes N, C, H, W"] --> B["Split the C channels into G groups of C/G channels"] B --> C["For each image n and group g, compute mean and variance over the group's channels and all H times W positions"] C --> D["Normalize every value in that group with those two numbers"] D --> E["Apply the learned scale gamma and shift beta for each channel"] E --> F["Output, same shape as x"]
Worked examples
Use so the numbers stay clean. Input for one image: channels 1 to 4 hold . Groups: and .
- Group 1 values are and . Their mean is .
- Group 1 deviations are and . Their squares are and , so the variance is and .
- Normalized group 1 values are and .
- Group 2 values are and . Their mean is .
- Group 2 deviations are and . Their squares are and , so the variance is and .
- Normalized group 2 values are and .
Interpretation: each group is now centred and has unit spread, so the two groups look alike even though their raw scales were very different (group 2 had values about four times larger than group 1). That is the purpose of the layer.
Use the same layer with . Image A is as before. Image B is .
- Normalize image A alone. Its output is , as in example 1.
- Normalize image B. Group 1 is : mean , deviations , variance , so . Outputs are .
- Group 2 is : mean , deviations , . Outputs are .
- Now stack both images into a batch of 2 and normalize the whole batch with batch normalization instead. Channel 1 holds (A) and (B), so its mean is and its variance is . The normalized value for A becomes , not .
- Under group normalization, image A still gives , because its statistics never looked at image B.
Interpretation: with group normalization the output for an image does not depend on the other images in the batch, so batch size 1 behaves exactly like batch size 32. Batch normalization gives a different answer for A depending on B, and that dependence is the source of the small-batch problem.
A ResNet-50 layer might have channels on a feature map, trained with the paper's default groups.
- Channels per group: .
- Positions per channel: .
- Values normalized together for one group in one image: .
- Under batch normalization, one channel's statistics at batch size 2 would be computed from values, all from two images. Under group normalization the statistics always come from values in one image, so the estimate is equally reliable at batch size 2 and batch size 32.
- Table 2 of the paper reports the result of this regime: at batch size 2, ResNet-50 has error 24.1 percent with GN and 34.7 percent with BN, a difference of points.
Interpretation: the statistics come from 25088 values inside one image, so noise is not the limit. The batch can be as small as memory forces it to be.
Try it: a layer has channels, groups and a feature map. For one image, how many values are normalized together for one group?
Answer: channels per group, positions, so values.
The math
Definition (the general form). Let be a feature tensor indexed by , where is the batch axis, the channel axis, and , the spatial axes. A normalization layer computes
where the mean and standard deviation are taken over a set of values:
Here is a small constant that avoids dividing by zero. The four methods differ only in the set .
Step 1 in symbols (the groups). Let be the number of groups, so each group holds channels. The set for group normalization is
In words: the value belongs to the same set as if it comes from the same image and from the same group of channels. The floor expression sends channel numbers to to group 0, the next block to group 1, and so on. The paper uses by default.
Step 2 in symbols (the size of the set). Each group contains channels, and each channel has positions, so
For the toy layer, , , , so .
Step 3 in symbols (the other methods as special cases). Batch normalization uses , which pools over the batch and space. Layer normalization uses , pooling over all channels and space of one image. Instance normalization uses , pooling only over space. Group normalization sits between layer and instance normalization: setting gives layer normalization, and setting gives instance normalization.
Step 4 in symbols (the output). The layer learns one and one per channel, so the parameter count is , the same as batch normalization. Nothing about and depends on the batch.
Results
ImageNet, batch size 32 per GPU (Table 1). ResNet-50 validation error: BN 23.6 percent, LN 25.3, IN 28.4, GN 24.1. GN is 0.5 points behind BN, and it is the best of the three batch-free methods by a wide margin.
ImageNet, varying batch size (Table 2). Validation error by images per GPU:
| batch size | 32 | 16 | 8 | 4 | 2 |
|---|---|---|---|---|---|
| BN | 23.6 | 23.7 | 24.8 | 27.3 | 34.7 |
| GN | 24.1 | 24.2 | 24.0 | 24.2 | 24.1 |
GN is flat across the range, and at batch size 2 it is 10.6 points better than BN. COCO object detection and segmentation, C4 backbone (Table 4). Box AP 38.8 for GN against 37.7 for frozen BN, and mask AP 33.6 against 32.8. Gains are about one point at a common setting.
COCO with the FPN backbone (Table 6). FPN (a feature pyramid that combines layers at several resolutions) is the backbone used here. With the Detectron baseline, ResNet-50 box AP is 38.6 with frozen BN and 40.3 with GN. Training GN for longer (the paper's "long" schedule) gives 40.8, and the mask AP goes from 34.5 to 36.1. The gains come from using GN in the backbone, box head and mask head together.
Kinetics video classification. The paper uses a ResNet-50 I3D (a ResNet whose filters also cover time). With a short clip and a batch of 4, GN is ahead of BN, and with a longer clip the gap grows, because GN can use the longer clip without shrinking the batch.
What the numbers mean. GN is not better than BN when BN has a large batch. It matches BN there, slightly loses on the validation set, and is much more stable whenever the batch shrinks. Those gains transfer to detection and video, where small batches are the norm.
Limits. The experiments use ResNets and VGG-16 on ImageNet, and Mask R-CNN and I3D with ResNet-50 backbones for detection and video. They do not cover sequence models or generative models. Some detection numbers come from longer training schedules, so compare schedules before comparing numbers across papers.
Common mistakes and tradeoffs
It is tempting to think that group normalization is just a cheaper batch normalization; in fact it changes which numbers are averaged, and the averaged numbers are different. Batch normalization averages each channel over the batch, so its training noise also acts as a regularizer. Group normalization removes that noise. The paper observes that GN has lower training error than BN but slightly higher validation error at batch size 32, and it suggests a regularizer could recover the gap. Expect a small loss in the regime where BN works well.
It is tempting to think that the number of groups does not matter as long as it is not extreme. In fact the group count is a real hyper-parameter. is layer normalization and is instance normalization, and both are worse than an intermediate choice on image recognition. The paper's default is .
It is tempting to think that GN replaces every normalization in every network. In fact the authors' results are on ResNets, VGG-16 and 3D ResNets, and they note that BN has shaped many systems and their learning rates, so those settings may not be best for GN. For sequence models the paper says the connection to LN is suggestive but untested here.
When to use it: when the batch per device is small (detection, segmentation, video, very large inputs) or when you want the result to be the same at training and test time for any batch size. When not to use it: when the batch is large and BN is already the best choice and you have tuned for it. Alternatives include batch renormalization, which keeps batch statistics but limits how far they drift, and synchronized batch normalization, which computes statistics across several GPUs and so has a larger effective batch.
Reading guide
Read the paper in this order. Each section names the lessons it leans on.
- Abstract and Section 1, Introduction. Needs batch normalization (the mini-batch statistics) and layer normalization (the batch-free alternative). Figure 1 needs only the reading of a curve.
- Section 2, Related Work. Needs Mean and Variance to follow the ideas about spread and centring, and Instance Normalization for the spatial-only method.
- Section 3.1, Formulation. The core of the paper. Needs Mean and Variance and Convolutional Neural Network for what the channel, height and width axes mean. Read the sets slowly; they are the whole method.
- Section 3.2, Implementation. Needs nothing new beyond knowing what a tensor's axes are.
- Section 4.1, ImageNet. Needs ResNet for the architecture and batch normalization for the baseline. Tables 1 to 3 are the evidence for the claims above.
- Section 4.2, COCO. Needs Object Detection and Image Segmentation for the task, and the idea of freezing a layer so it stops updating.
- Section 4.3, Kinetics. Needs Convolutional Neural Network for the 3D version of the same idea, applied over time as well as space.
- Section 5, Discussion. Needs Layer Normalization and Instance Normalization for the connection to recurrent and generative models.
Check yourself
QuestionRecall: in group normalization, which values are averaged together to compute the mean for one group in one image?Show answer
The values in the same image and in the same group of channels, across all spatial positions. They are not averaged across other images in the batch, and channels in other groups are not included.
QuestionCompute: a layer has channels, groups and a feature map. For one image and one group, how many values are normalized together?Show answer
Each group has channels, and each channel has positions. So values.
QuestionWhy: why does the error of batch normalization rise sharply at batch size 2 while group normalization stays flat?Show answer
Batch normalization estimates each channel's mean and variance from the batch, so with two images the estimate is noisy and the network's normalization changes from step to step. Group normalization estimates them from many values inside one image, so its statistics do not depend on how many images are in the batch.
QuestionApplied: a team trains an object detector with one high-resolution image per GPU and freezes batch normalization. They ask whether switching to group normalization is worth trying. What does the paper suggest?Show answer
Yes. The paper's COCO experiments use one or two images per GPU, and GN trained within the model beats the frozen BN baseline (for example 40.3 against 38.6 box AP with ResNet-50 and FPN). The team should also expect to train longer, as the paper did for its best result, and should check the group count. The gain is an empirical result on COCO and may differ on other detectors.
Sources
- Yuxin Wu and Kaiming He, "Group Normalization," arXiv:1803.08494 (2018). https://arxiv.org/abs/1803.08494
- Yuxin Wu and Kaiming He, "Group Normalization," International Journal of Computer Vision (2020). https://doi.org/10.1007/s11263-019-01198-w
- Sergey Ioffe and Christian Szegedy, "Batch Normalization," arXiv:1502.03167 (2015). https://arxiv.org/abs/1502.03167
- Jimmy Lei Ba, Jamie Ryan Kiros and Geoffrey E. Hinton, "Layer Normalization," arXiv:1607.06450 (2016). https://arxiv.org/abs/1607.06450