ES98E · Course contents

Part A · Lectures 5–8

5. Symmetry and graphs: learning without arbitrary labels

Rename the atoms in a molecule. Nothing physical has changed, yet the coordinate array has been reordered. Rotate the molecule, and its energy still should not change; its force vectors should rotate. A model that depends on arbitrary labels or laboratory orientation spends data learning relationships we already know.

These are architectural questions rather than optimisation questions. A dense layer from a 256×256256\times256 single-channel image to 1,000 hidden units has 65,536,000 weights before biases. It can learn spatial structure, but supplies neither locality nor translation symmetry by construction. An inductive bias restricts or favours functions according to relevant structure.

In this chapter: group actions, structured architectures, message passing, permutation proof.

The output need not transform like the input

Let a group element gg act on inputs by ρX(g)\rho_X(g) and outputs by ρY(g)\rho_Y(g). A map is equivariant if

f(ρX(g)x)=ρY(g)f(x).f(\rho_X(g)x)=\rho_Y(g)f(x).

It is invariant when the output action is the identity, so f(ρX(g)x)=f(x)f(\rho_X(g)x)=f(x). Distinct input and output actions are essential: positions, vectors, tensors and scalars transform differently. Invariance is not restricted to scalar-valued functions, and equivariance is not restricted to vectors.

For positions r=(r1,…,rN)r=(r_1,\ldots,r_N), a rigid transformation is ri↦Rri+ar_i\mapsto Rr_i+a, with orthogonal RR. Suppose a differentiable energy satisfies E(Rr+a)=E(r)E(Rr+a)=E(r). Applying the chain rule gives

