Groups, Symmetry, and Equivariance
Part 2 of Math for GDL: groups, homomorphisms, group actions, and the invariance and equivariance that geometric deep learning is built on, with every claim checked in NumPy.
A dense layer that maps a 224 × 224 image to another image of the same size has \( 50{,}176^2 \approx 2.5 \) billion weights. A convolutional layer doing the same job with a 3 × 3 filter has 9. The gap is not a clever approximation. Most of it follows from a single requirement: if you shift the input, the output should shift the same way. Ask for that, and the only linear layers left are convolutions.
This post builds the language behind that argument. Groups describe symmetries. Group actions say how a symmetry moves data around. Invariance and equivariance say how a model should respond. With those in hand, the convolution claim takes a few lines to prove.
This is Part 2 of Math for GDL. The series works through a review paper by Sáez de Ocáriz Borde & Bronstein (2025), called the review below, one section at a time, and this part follows §1.2. Part 1 built the language of sets and maps. It found a first symmetry hiding in every network, the \( 1000! \) orderings of a hidden layer that compute the same function. And it ended with the central idea of geometric deep learning: shrink the hypothesis class by keeping only the maps that respect a symmetry of the problem. What it never said is what respecting a symmetry means. This post does. Fig. 1 shows the whole idea on one small example.
Table of contents
Notation
| Symbol | Meaning |
|---|---|
| \( (G, \circ) \) | A group: a set \( G \) with an operation \( \circ \) |
| \( e \) | The identity element of a group |
| \( g^{-1} \) | The inverse of \( g \) |
| \( C_n \) | The \( n \) rotations of a regular \( n \)-gon (equivalently, shifts of a ring of \( n \) points) |
| \( \mathbb{Z}_n \) | The integers \( \{0, \ldots, n-1\} \) under addition modulo \( n \) |
| \( S_n \) | All permutations of \( n \) items |
| \( H \le G \) | \( H \) is a subgroup of \( G \) |
| \( |G| \) | The order of \( G \): its number of elements |
| \( G \cong H \) | \( G \) and \( H \) are isomorphic |
| \( g \cdot x \) | The result of \( g \) acting on \( x \) |
| \( \operatorname{Orb}(x) \) | The orbit of \( x \): every point \( g \cdot x \) the group can reach |
| \( P \) | The cyclic shift on \( \mathbb{R}^n \): \( (Px)_i = x_{i-1 \bmod n} \) |
Groups
Seen groups before? Skim to Group actions and orbits; the review's slips are flagged along the way.
A symmetry of an object is a transformation that leaves it looking the same. Rotate a square by 90° and it looks unchanged; rotate it by 45° and it doesn't. The square's four rotations, \( C_4 = \{0^\circ, 90^\circ, 180^\circ, 270^\circ\} \), have three features worth noticing. Combining two of them gives another one (90° then 180° is 270°). Doing nothing, the 0° rotation, is one of them. And each one can be undone (90° is undone by 270°). Add associativity, which any chain of transformations has, and you have the definition of a group.
Definition 1 (Group). A group \( (G, \circ) \) is a set \( G \) together with an operation \( \circ : G \times G \to G \) that satisfies three axioms:
- Associativity: \( (a \circ b) \circ c = a \circ (b \circ c) \) for all \( a, b, c \in G \).
- Identity: there is an element \( e \in G \) with \( e \circ a = a \circ e = a \) for all \( a \in G \).
- Inverses: for each \( a \in G \) there is an element \( a^{-1} \in G \) with \( a \circ a^{-1} = a^{-1} \circ a = e \).
Closure, the rule that combining two elements gives another element of \( G \), is missing from the list. The review points out that it comes for free. The operation is a map \( G \times G \to G \) in the sense of Part 1, Definition 3, so its outputs land in \( G \) by construction. Some groups worth knowing:
- \( C_4 \), the rotations of a square, combined by adding angles modulo 360°. The identity is 0°.
- \( (\mathbb{Z}, +) \), the integers under addition. The identity is 0, and the inverse of \( a \) is \( -a \).
- \( (\mathbb{Q} \setminus \{0\}, \cdot) \), the non-zero rational numbers under multiplication. The identity is 1, and the inverse of \( a \) is \( 1/a \).
- \( S_n \), all permutations of \( n \) items, combined by doing one permutation after another. It has \( n! \) elements. The hidden-unit shuffles from Part 1 are exactly the elements of \( S_k \), for a layer of width \( k \).
Non-examples help too. The integers under subtraction fail associativity: \( (5 - 3) - 1 = 1 \) but \( 5 - (3 - 1) = 3 \). The positive integers under addition have no identity and no inverses. Two consequences of the axioms come up constantly, so they get their own proposition:
Proposition 1 (Uniqueness). A group has exactly one identity element, and each element has exactly one inverse.
Proof
If \( e \) and \( e' \) are both identities, then \( e = e \circ e' = e' \): the first step uses that \( e' \) is an identity, the second that \( e \) is. If \( b \) and \( c \) are both inverses of \( a \), then $$ \begin{aligned} b &= b \circ e && \text{; identity} \\ &= b \circ (a \circ c) && \text{; } c \text{ is an inverse of } a \\ &= (b \circ a) \circ c && \text{; associativity} \\ &= e \circ c = c && \text{; } b \text{ is an inverse of } a \end{aligned} $$ ∎
Proposition 1 is why we can speak of the identity \( e \) and the inverse \( a^{-1} \). A few more terms complete the vocabulary:
Definition 2 (Abelian group, subgroup, order). A group is abelian (or commutative) if \( a \circ b = b \circ a \) for all \( a, b \in G \). A subgroup \( H \le G \) is a subset of \( G \) that is itself a group under the same operation. The order \( |G| \) of a group is its number of elements.
\( C_4 \) is abelian and has order 4. The identity and the half-turn, \( C_2 = \{0^\circ, 180^\circ\} \), form a subgroup, \( C_2 \le C_4 \). \( S_3 \) is not abelian: swapping the first two items and then the last two gives a different arrangement from doing the same swaps in the other order.
The review slips once here. A margin note calls the rotations of three-dimensional space an abelian group, but they are not. Turn a book 90° about a horizontal axis, then 90° about a vertical one. Now start again and do the two turns in the opposite order. The book ends up facing a different way (the notebook checks this with rotation matrices). Rotations of the plane do commute, which may be what the note meant.
Homomorphisms
Groups that look different can have the same structure. \( C_4 \) is made of rotations, while \( \mathbb{Z}_4 = \{0, 1, 2, 3\} \) with addition modulo 4 is arithmetic on a four-hour clock. Yet if you label each rotation by its number of quarter-turns, one becomes the other. Maps that respect the operation make this precise.
Definition 3 (Homomorphism, isomorphism). Let \( (G, \circ) \) and \( (H, \ast) \) be groups. A map \( \varphi : G \to H \) is a homomorphism if $$ \varphi(a \circ b) = \varphi(a) \ast \varphi(b) \quad \text{for all } a, b \in G. $$ A bijective homomorphism is an isomorphism, and two groups are isomorphic, written \( G \cong H \), if an isomorphism between them exists.
The relabelling \( \varphi(90k^\circ) = k \) is an isomorphism \( C_4 \to \mathbb{Z}_4 \). For example, \( \varphi(90^\circ + 180^\circ) = \varphi(270^\circ) = 3 = 1 + 2 \). The review's second example, \( \psi : C_4 \to C_2 \), sends 0° and 180° to 0° and sends 90° and 270° to 180°. It is a homomorphism, but not injective. It has a simple meaning: it records whether a rotation swaps the square's two diagonals.
The review adds that \( C_4 \) and \( C_2 \) are not isomorphic. That is true, but not because \( \psi \) fails to be injective: some other map might succeed. The real reason is that the groups have different orders. No bijection exists between a set of four elements and a set of two, by the pigeonhole principle from Part 1.
Aside: what a homomorphism preserves
Proposition 2. A homomorphism \( \varphi : G \to H \) sends the identity to the identity and inverses to inverses: \( \varphi(e_G) = e_H \) and \( \varphi(a^{-1}) = \varphi(a)^{-1} \).
Proof
First, \( \varphi(e_G) = \varphi(e_G \circ e_G) = \varphi(e_G) \ast \varphi(e_G) \). Combining both sides with \( \varphi(e_G)^{-1} \) gives \( e_H = \varphi(e_G) \). Then $$ \begin{aligned} \varphi(a) \ast \varphi(a^{-1}) &= \varphi(a \circ a^{-1}) && \text{; homomorphism} \\ &= \varphi(e_G) = e_H && \text{; just shown} \end{aligned} $$ and similarly in the other order, so \( \varphi(a^{-1}) \) is an inverse of \( \varphi(a) \). By Proposition 1 it is the only one. ∎
Why ML cares. A homomorphism from a group into invertible matrices is called a representation. Sending each rotation in \( C_4 \) to its 2 × 2 rotation matrix is one: combining two rotations corresponds to multiplying their matrices. Representations are how equivariant networks (defined below) let a symmetry act on their hidden feature vectors, not just on raw inputs (Bronstein et al. 2021).
Group actions and orbits
A group on its own is abstract, while data is concrete. A group action connects the two: it says how each group element moves the points of some set.
Definition 4 (Group action). A (left) action of a group \( G \) on a set \( X \) is a map \( G \times X \to X \), written \( (g, x) \mapsto g \cdot x \), that satisfies two axioms:
- Identity: \( e \cdot x = x \) for all \( x \in X \).
- Compatibility: \( (g \circ a) \cdot x = g \cdot (a \cdot x) \) for all \( g, a \in G \) and \( x \in X \).
Compatibility says that acting with \( g \circ a \) is the same as acting with \( a \) first and then with \( g \). Three actions run through this post:
- \( C_4 \) acts on the corners A, B, C, D of a square. A 90° turn sends A to B, B to C, C to D and D to A.
- \( S_4 \) acts on the four weather stations from Part 1 by relabelling them, which moves their readings around.
- \( C_n \) acts on the positions of a ring of \( n \) points by shifting them.
Data is usually not a single point of \( X \) but a function on it. An image assigns a brightness to each pixel, and a weather snapshot assigns a temperature to each station. If \( G \) acts on \( X \), it also acts on functions \( f : X \to \mathbb{R} \):
$$ (g \cdot f)(x) = f(g^{-1} \cdot x). $$
To find the new value at \( x \), look up the old value at the point that \( g \) moved to \( x \). The inverse is easy to forget, and it matters. Suppose you define instead \( (g \cdot f)(x) = f(g \cdot x) \). Acting with \( a \) and then \( g \) gives
$$ \begin{aligned} \big(\textcolor{#3b82f6}{g} \cdot (\textcolor{#e0453a}{a} \cdot f)\big)(x) &= (\textcolor{#e0453a}{a} \cdot f)(\textcolor{#3b82f6}{g} \cdot x) && \text{; definition, for } g \\ &= f\big(\textcolor{#e0453a}{a} \cdot (\textcolor{#3b82f6}{g} \cdot x)\big) && \text{; definition, for } a \\ &= f\big((\textcolor{#e0453a}{a} \circ \textcolor{#3b82f6}{g}) \cdot x\big) && \text{; compatibility on } X \end{aligned} $$
which is \( (a \circ g) \cdot f \). We acted with \( a \) first and then \( g \), so compatibility needs \( (g \circ a) \cdot f \); the order is reversed. For an abelian group that makes no difference. For \( S_3 \), compatibility fails for 18 of the 36 pairs \( (g, a) \), exactly the pairs that don't commute.
Definition 5 (Orbit). The orbit of a point \( x \in X \) under an action of \( G \) is the set of all points the group can move it to, $$ \operatorname{Orb}(x) = \{\, g \cdot x \mid g \in G \,\}. $$
The orbit of corner A under \( C_4 \) is all four corners. The orbit of a temperature snapshot under \( S_4 \) has \( 4! = 24 \) points when all four readings differ, and fewer when some are equal. The top row of Fig. 1 is the orbit of an image under \( C_4 \).
Why ML cares. Data augmentation trains a model on randomly shifted, rotated or flipped copies of each example. In other words, it samples from orbits. This teaches the model to treat an orbit as one thing, but only approximately, and only for the transformations and inputs the training data covers. The rest of this post is about getting the same behaviour exactly, by construction.
Invariance and equivariance
There are two natural ways for a model to respect a symmetry. It can ignore the transformation completely, or it can transform its output in step with its input.
Definition 6 (Invariant map). Let \( G \) act on \( X \). A map \( f : X \to Y \) is \( G \)-invariant if $$ f(g \cdot x) = f(x) \quad \text{for all } g \in G,\ x \in X. $$
Definition 7 (Equivariant map). Let \( G \) act on both \( X \) and \( Y \). A map \( f : X \to Y \) is \( G \)-equivariant if $$ f(g \cdot x) = g \cdot f(x) \quad \text{for all } g \in G,\ x \in X. $$
An invariant map collapses each orbit to a single output. An equivariant map moves along the orbit with its input (Fig. 2). The two dots in Definition 7 can stand for different actions: one on inputs, one on outputs.
The weather stations give a clean example of each. The mean temperature is \( S_4 \)-invariant: relabelling the stations does not change the average. Centering, \( t \mapsto t - \bar{t} \), is \( S_4 \)-equivariant: relabel the stations and the centered readings are relabelled in the same way. For images, a classifier should be invariant to shifts: a cat moved to the left is still a cat. A segmentation model should be equivariant: its mask should move with the cat.
Proposition 3 (Stacking). If \( f : X \to Y \) and \( h : Y \to Z \) are \( G \)-equivariant, so is \( h \circ f \). If \( f \) is \( G \)-equivariant and \( h \) is \( G \)-invariant, then \( h \circ f \) is \( G \)-invariant. (Here \( \circ \) is composition of maps, as in Part 1, not a group operation.)
Proof
For the first claim, $$ \begin{aligned} h(f(g \cdot x)) &= h(g \cdot f(x)) && \text{; } f \text{ equivariant} \\ &= g \cdot h(f(x)) && \text{; } h \text{ equivariant} \end{aligned} $$ For the second, $$ \begin{aligned} h(f(g \cdot x)) &= h(g \cdot f(x)) && \text{; } f \text{ equivariant} \\ &= h(f(x)) && \text{; } h \text{ invariant} \end{aligned} $$ ∎
Proposition 3 is the blueprint behind most GDL architectures, and the review describes the same strategy. Stack equivariant layers, which keep track of where things are, then finish with an invariant readout such as a sum or a max. Fig. 1 is a one-layer example. Making every layer invariant would be too strict. Once the first layer throws away where things are, no later layer can use that information.
Why ML cares. E(n)-equivariant graph neural networks (Satorras et al. 2021) apply this blueprint to molecules. Their layers are equivariant to rotations, reflections and translations of the atom coordinates, and to relabelling the atoms. So a property they predict, such as a molecule's energy, cannot change when the molecule is turned around.
Convolutions are the shift-equivariant linear maps
Now for the claim from the opening. Take signals on a ring of \( n \) points, so a signal is a vector \( x \in \mathbb{R}^n \). The group \( C_n \) acts by shifting: the cyclic shift \( P \) moves every entry one step, \( (Px)_i = x_{i-1} \), with indices taken modulo \( n \). Shifting by \( k \) steps is \( P^k \), and \( P^n \) is the identity, so every element of \( C_n \) is a power of \( P \). That means checking a single shift is enough. A linear layer \( W \) is \( C_n \)-equivariant exactly when \( WP = PW \), because then \( WP^k = PWP^{k-1} = \cdots = P^k W \) for every \( k \).
Proposition 4 (Convolution). A linear map \( W : \mathbb{R}^n \to \mathbb{R}^n \) is shift-equivariant if and only if it is a circular convolution: there is a vector \( c \in \mathbb{R}^n \) with $$ (Wx)_i = \sum_{j=0}^{n-1} c_{\,i-j}\, x_j \quad \text{for all } x \in \mathbb{R}^n, $$ with indices modulo \( n \).
Proof
Let \( e_0, \ldots, e_{n-1} \) be the standard basis, so \( P e_j = e_{j+1} \) and \( e_j = P^j e_0 \). If \( WP = PW \), then column \( j \) of \( W \) is \( W e_j = W P^j e_0 = P^j W e_0 \): the first column \( c = W e_0 \), shifted down by \( j \). So \( W_{ij} = c_{i-j} \), which is the formula above. Conversely, for a convolution, $$ \begin{aligned} (WPx)_i &= \sum_j c_{i-j}\, x_{j-1} && \text{; } (Px)_j = x_{j-1} \\ &= \sum_{j'} c_{i-1-j'}\, x_{j'} && \text{; substitute } j' = j - 1 \\ &= (Wx)_{i-1} = (PWx)_i && \text{; definition of } P \end{aligned} $$ ∎
In matrix form, each column of a convolution is the column before it shifted down one step, wrapping around at the bottom. For \( n = 4 \) and filter \( c = (c_0, c_1, c_2, c_3) \):
$$ W = \begin{pmatrix} c_0 & c_3 & c_2 & c_1 \\ c_1 & c_0 & c_3 & c_2 \\ c_2 & c_1 & c_0 & c_3 \\ c_3 & c_2 & c_1 & c_0 \end{pmatrix}. $$
A general linear map on \( \mathbb{R}^n \) has \( n^2 \) entries. A shift-equivariant one is pinned down by \( n \) numbers, the filter \( c \). The notebook confirms this directly: for \( n = 8 \), the matrices that commute with \( P \) form a space of dimension exactly 8. Fig. 3 shows what equivariance looks like in practice.
The same argument works for images. Take a 224 × 224 grid that wraps around at the edges, and shift by any number of rows and columns. (The notebook checks the same count on a 6 × 6 grid.) Equivariance cuts a dense layer's 2,517,630,976 weights to 50,176: one full-size filter. A second, separate assumption, locality, cuts that to 9. Locality means each output depends only on a 3 × 3 neighbourhood. All these counts are per pair of input and output channels.
Real CNNs bend these rules in two ways. First, they pad image borders with zeros instead of wrapping around. A shift is then not even an exact symmetry of the image: content falls off one edge while zeros come in at the other. So equivariance holds only away from the borders. Second, layers that subsample with stride \( s \), such as strided convolutions and pooling, commute only with shifts by multiples of \( s \).
Why ML cares. This is weight sharing. LeCun et al. (1989) used it in a network trained to read handwritten zip codes. Units in a feature map apply the same weights at every position. That greatly reduced the number of free parameters, and it made the features follow the input as it shifts. Group equivariant CNNs (Cohen & Welling 2016) extend the same sharing from shifts to 90° rotations and reflections, and reported state-of-the-art results on rotated MNIST at the time.
Aside: the review's group convolution formula
The review defines a group convolution as \( (f \star \psi)(x) = \sum_{g \in G} f(g \cdot x)\, \psi(g^{-1}) \) and states that it is \( G \)-equivariant. For abelian groups it is. With \( G = C_n \) acting on a ring, it is exactly the circular convolution of Proposition 4. For non-abelian groups, the formula as written is not equivariant. Transforming the input by \( h \) gives \( \sum_k f(k \cdot x)\, \psi(k^{-1} h^{-1}) \) (substitute \( k = h^{-1} g \)). Transforming the output gives \( \sum_k f(k \cdot x)\, \psi(h^{-1} k^{-1}) \) (substitute \( k = g h^{-1} \)). The two agree for every \( \psi \) only when \( k^{-1} h^{-1} = h^{-1} k^{-1} \), that is, when the elements commute. The notebook finds counterexamples in \( S_3 \) under both conventions for how a group acts on functions. For general groups, Cohen & Welling (2016) use a convolution whose output is a function on the group itself.
A preview: fields
Part 3 builds vector spaces, and a vector space needs scalars to multiply by. The review closes §1.2 by defining the structure those scalars come from.
Definition 8 (Field). A field \( \mathbb{F} \) is a set with two operations, addition \( + \) and multiplication \( \cdot \), such that:
- \( (\mathbb{F}, +) \) is an abelian group, with identity \( 0 \);
- \( (\mathbb{F} \setminus \{0\}, \cdot) \) is an abelian group, with identity \( 1 \);
- multiplication distributes over addition: \( a \cdot (b + c) = a \cdot b + a \cdot c \) for all \( a, b, c \in \mathbb{F} \).
The rationals \( \mathbb{Q} \), the reals \( \mathbb{R} \) and the complex numbers \( \mathbb{C} \) are fields. The integers are not, because 2 has no multiplicative inverse among them.
Quick summary
The ideas of this post, each with its running example.
| Idea | In one line | Example in this post | In ML |
|---|---|---|---|
| Group | transformations you can combine and undo | \( C_4 \), \( S_n \), 3D rotations (not abelian) | the symmetries of the data |
| Homomorphism | a map that respects the operation | \( C_4 \cong \mathbb{Z}_4 \); \( \psi : C_4 \to C_2 \) | representations on features |
| Action | how each element moves data | \( (g \cdot f)(x) = f(g^{-1} \cdot x) \); without the inverse, 18 of 36 pairs break | shifting images, relabelling atoms |
| Orbit | everywhere one point can be moved | 24 orderings of four readings | data augmentation |
| Invariant | output ignores the transformation | mean temperature | classification, readouts |
| Equivariant | output moves with the input | centering the readings | segmentation, hidden layers |
| Convolution | the only shift-equivariant linear map | \( n \) numbers instead of \( n^2 \) | weight sharing in CNNs |
Open questions
Questions I'm carrying into the next parts:
- How much does exactness matter? Real images have borders, and real CNNs subsample, so their shift equivariance is only approximate. When is approximate symmetry good enough, and when does the gap cause errors?
- What about continuous groups? Rotations by any angle form an infinite group, so the sum in a group convolution becomes an integral. The review mentions the Haar measure for this. What does it mean to integrate over a group?
- Who chooses the group? Building a symmetry into a model is a modelling assumption, and Part 1's guarantee needs that symmetry to be present in the data. How do practitioners decide, and what happens when they get it wrong?
Next, Part 3 adds the structures that measure: length, distance and angle. It opens with a puzzle that this post sets up. Under the usual pixel distance, an F moved three pixels to the right is farther from the original F than an E is. The fix uses the orbits from this post.
Code
All checks in this post, and Figs. 1 and 3, are in
math-gdl-02-groups.ipynb
(NumPy and Matplotlib; runs in seconds). Each demo ends with a short exercise, such as
breaking the symmetry of the kernel in Fig. 1 and predicting which assertion fails.
To skip the setup, open the
interactive playground.
It runs the same checks in your browser and adds controls for the exercises. You can
change a group's operation, drop the inverse from a group action, edit a convolution
kernel, or test the review's group convolution on \( S_3 \). The first load can take up to
half a minute while Python starts up. Its source is
math-gdl-02-groups-playground.py,
a marimo notebook.
Corrections are welcome at .
Previous: Part 1, Sets, Maps, and the Hypothesis Class. Next: Part 3, Length, Distance, and Angle. Series overview: Eight Puzzles That Helped Me Understand Geometric Deep Learning.
Citation
Cited as:
Pham, Anh-Duy. (Nov 2026). Groups, symmetry, and equivariance. Math for GDL, Part 2. https://www.adpham.de/blog/math-gdl-02-groups.html
Or
@article{pham2026mathgdl02,
title = "Groups, Symmetry, and Equivariance",
author = "Pham, Anh-Duy",
journal = "www.adpham.de",
year = "2026",
month = "Nov",
url = "https://www.adpham.de/blog/math-gdl-02-groups.html"
}
References
- Sáez de Ocáriz Borde, H. & Bronstein, M. M. “Mathematical Foundations of Geometric Deep Learning.” arXiv:2508.02723 (2025).
- Bronstein, M. M., Bruna, J., Cohen, T. & Veličković, P. “Geometric Deep Learning: Grids, Groups, Graphs, Geodesics, and Gauges.” arXiv:2104.13478 (2021).
- LeCun, Y., Boser, B., Denker, J. S., Henderson, D., Howard, R. E., Hubbard, W. & Jackel, L. D. “Backpropagation applied to handwritten zip code recognition.” Neural Computation 1(4), 541–551 (1989).
- Cohen, T. & Welling, M. “Group equivariant convolutional networks.” Proceedings of the 33rd International Conference on Machine Learning, PMLR 48, 2990–2999 (2016).
- Satorras, V. G., Hoogeboom, E. & Welling, M. “E(n) equivariant graph neural networks.” Proceedings of the 38th International Conference on Machine Learning, PMLR 139, 9323–9332 (2021).