Symmetry and Groups: Invariance, Equivariance, and Why You Build It In

6 minute read

Published:

TL;DR: A group acting on a space partitions it into orbits. A function is invariant when \(f(g\cdot x) = f(x)\) — constant on orbits. It is equivariant when \(f(g\cdot x) = \rho(g)\, f(x)\), where \(\rho\) is how the same group acts on the output space; invariance is the case \(\rho(g) = \mathrm{id}\). Convolution is translation equivariant, message passing is permutation equivariant, and a molecular energy model should be \(SE(3)\) invariant while its force predictions are \(SE(3)\) equivariant. Building the symmetry into the architecture makes it hold exactly and everywhere; augmentation only approximates it, near the data you have.

Groups, actions, orbits

A group $(G,\cdot)$ is a set with an associative operation, an identity $e$, and inverses. An action of $G$ on a set $X$ is a map $G\times X\to X$ with $e\cdot x = x$ and $(gh)\cdot x = g\cdot(h\cdot x)$ — the group’s structure is faithfully reflected in how it moves points.

The orbit of $x$ is \(\mathcal{O}_x = \\{g\cdot x : g\in G\\}\): everything reachable from $x$ by a symmetry. Orbits partition $X$, which gives the cleanest description of invariance — an invariant function is one that is constant on every orbit, i.e. a function on the quotient $X/G$ rather than on $X$.

The three groups worth knowing cold:

GroupActs onElements
$\mathbb{Z}^2$ (translations)image gridsinteger shifts
$S_n$ (permutations)node sets, setsrelabellings, $n!$ of them
$SE(3)$point clouds in $\mathbb{R}^3$rotation $R\in SO(3)$ plus translation $t$

The two definitions, precisely

Let $G$ act on the input space $X$ and on the output space $Y$. A map $f: X\to Y$ is

\[ \textbf{invariant:}\quad f(g\cdot x) = f(x)\quad \forall g\in G,\ \forall x\in X, \] \[ \textbf{equivariant:}\quad f(g\cdot x) = \rho(g)\, f(x)\quad \forall g\in G,\ \forall x\in X, \]

where $\rho$ is the action (a representation, when $Y$ is a vector space) of $G$ on $Y$. Equivariance says $f$ commutes with the symmetry: transform-then-predict equals predict-then-transform. Invariance is the special case $\rho(g)=\mathrm{id}$ for all $g$.

Commuting square defining equivarianceA square diagram with four corners. Top left is the input x, top right is f of x, reached by an arrow labelled f. Bottom left is g acting on x, reached from the top left by a downward arrow labelled "act with g". Bottom right is f of g acting on x, reached from the bottom left by another arrow labelled f, and also reached from the top right by a downward arrow labelled rho of g. Equivariance is the statement that both routes from top left to bottom right agree. A note says invariance is the case where rho of g is the identity, making the right-hand arrow do nothing. x f(x) g · x f(g · x) f f act with g ρ(g) invariance is this square with ρ(g) = id — the right-hand arrow does nothing
Notice that equivariance needs two actions, one per space. Saying a model "is equivariant" without naming the output action is an incomplete statement.

The three cases that come up

Translation in CNNs. For a signal $x:\mathbb{Z}^2\to\mathbb{R}$ and shift $(T_v x)(u) = x(u-v)$, cross-correlation with a kernel $\psi$ satisfies $(T_v x)\star\psi = T_v(x\star\psi)$. A convolution layer is translation equivariant: shift the input and the feature map shifts identically. Invariance appears only when you collapse the spatial axes — global pooling, or in practice the classifier head. In real networks the equivariance is approximate: striding and pooling alias, so it holds exactly only for shifts that are multiples of the stride, and padding breaks it at the borders.

Permutation in GNNs and set models. With node features $X\in\mathbb{R}^{n\times d}$, adjacency $A$, and a permutation matrix $P$, a message-passing layer $F$ satisfies

