21 Lab 05 — Sheaf Laplacian
Anchor chapter: Chapter 5 — Sheaf Cohomology, Laplacians, Harmonic Extensions.
Goal. Assemble \(\delta\), compute \(\mathcal{L}_\mathcal{F} = \delta^T\delta\), diagonalise it, and check \(\ker \mathcal{L}_\mathcal{F} = H^0(\mathcal{F}; \mathbb{R}^d)\).
Implement the sheaf Laplacian \(\mathcal{L}_\mathcal{F} = \delta^T\delta\) from the coboundary matrix built in Lab 04. For the path sheaf, verify the block-tridiagonal structure of \(\mathcal{L}_\mathcal{F}\). Compute eigenvalues and eigenvectors. For a randomly initialised [2, 4, 1] network, compute the restricted Laplacian \(\mathcal{L}_\mathcal{F}[\Omega,\Omega]\), verify positive definiteness (all eigenvalues \(> 0\)), and check that \(\det\mathcal{L}_\mathcal{F}[\Omega,\Omega] = 1\) (as predicted by Lemma 3.2). Visualise the Fiedler eigenvector energy per stalk.
This lab requires only NumPy, Matplotlib, and SciPy, loaded automatically via Pyodide. Code cells run directly in the page via WebAssembly — no local Python installation needed.
Prefer a local Jupyter environment? Download lab-05-sheaf-laplacian.ipynb
21.1 Setup
21.2 1. Build the object
The sheaf Laplacian is \(\mathcal{L}_\mathcal{F} = \delta^\top \delta\), a positive semi-definite matrix acting on 0-cochains. Its kernel is exactly the space of global sections \(H^0(\mathcal{F})\). We build the neural sheaf for a [2, 4, 1] ReLU network: the pre-activation cochain lives in \(\mathbb{R}^{n_0} \times \mathbb{R}^{n_1} \times \mathbb{R}^{n_2}\), and the coboundary \(\delta_\sigma\) encodes the affine-plus-ReLU relations between consecutive layers. The restricted Laplacian \(\mathcal{L}_\mathcal{F}[\Omega, \Omega]\) eliminates the pinned input and output blocks; Lemma 3.2 predicts \(\det \delta_\Omega = 1\) (unitriangular structure), so \(\det \mathcal{L}_\mathcal{F}[\Omega, \Omega] = (\det \delta_\Omega)^2 = 1\).
21.3 2. Verify a theorem / run an experiment
We diagonalise \(\mathcal{L}_\mathcal{F}[\Omega, \Omega]\) and confirm all eigenvalues are strictly positive (positive definiteness), consistent with the unitriangular structure of \(\delta_\Omega\). The Fiedler eigenvector (associated to the smallest eigenvalue \(\lambda_{\min}\)) indicates which stalks carry the most “tension” and governs the convergence rate of the sheaf heat equation in Lab 06. We also run the experiment across 50 random activation patterns to confirm Lemma 3.2 holds generically.
21.4 Exercises
Kernel = global sections. For the discourse sheaf from Lab 04, verify that \(\ker \mathcal{L}_\mathcal{F}\) and \(\ker \delta\) have the same dimension (both equal \(H^0(\mathcal{F})\)). Use
numpy.linalg.eighto find near-zero eigenvalues and compare toscipy.linalg.null_space.Positivity and connectivity. For the constant \(\mathbb{R}^1\) sheaf on a connected graph, \(\mathcal{L}_\mathcal{F}\) has exactly one zero eigenvalue. Verify this for the path \(P_5\) and cycle \(C_5\). What happens on a disconnected graph with two components?
Fiedler vector as tension map. For the [2, 4, 1] neural sheaf, plot the Fiedler eigenvector as a bar chart broken down by stalk. Repeat for three different random weight matrices. Does the stalk with the highest energy concentration change?
Deeper network. Extend the coboundary construction to a [2, 4, 4, 1] network (two hidden layers). Assemble \(\delta_\Omega\) as a \(9 \times 9\) lower-triangular matrix, verify \(\det \delta_\Omega = 1\), and compare the eigenvalue spectrum of \(\mathcal{L}_\mathcal{F}[\Omega, \Omega]\) to the [2, 4, 1] case.