Structured matrices in ML for science: circulants and FNO, spectral graphs and GNNs, equivariance, matrix manifolds
Before this lesson: lesson 02 (the incidence matrix), lesson 04 (the DFT is unitary), lesson 06 (spectral theorem, Rayleigh quotient) and lesson 08 (SVD and polar decomposition). Time: about 90 minutes, plus the notebook.
Why this matters #
Physical laws do not change when you shift, rotate or relabel the system. Such a symmetry is a group of matrices acting on the data, and a layer that respects it is equivariant. One fact connects the main architectures of ML for science: matrices that commute share eigenvectors. For shifts these are Fourier modes: CNNs and Fourier neural operators (FNOs). For graphs they are Laplacian eigenvectors: spectral GNNs such as GCN. Rotations give E(3)-equivariant interatomic potentials (NequIP, MACE). Orthogonality constraints and subspaces live on the Stiefel and Grassmann manifolds: PCA, orthogonal layers, Muon.
1. Predict first #
2. The picture #
The simplest case, . The cyclic shift maps to , and . Take a "wave" with . Then : shifting a wave only multiplies it by a phase. There are three such waves, for the three cube roots of unity, with three different eigenvalues .
Now take any linear filter that does not care where the signal sits: . Then , so is again an eigenvector of for the same eigenvalue. Each eigenspace of is a line, so must be a multiple of . A shift-invariant filter can only scale each wave: it is diagonal in the Fourier basis. This is the convolution theorem.
A computation by hand, . Take the filter with first column : each output is twice the sample plus its two neighbors, with wrap-around. Its matrix has entry in row , column (indices mod 4), so each row is the row above, shifted one place to the right:
For , , and the first Fourier wave is . Multiply row by row:
- Row 0: .
- Row 1: .
- Row 2: .
- Row 3: .
So : the same wave, scaled by 2. Theorem 1 below predicts the scale without any multiplication: . All four eigenvalues are .
Pick a kernel, then move the mode . The heatmap is the circulant built from the first column ; hover over a cell to see that is constant along each wrapped diagonal. The blue dots are a Fourier mode (real part), the violet squares are , computed as a matrix–vector product. They always form the same wave, only scaled by and shifted in phase: , with . Try "shift P": all eigenvalues lie on the unit circle. Try "difference": is not symmetric, so most eigenvalues are complex.
You change the kernel of a circular convolution on signals of length 8 from "blur" to "difference". What happens to the eigenvectors of its matrix?
Every circular convolution is a circulant, and every circulant has the Fourier vectors as eigenvectors (Theorem 1). The kernel decides only the eigenvalues . A non-symmetric kernel gives complex eigenvalues, but the matrix is still diagonalized by the DFT.
Graphs. Replace the cycle by any graph, and the shift by the graph Laplacian . The eigenvectors of play the role of waves: small eigenvalues belong to signals that are smooth over the graph, large ones to signals that oscillate between neighbors.
Colour the graph by an eigenvector of . Nodes are orange where and blue where . For (the Fiedler vector) the signs cut the two clusters apart along the single bridge. Click the bridge to remove it: a second eigenvalue drops to 0, one per connected component. Raise and the vector changes sign more often. "Signal kept on " projects a noisy signal onto the smoothest eigenvectors: a low-pass filter on the graph. Try the karate club: the Fiedler vector almost predicts how the club split in 1977.
Equivariance is the same commuting property for any symmetry: transform the input and then apply the layer, or apply the layer and then transform the output; both give the same result.
Follow both paths around the square. Right, then down: (dashed outlines). Down, then right: (filled bars). The layer is equivariant when they match, and the relative error is then 0 or at round-off level. Compare circular and zero-padded convolution, a convolution that also sees the position, and a dense layer. Then switch to "relabel graph nodes": a GCN layer passes the test only if the adjacency matrix is relabeled together with the features.
Manifolds. A unit vector in lives on a sphere, a curved set. A frame of orthonormal vectors lives on the Stiefel manifold. If only their span matters, it lives on the Grassmann manifold. Section 3 shows how to take a gradient step on a sphere and stay on it.
3. Definitions and main results #
Circulant matrices and the DFT #
Indices run from to and are taken mod . The cyclic shift is . The circulant with first column is
the circular convolution of and . For : . The DFT (lesson 04) uses and , so and . The Fourier vector has entries ; it is column of .
Theorem 1 (circulants are diagonalized by the DFT). for . Hence and , which costs with the FFT.
Proof.
- . The wrap-around index is fine because . So .
- Repeating, .
- .
- Put the equations side by side as columns: . Since , .
Theorem 2 (shift-equivariant linear maps are circulants). if and only if is circulant.
Proof.
- , because moves row to row .
- , because exactly when .
- So means for all , that is, : the entries are constant along the wrapped diagonals. Then depends only on : is circulant.
- Conversely, a circulant is a polynomial in , so it commutes with .
Consequences:
- The eigenvalues are the frequency response of the filter. For real , ; for symmetric () they are real.
- All circulants share one eigenbasis, so they commute with each other.
- A 2-D periodic convolution is a block-circulant matrix with circulant blocks. The 2-D DFT, (lesson 16), diagonalizes it.
- Deep-learning "convolution" is cross-correlation (a flipped kernel, still circulant). Zero padding gives a Toeplitz matrix, not a circulant, so shift equivariance fails near the borders. Strides and pooling also break exact equivariance.
The Fourier layer of an FNO #
The FNO Fourier layer (Li et al. 2021). A function on a periodic grid with points and channels is . One layer computes , with acting pointwise and
where is mode of all channels and is learned. Read it with Theorem 1:
- For one channel (), is exactly a circulant with eigenvalue on the kept
modes (and on the mirror modes , so a real input gives a real output;
rfftandirfftdo this for you) and on the others: a learned global convolution that is also a low-pass filter. Its kernel spreads over the whole domain, so one layer has a global receptive field. - With channels, is a block matrix of circulants, one per pair of channels.
- Parameters: complex numbers per layer in 1-D (one per kept mode), independent of . The paper uses 4 layers, , in 1-D. Cost: the FFTs, , plus for the mixing.
- Discretization invariance: lives on frequencies, not on grid points. On any uniform grid with that resolves the input, the layer computes the same function. This is why an FNO trained at one resolution can be evaluated at another.
- Shift equivariance: , and all commute with cyclic shifts of the grid. The reference code appends the grid coordinates as extra input channels, which breaks this on purpose.
One Fourier layer with one channel. Move : the layer keeps the blue modes, drops the grey ones and multiplies mode by . Then change the grid size : the violet dots (the output on your grid) stay on the violet curve (the same layer on a 1024-point grid), because belongs to frequencies, not to grid points. Choose "smooth + high modes" with to see the limit: modes above alias onto the kept modes and the output changes. With "step", the truncation gives the Gibbs ripples.
Why the grid does not matter, and when it does (aliasing)
Sample a periodic function on uniform points . The forward DFT of the samples grows like (it is a sum of terms) and the inverse DFT divides by , so the factors cancel: the layer works with the Fourier coefficients of the function, not of the grid. If has no modes above , these sums are exact, and every such grid gives the same and the same output.
If has a mode , the samples cannot tell it apart from the mode (or ): at every grid point. This is aliasing. The high mode is added to a low coefficient, the kept coefficients change a little, and the agreement between grids becomes approximate. FNOs on non-uniform meshes need another transform (for example the geometry-aware variants), because the FFT needs a uniform grid.
A 1-D FNO layer with and is trained on a grid of 256 points. How many complex weights does its Fourier part have when you evaluate it on a grid of 1024 points?
There is one matrix per kept mode , so complex numbers. They belong to frequencies, not to grid points, so the count does not depend on . This is why the same weights can be used on any grid that has at least modes.
The graph Laplacian #
A graph has nodes and symmetric weights ( exactly when and are joined). The degrees are , , and the Laplacian is . For an unweighted graph, with the incidence matrix of lesson 02. Its quadratic form measures how much a signal varies across edges:
Theorem 3 (what the eigenvalues say). Sort the eigenvalues upward, (lesson 06 called them ). Then: (a) and , so ; (b) the multiplicity of equals the number of connected components; (c) , and exactly when the graph is connected; (d) .
Proof.
- (a) The quadratic form is a sum of non-negative terms. .
- (b) Since , on every edge is constant on each component. The indicator vectors of the components are independent and span this null space.
- (c) Courant–Fischer (lesson 06) with the first eigenvector . By (b), exactly when there are at least two components.
- (d) . Summing over the edges, .
How to read the spectrum:
- The eigenvector has variation : small = smooth over the graph, large = oscillating. is the graph Fourier transform.
- On the cycle graph, is the circulant with : its eigenvalues are and its eigenvectors are Fourier modes. On a cycle, graph Fourier = DFT.
- The minimizer in (c) is the Fiedler vector. Its signs split the graph in two (spectral bisection); the first eigenvectors give spectral clustering. A small means a bottleneck. Cheeger's inequality makes this precise for the normalized Laplacian (next item): with , where the conductance is the smallest ratio of cut weight to the degree sum of the smaller side.
- The normalized Laplacian (all ) has eigenvalues in , with exactly when a component is bipartite.
From a spectral filter to the GCN layer #
Theorem 4 (the GCN propagation rule; Kipf and Welling 2017, §2). Let . The GCN layer is the end of six steps. Each step makes one approximation or one change; the "Changes" line says what it buys and what it costs.
- Spectral filter. Filter a signal by . Changes: nothing yet. This is the exact graph analogue of a convolution, but it needs the eigendecomposition () and dense products (), and the filter is not local.
- Polynomial filter (ChebNet). Take with Chebyshev polynomials and . Because , this is with . Changes: no eigenvectors are needed; only nodes at most hops apart interact; the cost is ; the filter has parameters.
- First order. Take and (its upper bound). Then and . Changes: each layer sees only direct neighbors; a wider view comes from stacking layers.
- One parameter. Set : . Changes: fewer parameters (less overfitting). But has eigenvalues in , so stacking layers can multiply a signal by up to : signals and gradients explode or vanish.
- Renormalization trick. Replace by with (self-loops) and . Changes: the eigenvalues move into (proof below), so repeated layers are stable.
- Channels. For node features and weights : , at cost . Changes: input channels and filters; the same is shared by all nodes.
Choose a propagation matrix, then add layers. The blue curve is the response after layers; the orange dots are the eigenvalues of the chosen graph (the violet dot has the largest ). With "2I − L_sym" (step 4) the eigenvalue 2 at makes the response grow like . With "I − L_sym" a bipartite graph (path, ring, star) has , which never decays. With the renormalized (step 5) every other eigenvalue shrinks to 0 as grows: only the top eigenvector survives. This is over-smoothing.
A 3-node example. The path 1–2–3 has degrees .
- has eigenvalues (the path is bipartite, so 2 appears).
- Step 4: has eigenvalues . Ten layers on give : the signal exploded.
- Step 5: with self-loops, and :
- One layer on : . The feature moved one hop.
- Twenty layers: . This is the projection of onto the top eigenvector , which is . The other parts decayed like and .
Why step 5 works: the eigenvalues of lie in .
- , so : every eigenvalue is .
- gives : the eigenvalue 1 is attained.
- , because : every eigenvalue is .
Over-smoothing. Applying many times is power iteration (lesson 05). On a connected graph, converges to the projection of onto : every node's feature becomes proportional to , and deep GCNs without residual connections lose the difference between nodes.
Permutation equivariance. Relabeling the nodes with a permutation matrix maps and . Then , , and , because and acts entrywise.
Equivariance #
A group is a set of transformations that is closed under composition and inverses: shifts, permutations, rotations. A representation gives each an invertible matrix with .
Definition. A map is equivariant if for all and all inputs , where acts on inputs and on outputs. It is invariant if .
| Data | Group | on the input | on the output | Equivariant layers |
|---|---|---|---|---|
| periodic signal | cyclic shifts | circulant convolution, FNO layer | ||
| graph , | permutations | (node outputs); (graph outputs) | GCN, message passing, DeepSets | |
| atoms (one row per atom) | E(3): , | forces ; energy unchanged | EGNN, NequIP, MACE | |
| wind field on the sphere | rotations SO(3) | rotate the positions and the vectors | the same | spherical CNNs, SFNO |
Theorem 5 (equivariant linear maps form a subspace). A linear map is equivariant if and only if for all . It suffices to check a set of generators of . With vec and Kronecker products (lesson 16), the conditions read : the equivariant layers are a null space.
Proof of Theorem 5
- Equivariance as a matrix equation. For , equivariance says for all . Two matrices that agree on every are equal: . The converse is the same line read backwards.
- Products. If the equation holds for and , then .
- Inverses. Multiply by on the left and by on the right: , that is, .
- Every element of is a product of generators and their inverses, so by steps 2 and 3 the generators suffice.
- Vec form. The identity (lesson 16) gives and . So each condition is one homogeneous linear equation in , and the solutions of a set of such equations form a null space.
Example (DeepSets, Zaheer et al. 2017). For permutations acting on , the equivariant linear maps are exactly .
- for every permutation means for all .
- A permutation can move any diagonal position to any other : all diagonal entries are equal.
- It can move any off-diagonal position , , to any other , : all off-diagonal entries are equal.
- So ; conversely, shows that it commutes with every .
Two parameters instead of . With input and output channels, (): parameters.
A self-attention layer without positional encodings maps the token matrix (one row per token) to , with the softmax taken row by row. You permute the tokens: . What happens to the output?
The score matrix becomes . A row-wise softmax commutes with permuting rows and columns together, so the weights become , and then . This is why transformers need positional encodings to know the order of tokens.
An invariant energy gives equivariant forces. If for all and , then the forces satisfy .
- Let , so .
- Chain rule: .
- The left side equals , since for all . Multiply by on the right: .
This is why machine-learned interatomic potentials predict an invariant energy and get the forces by autodiff.
Building E(3)-equivariant layers. Distances are invariant. Relative vectors rotate with and ignore . So is equivariant for any scalar function ; this is the coordinate update of EGNN (Satorras et al. 2021). Richer features (spherical harmonics of degree , the irreducible representations of SO(3), combined with Clebsch–Gordan coefficients) are the language of e3nn, NequIP and MACE.
How to test equivariance numerically.
- Draw random inputs and random group elements : shifts; permutations; (for
example
scipy.stats.ortho_group) and . - Compute the relative error .
- An exactly equivariant layer gives at round-off level ( in float64, in float32) in every trial. Cover the generators, and for O(3) both and .
- Run the same test on a layer that is not equivariant and check that : the test must be able to fail.
- An approximately equivariant layer (zero padding under shifts, a CNN under 45° rotations of a pixel grid) gives a small that is far above round-off. Report it; do not call it equivariant.
Matrix manifolds: Stiefel and Grassmann #
The sphere first (). The set of unit vectors is a sphere. Suppose we want to minimize a function over it, for example (its minimizer is the top eigenvector of , lesson 06). A plain gradient step leaves the sphere. Riemannian gradient descent fixes this in three steps:
- Tangent plane. Differentiate at : . So the directions in which we can move without leaving the sphere (to first order) are , the plane perpendicular to .
- Project the gradient. Remove the part of along : . Then .
- Step, then retract. The step is perpendicular to , so : the point is off the sphere. Divide by its length: .
Take steps on the sphere. At the black point the grey arrow is the gradient of , . The blue arrow lies in the aqua tangent plane. The orange step ends at , slightly outside the sphere; the violet point is the retraction . Press Take one step a few times: moves to the minimizer , the top eigenvector of . Drag to rotate the view.
The Stiefel manifold. The same three steps work for orthonormal columns. The Stiefel manifold is , . For it is the unit sphere; for it is the orthogonal group .
- Dimension : entries, minus independent equations in the symmetric matrix equation . For : , the dimension of a sphere in .
- Tangent space. Differentiate : , so is skew-symmetric.
- Riemannian gradient. Project the Euclidean gradient onto : , with . For , is a number and this is the formula of step 2.
- Retraction (a smooth way back to the manifold). QR retraction: the Q factor of (with a positive diagonal in R). Polar retraction: , where is a thin SVD; it is the closest point of to in the Frobenius norm. For both are "divide by the length".
- One step of Riemannian gradient descent: .
For , the polar factor is orthogonal but not always a rotation: it contains a reflection when (see the box "orthogonal does not mean rotation" in lesson 04).
What is the dimension of , and what is its tangent space at a point ?
is the unit sphere in , a surface: . Differentiating gives , so the tangent space is the plane perpendicular to . The line through is exactly the direction you must remove from the gradient.
The Grassmann manifold is the set of -dimensional subspaces of . The frames and () span the same subspace, so .
- A unique representative of the subspace is the orthogonal projector .
- Dimension : the Stiefel dimension minus .
- is a function on when for all .
- Two subspaces are compared through their principal angles (lesson 17), not through their bases.
One ML use of each:
- Stiefel: orthonormal weights. All singular values equal 1, so the layer keeps norms and is 1-Lipschitz (orthogonal RNNs, orthogonal initialization).
- Grassmann: PCA. The objective over does not change under , so PCA is a problem on : the objective finds the top- subspace. The individual principal directions inside it come from the eigenvectors of , and they are unique (up to sign) only when the eigenvalues are distinct (Boumal §2.4).
Grassmann distances, LoRA subspaces and Muon
- Distances. For orthonormal bases of two subspaces, the principal angles satisfy . The geodesic distance on is ; the projection distance is , the of Davis–Kahan (lesson 17).
- Comparing learned subspaces. The LoRA paper (§7.2) compares learned update subspaces with the Grassmann-based similarity ; climate scientists compare the EOF subspaces of two models by principal angles.
- Muon (2024) replaces each momentum update by an approximation of its polar factor (a few Newton–Schulz steps): the nearest point of the Stiefel manifold to , so every direction of the update gets the same size. "Manifold Muon" (Bernstein, 2025) keeps the weights themselves on the Stiefel manifold.
Answers to section 1. (1) Yes: the Fourier vectors . A circularly padded convolution commutes with the shift, so it is a circulant (Theorem 2), and Theorem 1 applies; the kernel only decides the eigenvalues . (2) Three, by Theorem 3(b).
4. Worked example #
(a) The 4-cycle is a circulant. Nodes 1–2–3–4–1. Its Laplacian has first column . With : , so for the eigenvalues are .
- with : one component.
- with : the bound of Theorem 3(d) is reached (the cycle is bipartite).
- twice, with . Real versions: and , the slowest waves around the cycle. Any combination is a Fiedler vector: it is not unique.
(b) Cut one edge. Remove the edge 4–1 to get the path 1–2–3–4. It is no longer a circulant. Its eigenvalues are : , , , . The Fiedler vector splits , the cut in the middle. drops from 2 to 0.586: the path is easier to cut. Since with , we have , so no eigenvalue can go up (lesson 07): , , , . ✓
What are the eigenvalues of the Laplacian of the path on 3 nodes (1–2–3)?
. gives 0 (one component, so only one zero). gives : eigenvalue 1. The trace is , so the last eigenvalue is , with eigenvector . The values belong to the normalized Laplacian : do not mix the two.
(c) One GCN step on the path. With self-loops, and :
- A feature on node 1 only, : . It moved one hop.
- Eigenvalues: , , , , all in . Without the trick, has eigenvalues .
- Over-smoothing: . This is almost the projection of onto , which is . The rest decays like . After 20 layers the network cannot tell where the feature started.
(d) Stiefel and Grassmann. and in : , so the principal angles are and , and . has dimension and has dimension (a plane through 0 in is fixed by its normal direction).
5. In code #
NumPy and SciPy check the worked example and the main theorems. The notebook for this lesson has these cells and the exercises.
import numpy as np
from scipy.linalg import circulant, subspace_angles
from scipy.sparse.csgraph import laplacian
from scipy.stats import ortho_group
rng = np.random.default_rng(0)
# 1) A circulant matrix is diagonalized by the DFT; its eigenvalues are fft(c).
c = np.array([2.0, -1.0, 0.0, -1.0]) # first column: Laplacian of the 4-cycle
C = circulant(c)
F = np.fft.fft(np.eye(4)) # DFT matrix, F[k, j] = exp(-2 pi i jk / 4)
print(np.fft.fft(c).real) # [0. 2. 4. 2.]
print(np.allclose(C, np.linalg.inv(F) @ np.diag(np.fft.fft(c)) @ F)) # True
x = rng.standard_normal(4)
print(np.allclose(C @ x, np.fft.ifft(np.fft.fft(c) * np.fft.fft(x)).real)) # True
P = circulant([0.0, 1.0, 0.0, 0.0]) # cyclic shift, (Px)_j = x_{j-1}
print(np.allclose(C @ P, P @ C)) # True
# 2) Laplacians of the 4-cycle and of the path (the cycle without edge 4-1).
A_cyc = circulant([0.0, 1.0, 0.0, 1.0])
A_path = A_cyc.copy()
A_path[0, 3] = A_path[3, 0] = 0.0
print(np.linalg.eigvalsh(laplacian(A_cyc)).round(3) + 0.0) # [0. 2. 2. 4.]
print(np.linalg.eigvalsh(laplacian(A_cyc, normed=True)).round(3) + 0.0) # [0. 1. 1. 2.]
lam, U = np.linalg.eigh(laplacian(A_path))
print(lam.round(3) + 0.0, U[:, 1].round(3)) # [0. 0.586 2. 3.414], Fiedler (up to sign)
Pi = np.eye(4)[[2, 0, 3, 1]] # relabel the nodes
print(np.allclose(laplacian(Pi @ A_path @ Pi.T), Pi @ laplacian(A_path) @ Pi.T)) # True
# 3) Equivariance test under E(3): X (N atoms x 3) -> X Q^T + t.
def rel_err(f, X, act_in, act_out):
return np.linalg.norm(f(act_in(X)) - act_out(f(X))) / np.linalg.norm(f(X))
def vector_layer(X): # f_i = sum_j exp(-r_ij^2) (x_i - x_j)
D = X[:, None, :] - X[None, :, :]
r2 = (D**2).sum(axis=-1, keepdims=True)
return (np.exp(-r2) * D).sum(axis=1)
W1, W2 = rng.standard_normal((3, 16)), rng.standard_normal((16, 3))
mlp = lambda X: np.tanh(X @ W1) @ W2 # a plain MLP on raw coordinates
X = rng.standard_normal((10, 3))
for _ in range(3):
Q = ortho_group.rvs(3, random_state=rng) # random orthogonal: det +1 or -1
t = rng.standard_normal(3)
print(round(np.linalg.det(Q)),
rel_err(vector_layer, X, lambda Y: Y @ Q.T + t, lambda Y: Y @ Q.T), # ~5e-16
rel_err(mlp, X, lambda Y: Y @ Q.T, lambda Y: Y @ Q.T)) # ~1: fails
# 4) Shift test of a 1-D convolution: circular padding is exact, zero padding is not.
k = rng.standard_normal(5) # kernel taps for offsets -2..2
u = rng.standard_normal(64)
c64 = np.zeros(64); c64[:3] = k[2:]; c64[-2:] = k[:2] # the same kernel as a circulant
conv_circular = lambda x: np.fft.ifft(np.fft.fft(c64) * np.fft.fft(x)).real
conv_zeros = lambda x: np.convolve(x, k, mode="same") # zero padding at both ends
for name, conv in [("circular", conv_circular), ("zeros", conv_zeros)]:
e = np.linalg.norm(conv(np.roll(u, 3)) - np.roll(conv(u), 3)) / np.linalg.norm(conv(u))
print(name, e) # circular ~2e-16, zeros ~0.16
# 5) Stiefel St(6, 2): tangent projection and polar retraction; Grassmann angles.
X = np.linalg.qr(rng.standard_normal((6, 2)))[0]
G = rng.standard_normal((6, 2)) # a Euclidean gradient
xi = G - X @ (X.T @ G + G.T @ X) / 2 # projection onto the tangent space
print(np.abs(X.T @ xi + xi.T @ X).max()) # ~3e-16: xi is tangent
Ur, _, Vrt = np.linalg.svd(X - 0.1 * xi, full_matrices=False)
Y = Ur @ Vrt # polar retraction of a gradient step
print(np.abs(Y.T @ Y - np.eye(2)).max()) # ~4e-16: back on St(6, 2)
Xg = np.eye(3)[:, :2]
Yg = np.column_stack([[1, 0, 0], np.array([0, 1, 1]) / np.sqrt(2)])
print(np.degrees(subspace_angles(Xg, Yg))) # [45. 0.]
print(np.linalg.norm(Xg @ Xg.T - Yg @ Yg.T)) # 1.0 = sqrt(2) * sin(45 deg)
The equivariance test in part 3 passes for too, because distances and relative vectors do not care about orientation. In part 4 the zero-padded layer misses by about 16%: the error comes only from the two borders, where zero padding replaces the wrapped values.
6. Where it shows up #
- Weather and climate. FourCastNet (Pathak et al. 2022) mixes tokens with learned Fourier-domain filters (AFNO). Spherical FNOs (Bonev et al. 2023) replace the DFT by the spherical harmonic transform: spherical harmonics are the eigenfunctions of the Laplacian on the sphere. GraphCast (Lam et al. 2023) is a message-passing GNN on an icosahedral mesh.
- PDE surrogates. FNOs for Navier–Stokes and Darcy flow; MeshGraphNets on simulation meshes.
- Sensor and station networks. Spectral clustering with the first eigenvectors of ; smoothness penalties ; graph diffusion (lesson 16).
- Molecules and materials. NequIP and MACE predict an invariant energy and take forces as .
7. Common mistakes #
- Mixing DFT conventions. In NumPy's convention the eigenvalues are
fftof the first column. The first row gives instead (conjugates for real ). - Calling a zero-padded or strided CNN exactly shift equivariant. Zero padding gives a Toeplitz matrix, and the error at the borders is real. Strides and pooling break exact equivariance too.
- Thinking an FNO works on any grid. It needs a uniform grid with at least the modes, and fine enough for the input; on a coarser grid the input aliases.
- Mixing Laplacians. has eigenvalues up to ; has them in .
- Expecting a unique Fiedler vector. With a repeated (the 4-cycle) every vector in the eigenspace is a minimizer.
- Weak equivariance tests: one input only, only , no failing baseline.
- Taking a plain gradient step on a manifold. leaves : project the gradient onto the tangent space and retract.
- Comparing subspaces through their bases. and are different Stiefel points but the same subspace: compare or the principal angles.
8. Check yourself #
- Give the eigenvalues and the determinant of the circulant with first column .
Answer
. with : , , and . . - A 1-D FNO layer has and . How many parameters are in ? Does
the number change between a grid of 1024 and 8192 points?
Answer
complex numbers (131,072 real), plus for . No: the parameters belong to Fourier modes, not to grid points. - An unweighted graph on 5 nodes has Laplacian eigenvalues . How many components?
How many edges? What can you say about the largest degree?
Answer
Two zero eigenvalues: two components, so it is not connected (). The eigenvalues sum to : three edges. gives , so some node has degree at least 2. (Example: a path on 3 nodes, eigenvalues , plus a separate edge, eigenvalues .) - How many parameters does the most general permutation-equivariant linear layer
have? Why?
Answer
Two: . for all permutations forces all diagonal entries to be equal and all off-diagonal entries to be equal. With input and output channels: . - Your force model passes the rotation test ( in float32) but gives for
with . What does this mean?
Answer
It is SO(3)- but not O(3)-equivariant: it uses orientation (for example a cross product or chirality-aware features). That is correct if mirror images may behave differently (chiral molecules), and a bug if the target is mirror symmetric. - Give and . Why is a function on the Grassmann manifold?
Answer
and . for (cyclic trace): it depends only on the subspace.
Give the eigenvalues and eigenvectors of the circulant with first column .
Eigenvalues ; eigenvectors the Fourier vectors .
Which linear maps commute with the cyclic shift ?
Exactly the circulant matrices, that is, the circular convolutions.
What does one FNO Fourier layer compute (one channel)?
FFT, keep the lowest modes and multiply mode by a learned , inverse FFT: a learned global circular convolution that is also a low-pass filter.
Define the graph Laplacian and its quadratic form.
, and .
What does the number of zero eigenvalues of tell you, and why?
The number of connected components: exactly when is constant on each component.
What is the Fiedler vector, and what is it used for?
The eigenvector of . Its signs split the graph in two (spectral bisection).
Write the GCN propagation rule.
with and .
Define an equivariant map, and an invariant one.
Equivariant: for all and . Invariant: the same with .
What is the Stiefel manifold , and what is its dimension?
, of dimension .
How is the Grassmann manifold built from the Stiefel manifold, and what is its dimension?
: frames with the same span are the same point. Dimension .
9. Interview angle #
- "Why is convolution diagonal in Fourier space?" — It commutes with the shift; the shift has the Fourier vectors as eigenvectors with distinct eigenvalues; commuting matrices share them.
- "Derive the GCN layer." — First-order Chebyshev filter, , one shared parameter, self-loops and symmetric normalization (renormalization trick): .
- "What is over-smoothing, in linear-algebra terms?" — is power iteration; features converge to the top eigenvector . Fixes: residual connections, normalization, fewer layers.
- "Why can an FNO trained on 64 points run on 256?" — Its weights belong to Fourier modes; every grid that resolves those modes gives the same operator.
- "How do you take a gradient step with an orthogonality constraint?" — Project the gradient onto , step, and retract with QR (positive diagonal in R) or the polar factor.
10. Practice #
The notebook for this lesson runs in Colab. It has five exercises, each with a check cell and a folded solution:
- Write circular convolution with the FFT and the eigenvalues of a circulant, and check
against
scipy.linalg.circulant. - Write a one-channel FNO Fourier layer with
np.fft.rfft, and show that it commutes with shifts and gives the same function on grids of 64 and 256 points. - Build the Laplacian of a graph, count its components from the spectrum, and split a graph with two planted communities by the signs of the Fiedler vector.
- Build the GCN matrix , check that its eigenvalues lie in , test permutation equivariance, and watch over-smoothing.
- Take Riemannian gradient steps on the Stiefel manifold (tangent projection + QR retraction) to find the top-2 eigenvector subspace of a symmetric matrix, and measure the principal angles to the true subspace.
11. Watch and read #
- Gilbert Strang, MIT 18.065 (2018), lecture 32 "ImageNet is a convolutional neural network (CNN), the convolution rule" and lecture 35 "Finding clusters in graphs": course page with all videos.
- Bronstein, Bruna, Cohen, Veličković, Geometric Deep Learning: Grids, Groups, Graphs, Geodesics, and Gauges (2021): §3.1 (symmetries, representations, invariance and equivariance), §4.1 (graphs and sets, permutation equivariance), §4.2 (grids: circulant matrices and the Fourier transform), §5.3 (GNNs).
- Li et al., "Fourier Neural Operator for Parametric Partial Differential Equations" (ICLR 2021): §3 (Definitions 1–2, the neural operator), §4 (Definition 3 and Eq. (4)–(5), the Fourier layer; "Invariance to discretization").
- Kipf and Welling, "Semi-Supervised Classification with Graph Convolutional Networks" (ICLR 2017): §2.1–2.2, Eq. (2)–(8), the derivation of Theorem 4.
- Nicolas Boumal, An Introduction to Optimization on Smooth Manifolds (2023, free PDF): §2.4 (PCA on Stiefel and Grassmann), §7.3 (the Stiefel manifold, Eq. (7.13)–(7.28)), §9.16 (Grassmann summary).
- Sanchez-Lengeling et al., "A Gentle Introduction to Graph Neural Networks" (Distill, 2021): message passing with interactive figures.
Runs in your browser with nothing to install. The notebook repeats the key demos and has exercises with checks; solutions are inside, folded.
No Google account needed: Python runs inside your browser. The first start downloads about 40 MB; your changes are saved in this browser only.