Rotation-Equivariant & Steerable CNNs
Building rotations and reflections into convolution, from group convolutions to steerable filters.
A convolutional layer detects an edge anywhere in the image, but at only one orientation per filter: rotate the input and nothing in the architecture makes the features follow. Microscope slides, satellite images and tissue samples have no preferred "up", so it pays to build rotations into the layers themselves. The mathematics that does it, group convolution, steerable filters and one linear constraint on the kernel, also explains why convolution itself was inevitable.
What you’ll learn
- Define the groups p4 and p4m, describe how they act on images and on feature maps over the group, and prove that the lifting correlation is equivariant.
- Implement group convolution by filter transformation and account for its planes, parameters and multiply–adds at a matched parameter budget.
- Derive the steering property of circular harmonics, , and the arithmetic of rotation orders in harmonic networks.
- Derive the steerable kernel constraint , solve it in simple cases, and state the theorems that make equivariant linear layers convolutions.
- Judge when built-in rotation equivariance helps relative to augmentation, and when exact invariance hurts.
Group convolution on the square grid
Write a stack of feature maps as and a transformation of the plane as acting by . Ordinary cross-correlation commutes with translations, but for a rotation one only has (Cohen & Welling, 2016): a rotated image correlated with gives the rotated result of correlating the original image with the counter-rotated filter. A CNN whose filter bank happens to contain all rotated copies of each filter is therefore equivariant as a whole, but it has to learn every copy separately, from data showing every orientation.
A group convolution hard-wires the copies instead. Rotations by multiples of map the pixel grid onto itself exactly, which makes them the natural first target.
Transform the input by any , which permutes , and substitute :
Since , the last sum is the original output evaluated at :
Read off what does to the output when is the rotation about the origin: . Every plane is rotated and the four planes shift cyclically by one orientation. A rotated input produces the same features, moved to rotated positions and relabeled to the next orientation.
Implementation by filter transformation. Nothing new is needed at run time. Before each forward pass, build the expanded filter bank, rotating each filter spatially and, from the second layer on, also cyclically shifting its orientation axis, then call an ordinary conv2d with as many input and output channels. Pointwise nonlinearities commute with the permutation of planes, so ReLUs keep the equivariance. For an invariant prediction, pool over the orientation axis at the end, after the last group convolution: Cohen & Welling found that pooling over rotations early, "premature invariance", discards relative orientations that later layers need.
What it costs and what it buys
A p4 layer with input and output fields stores weights, because each filter spans the 4 orientation planes of every input field, but it runs as a convolution from to planes. Sharing each filter across the four rotations is extra weight sharing, just as convolution shares across positions.
Cohen & Welling compared networks at a matched parameter count, dividing the number of fields by for p4 and by about for p4m. For a layer that a plain CNN runs with channels, p4 with fields has exactly the same weights, yet carries planes and costs , four times the multiply–adds; p4m carries about planes for eight times the multiply–adds. Equivariance buys a larger, structured representation per parameter, paid for in compute and activation memory.
A p4m group-convolution layer has 24 output fields. How many two-dimensional feature planes does it produce?
Show the answer
192 planes
Each p4m field is a function on the 8 symmetries of the square at every pixel: 4 rotations, each with or without a reflection. So planes. This is the regular representation of the point group: each field consumes channels, being the group of rotations and reflections that fix a point.
| Network (Cohen & Welling, 2016) | Group | Test error, plain / augmented | Parameters |
|---|---|---|---|
| All-CNN on CIFAR-10 | (ordinary) | 9.44% / 8.86% | 1.37M |
| All-CNN on CIFAR-10 | p4 | 8.84% / 7.67% | 1.37M |
| All-CNN on CIFAR-10 | p4m | 7.59% / 7.04% | 1.22M |
| ResNet-44 on CIFAR-10 | / p4m | 9.45% → 6.46% / 5.61% → 4.94% | 2.64M / 2.62M |
| 7-layer CNN on rotated MNIST | p4 (P4CNN) | 2.28%, against 3.98% for the best earlier method | about the baseline's |
Rotations by are exact on a pixel grid; any other angle needs interpolation, so a network built for orientations with is equivariant only up to discretization error. Weiler & Cesa (2019) swept on rotated digits and found accuracy improving with the number of orientations and saturating at around 8 to 12.
Steerable filters and circular harmonics
Storing one copy of a filter per orientation does not scale to fine angles. Freeman & Adelson (1991) noticed that some filters can be rotated to any angle by mixing a few fixed basis filters. The derivative of the Gaussian in direction is the directional derivative
so two filters, and , give an edge detector at every orientation. In general, expand a filter in polar coordinates as an angular Fourier series . Rotating it by gives , a combination of the same functions: a filter with nonzero angular harmonics is steerable with basis filters. Such a filter is a steerable filter.
Rotate the image about the filter's center by : . Correlating at that center (without complex conjugation, as harmonic networks do):
Substitute , which shifts the angle of integration over a full period:
The response to the rotated patch is the original response times : order is rotation-invariant, turns with the input. Chaining filters of orders and multiplies the phases, so rotation orders add along any path; nonlinearities that act on magnitudes only preserve the phase. To make an output -equivariant, every path into it must have orders summing to .
The payoff is equivariance to continuous rotations of local patches, with one complex filter per order instead of one real filter per angle. Worrall et al. reported 1.69% test error on rotated MNIST with 33,000 parameters, below the earlier group-convolutional result.
Feature fields and the kernel constraint
Group convolutions and harmonic networks are two instances of one idea (Cohen & Welling, 2017; Weiler & Cesa, 2019). Give every feature a type: a representation of the rotation group , saying how its channels mix when the input rotates. A field of type transforms under a rotation and translation as
A grayscale image is a scalar field (); optical flow is a vector field (, the arrows turn as they move); the orientation planes of a p4 network form a regular field ( permutes the four planes cyclically); a harmonic network's order- response is an irrep field, rotating its two real components by .
A layer is a correlation with a matrix-valued kernel ; it commutes with translations automatically. Apply it to a rotated input field and substitute (rotations and reflections preserve area):
Equivariance demands that this equal the rotated output field:
For this to hold for every input , the integrands must agree for all and . Put , so that :
The constraint is linear, so the admissible kernels form a subspace, and its consequences are concrete:
- Scalar to scalar, : for every rotation, so the kernel is isotropic, a function of alone. A rotation-equivariant layer between scalar fields can only apply isotropic filters, such as blurs and center–surround (Laplacian-like) filters, and cannot detect the orientation of an edge, which is why equivariant networks need richer field types in their hidden layers.
- Regular fields of : rotating the kernel spatially must equal cyclically shifting its input and output orientation axes, which is exactly the filter transformation of a group convolution.
- Irreps of : the admissible kernels are angular harmonics whose frequencies are fixed by the input and output orders, with free radial profiles; the circular harmonics of harmonic networks are such a solution.
Weiler & Cesa (2019) reduced the constraint for any representation to constraints between irreducible representations and solved it for every subgroup of : cyclic and dihedral groups, and . The constraint fixes only the angular part of a kernel and leaves its radial profile free. Their library, e2cnn, gave notable gains on CIFAR-10, CIFAR-100 and STL-10 as a drop-in replacement for ordinary convolutions.
A kernel maps a scalar field to a scalar field and must commute with rotations by (), so . How many free weights does it have?
- 25
- 7
- 6
- 1
Show the answer
B. 7
The constraint ties together the weights at positions in one orbit of . The center is its own orbit; the 4 edge neighbors, the 4 diagonal neighbors, the 4 points at and the 4 corners are one orbit each; and the 8 knight-move positions such as split into two orbits of 4. That is .
When symmetry helps, and when it hurts
Equivariant CNNs earn their keep where the data really have no preferred orientation: tissue slides, cells under a microscope, aerial and satellite images, astronomical images. Veeling et al. (2018) showed that rotation equivariance significantly improves tumor detection in lymph-node histopathology, and released the PatchCamelyon benchmark for such comparisons. The gain is largest in sample efficiency: the network never has to learn an orientation it has already seen in another guise.
On upright natural images, global rotation invariance is wrong: a 6 is not a 9 and the sky is above the ground. The evidence favors local equivariance with the symmetry released near the output. On upright MNIST, Weiler & Cesa found that fully invariant and models did not beat a plain CNN, while models equivariant in early layers and restricted to no symmetry in the last ones did. Their dihedral models were also blind to the difference between a digit and its mirror image.
Between the extremes sit softer options. Augerino learns a distribution over augmentations jointly with the weights, so the training data decide how much invariance to keep (Benton et al., 2020). Relaxed group convolutions replace the single shared kernel by a few kernels mixed with weights that depend on the group element, so a network is biased toward equivariance without being forced into it; on turbulence and jet-flow data with imperfect symmetry they beat both strictly equivariant and unconstrained baselines (Wang, Walters & Yu, 2022). Equivariance and augmentation also combine: G-CNNs still improved when trained with flips and translations from a larger group than the one built in. A Theory of Data Augmentation analyzes the augmentation side, and Equivariant Networks for 3D Geometry carries the same constraint to rotations in three dimensions.
Key takeaways
- Group convolutions for p4 and p4m correlate with every rotated (and reflected) copy of each filter; feature maps become functions on the group, on which a rotation rotates each plane and cyclically shifts the orientation axis. They run as ordinary convolutions on a transformed filter bank.
- At a matched parameter count a p4 layer carries twice the planes and four times the multiply–adds of a plain layer; Cohen & Welling found consistent gains on rotated MNIST and even on upright CIFAR-10.
- Steerable filters rotate by mixing a few basis filters; circular harmonics respond to a rotation with a phase , and rotation orders add along paths.
- Equivariance between fields of types is the linear constraint , solved for all subgroups of ; equivariant linear maps between such fields are exactly these convolutions.
- Built-in symmetry pays most for data without a preferred orientation; for upright images, release it near the output, or learn how much to impose.
Check yourself
In the interactive lesson these are scored with your confidence, and what you miss comes back for review.
A p4 group-convolutional network receives an input rotated by . What happens to a hidden p4 feature map, which has 4 orientation planes per field?
- Each plane is rotated by , and nothing else changes
- The planes are cyclically permuted, but none is rotated
- Each plane is rotated by and the four planes are cyclically shifted by one orientation
- Nothing changes: p4 feature maps are rotation-invariant
Show the answer
C. Each plane is rotated by and the four planes are cyclically shifted by one orientation
The group acts by : positions rotate and the orientation index advances by one, cyclically. Invariance appears only after pooling over orientations at the end.
For and scalar input and output fields, what does the kernel constraint allow?
- Any kernel, since scalars do not transform
- Only radially symmetric (isotropic) kernels
- Only the zero kernel
- Kernels symmetric under rotations, but nothing more restrictive
Show the answer
B. Only radially symmetric (isotropic) kernels
With the constraint reads for every rotation , so depends on only. Such layers cannot detect oriented features, which is why hidden layers use regular or irrep fields.
In a harmonic network, one path through three layers uses filters of rotation orders , and . Rotating the input patch by multiplies that path's contribution by what?
Show the answer
D.
Each filter multiplies the phase by , so orders add: . Every other path into the same output must also sum to order 2, or the output would not be equivariant.
You classify upright street-scene photos, where the sky is always at the top. Which use of rotation equivariance is most likely to help?
- Full rotation invariance from the first layer on, so orientation can never matter
- Equivariance in the early layers, with the symmetry restricted or released near the output
- None: equivariance never helps on data without a global symmetry
- p4m invariance in every layer, to add reflections as well
Show the answer
B. Equivariance in the early layers, with the symmetry restricted or released near the output
Low-level patterns such as edges and textures occur at every orientation even in upright scenes, so early equivariance shares statistical strength. The final decision may depend on absolute orientation, so the symmetry should be released near the output, as in Weiler & Cesa's restricted models and in the CIFAR-10 gains of G-CNNs.
Further reading
- T. S. Cohen & M. Welling, "Group equivariant convolutional networks," ICML (2016).
- W. T. Freeman & E. H. Adelson, "The design and use of steerable filters," IEEE Transactions on Pattern Analysis and Machine Intelligence 13(9) (1991).
- D. E. Worrall, S. J. Garbin, D. Turmukhambetov & G. J. Brostow, "Harmonic networks: Deep translation and rotation equivariance," CVPR (2017).
- M. Weiler & G. Cesa, "General E(2)-equivariant steerable CNNs," NeurIPS (2019).
- T. S. Cohen, M. Geiger & M. Weiler, "A general theory of equivariant CNNs on homogeneous spaces," NeurIPS (2019).