RT∇ri′E(r′)=∇riE(r),Fi(r′)=RFi(r),Fi=−∇riE.R^T\nabla_{r_i'}E(r')=\nabla_{r_i}E(r),\qquad F_i(r')=RF_i(r),\quad F_i=-\nabla_{r_i}E.

Forces rotate, but a pure translation leaves their vector components unchanged. They do not acquire the positional offset aa. This corrects the source's ambiguous statement that forces are “equivariant to translation” under the same action as positions. Translation invariance also implies ∑iFi=0\sum_iF_i=0 by differentiating E(r1+a,…,rN+a)E(r_1+a,\ldots,r_N+a) with respect to aa.

The distinction is visible in a small spring configuration. Rotate the positions and compare the transported force arrows with forces recomputed from the rotated geometry. Translation moves the configuration but contributes no offset to the force vectors.

Rotate the configuration, carry the forces

E(Rr + a) = E(r) · F(Rr + a) = RF(r)

-2.22.22.2-2.2position xposition y (equal units)123

energy = 0.55630|ΣF| = 0.00000000

Three particles interact through unit-stiffness pair springs with rest length 1.05. Rotate and translate the positions while their force arrows rotate without acquiring a translation. The dashed configuration is the original; energy and total force are recomputed from the transformed positions. Force arrows use the same fixed magnification throughout. This is a spring model, not a molecular benchmark. ↗

Pairwise distances and angles give rotation/translation-invariant scalar inputs. They do not automatically remove ordering dependence or guarantee a complete geometric representation; distances also identify mirror-related configurations. Whether reflections should be a symmetry depends on the target. Invariant energy models yield equivariant conservative forces by differentiation, assuming sufficient smoothness. Architectures with equivariant internal tensor features can retain directional information before forming an invariant energy.

Data augmentation exposes the model to transformed inputs, but does not generally enforce exact symmetry. An architecture enforces a symmetry only when every operation, feature and readout respects the required action. Claims about exact physical behaviour must therefore include the full computation, not just one equivariant layer.

Different structures call for different sharing rules

A convolution applies the same local filter at each location. On an ideal translation-compatible domain this is translation equivariant; finite padding, strides, pooling and boundaries can restrict the exact symmetry. Pooling can reduce spatial resolution and support approximate invariance, but invariance is not a universal property of a CNN. U-Net combines resolutions for spatially resolved predictions such as segmentation.

Residual networks, introduced in the previous chapter, share an identity route across depth. Their purpose is to ease learning changes to a representation; they can be combined with convolution or graph operations.

Self-attention instead computes data-dependent interactions between elements. Without positional encodings or order-dependent masks, ordinary self-attention is permutation equivariant. Positional information and causal masks change this statement; sequence transformers are not automatically permutation equivariant once their complete inputs and masks are fixed. Attention can model long-range relationships at the cost of pairwise interactions.

Graphs specify which elements should communicate. Molecules, meshes and networks have variable size and no privileged node ordering. A graph neural network shares its local update rule across nodes, allowing a single parameter set to operate on different graph sizes.

A local update that can travel

For clarity, use an undirected graph with symmetric adjacency A∈{0,1}N×NA\in\{0,1\}^{N\times N}. Let Hk∈Rdk×NH_k\in\mathbb R^{d_k\times N} contain node embeddings as columns, and hk(n)h_k^{(n)} denote column nn. Atomic species can be encoded by one-hot features (the source uses 118 element categories); geometry requires additional information such as distances or directional features. A simple source-style update is

hk+1(n)=ϕ ⁣(bk+Wk[hk(n)+∑m∈N(n)hk(m)]),h_{k+1}^{(n)}=\phi\!\left(b_k+W_k\left[h_k^{(n)}+\sum_{m\in\mathcal N(n)}h_k^{(m)}\right]\right), Hk+1=ϕ ⁣(bk1T+WkHk(A+I)).H_{k+1}=\phi\!\left(b_k\mathbf1^T+W_kH_k(A+I)\right).

The weights apply to both the node itself and its neighbour sum. Shared parameters and commutative aggregation are what remove dependence on neighbour order. After KK layers, each embedding can depend on its KK-hop neighbourhood. Powers of an unweighted adjacency count walks of corresponding length, explaining how repeated propagation carries information, though nonlinear learned updates are not simply powers of AA.

Consider the path graph with three scalar node features (1,2,4)(1,2,4) and take W=1W=1, b=0b=0, identity activation. The update yields (3,7,6)(3,7,6). Change the labels and follow the same update: the values should move with their nodes, without changing the graph's aggregate.

Messages follow edges, not array positions
Original storage order1→ 32→ 74→ 6self + neighbours → mean = 16/3Reverse storage order4→ 62→ 71→ 3self + neighbours → mean = 16/3
Exact linear message passing on a three-node undirected path: add the node's value and its neighbours' values. Relabelling reverses the storage order. Updated values reverse from (3,7,6) to (6,7,3), while their mean stays 16/3. This teaching example has no trained parameters. ↗

Degree matters: an unnormalised sum can grow with the number of neighbours. A commonly used GCN replaces A+IA+I by D~−1/2(A+I)D~−1/2\tilde D^{-1/2}(A+I)\tilde D^{-1/2}, with D~\tilde D its degree matrix. The Kipf–Welling GCN uses such a normalised propagation. More general message-passing layers use separate self and neighbour weights, learned messages and edge features. For a directed graph with “receiver, sender” adjacency, the column convention above needs ATA^T on the right; the undirected assumption is doing real work here.

Now give one node a signal and watch it spread over several layers. This example uses a self-plus-neighbour average so magnitudes remain bounded. Reverse the storage order at any stage: the features travel with their nodes, and the commutative graph readout remains the same.

Information travels one edge at a time

hnext(n) = mean{ h(n), h(m) : m ∈ neighbours(n) }

Layer 0 → 11.000node 10.000node 20.000node 30.000node 40.000node 5weighted messages → updated node features

completed layers = 0next-layer mean = 0.1667

A signal starts at one end of a five-node path. Each layer averages the node and its neighbours; moving beads show the weighted messages before the next update. Scrub between layers to see the growing receptive field. Reversing storage order carries the node features with it and preserves the graph readout. Interpolated transitions are visual aids, not extra network layers. ↗

Why the symmetry survives every layer

Let PP be a permutation matrix. Relabelling gives Hk′=HkPH_k'=H_kP and A′=PTAPA'=P^TAP. Since PPT=IPP^T=I, 1TP=1T\mathbf1^TP=\mathbf1^T, and elementwise activation commutes with column permutation,

Hk+1′=ϕ ⁣(bk1T+WkHkP(PTAP+I))=ϕ ⁣((bk1T+WkHk(A+I))P)=Hk+1P.\begin{aligned} H_{k+1}' &=\phi\!\left(b_k\mathbf1^T+W_kH_kP(P^TAP+I)\right)\\ &=\phi\!\left((b_k\mathbf1^T+W_kH_k(A+I))P\right) =H_{k+1}P. \end{aligned}

Induction proves node-level equivariance for the whole stack. Mean pooling hG=N−1HK1h_G=N^{-1}H_K\mathbf1 is invariant because P1=1P\mathbf1=\mathbf1. A final map can produce a scalar regression output or softmax class probabilities. Sum pooling is also invariant and often more appropriate for extensive quantities such as total energy; mean pooling can erase graph-size information. Neither choice alone guarantees generalisation to unseen graph sizes or compositions.

The source reports an ethanol relabelling test and application to propanol. Those are useful implementation checks, not substitutes for the proof or evidence of arbitrary molecular transfer. Plain connectivity and atomic numbers also omit geometry; predicting geometrically dependent energy requires suitable geometric features or equivariant representations. Repeated aggregation can blur node distinctions, and limited neighbourhoods may miss long-range interactions.

Architectural symmetry is one way to supply scientific knowledge. The next chapter supplies a different kind: a differential equation that the prediction should satisfy.