\[ F\!\left(PX,\, PAP^\top\right) = P\,F(X, A) \quad\text{(equivariant)},\qquad \rho\!\left(PX,\, PAP^\top\right) = \rho(X, A) \quad\text{(invariant readout)}. \]

Node-level predictions must be equivariant — relabel the nodes and the predictions come along. Graph-level predictions must be invariant, which is what the sum/mean/max readout provides. The same split governs Deep Sets and set transformers.

$SE(3)$ in molecular models. A potential energy is invariant, $E(Rx+t) = E(x)$, while forces are equivariant, $F(Rx+t) = R\,F(x)$ — a rotated molecule feels rotated forces. There is a neat consistency here: since $F = -\nabla_x E$, the gradient of an $SE(3)$-invariant scalar is automatically equivariant, so getting the energy right gets the forces right by construction. See the GNN book’s posts on equivariance, EGNN and SE(3) transformers for the architectures.

Key Insight — why constraints beat augmentation: an invariant model does not learn a function on \(X\), it learns one on the quotient \(X/G\). For a finite group acting freely that shrinks the effective input space by a factor of \(\lvert G\rvert\); for \(SE(3)\) it removes a six-dimensional family of variation per example. Augmentation attacks the same problem from the other side — it asks the model to discover the symmetry from samples, so the constraint holds only near the data, costs capacity that is spent memorising the group, and gives nothing on inputs far from the training distribution. Elesedy and Zaidi (2021) make the gap precise for linear models and group-averaged predictors: the equivariant model has strictly lower generalisation error, and the size of the improvement grows with the group.

The counter-argument is real too. A symmetry that is only approximately true in the data — near-symmetry, or a symmetry broken by context, like gravity breaking full rotational symmetry for a robot — is expensive to hard-code and can hurt. Constraints are priors: correct ones help, wrong ones bite.

Interview trap: two mistakes, both common. (1) Calling a convolution layer translation invariant. It is equivariant; invariance comes from pooling. (2) Making a network invariant too early. A segmentation head must be equivariant — an invariant intermediate representation has thrown away the position information the task needs. Ask what the output should do under the group before deciding which property you want.

Recap

  • An action satisfies \(e\cdot x = x\) and \((gh)\cdot x = g\cdot(h\cdot x)\); orbits partition the space, and invariant functions are exactly functions on the quotient.
  • Invariance: \(f(g\cdot x) = f(x)\). Equivariance: \(f(g\cdot x) = \rho(g)f(x)\). Invariance is equivariance with the trivial output representation.
  • Convolution is translation equivariant (approximately so under striding); message passing is permutation equivariant, with an invariant readout for graph-level tasks.
  • Molecular energies are \(SE(3)\) invariant, forces are \(SE(3)\) equivariant, and \(F = -\nabla E\) makes the second follow from the first.
  • Built-in symmetry holds exactly and everywhere; augmentation only approximates it near the training data and spends capacity doing so.

That closes the book — back to the overview for the map of all seven posts.

References

  1. Bronstein, M. M., Bruna, J., Cohen, T., & Veličković, P. Geometric Deep Learning: Grids, Groups, Graphs, Geodesics, and Gauges. arXiv:2104.13478, 2021.
  2. Cohen, T., & Welling, M. Group Equivariant Convolutional Networks. ICML 2016.
  3. Zaheer, M., Kottur, S., Ravanbakhsh, S., Poczos, B., Salakhutdinov, R., & Smola, A. Deep Sets. NeurIPS 2017.
  4. Satorras, V. G., Hoogeboom, E., & Welling, M. E(n) Equivariant Graph Neural Networks. ICML 2021.
  5. Elesedy, B., & Zaidi, S. Provably Strict Generalisation Benefit for Equivariant Models. ICML 2021.
  6. Zhang, R. Making Convolutional Networks Shift-Invariant Again. ICML 2019.