Similarity measures are widely used to interpret the representational geometries used by neural networks to solve tasks. Yet, because existing methods compare the extrinsic geometry of representations in state space, rather than their intrinsic geometry, they may fail to capture subtle yet crucial distinctions between fundamentally different neural network solutions. Here, we introduce metric similarity analysis (MSA), a novel method which leverages tools from Riemannian geometry to compare the intrinsic geometry of neural representations under the manifold hypothesis. We show that MSA can be used to i) disentangle features of neural computations in deep networks with different learning regimes, ii) compare nonlinear dynamics, and iii) investigate diffusion models. Hence, we introduce a mathematically grounded and broadly applicable framework to understand the mechanisms behind neural computations by comparing their intrinsic geometries.
Figures & tables
Figure 1: Intrinsic vs. extrinsic geometric similarity.
Figure 2: The pullback metric of neural representations.
Figure 3: The spectral ratio is a distance over SPD matrices. a. The set of SPD matrices (here 2×2 ) is a solid cone in the Euclidean space of their entries. b. Slice of the SPD cone along matrices which are related by a scalar multiple. The slice is characterised by a variable r , defining the relative magnitude of the diagonal entries and θ defining the magnitude of the off-diagonal entries. The spectral ratio defines a similarity between pairs of matrices on the SPD cone, with different relative θ ( c ) or r ( d ).
Figure 4: Metric similarity analysis enables comparison of the intrinsic geometry of neural representations. Two neural networks receiving inputs from the same manifold with different hidden-layer geometries, corresponding to distinct Riemannian metrics.
Figure 5: Rich and lazy network representations have different intrinsic geometries. a. Network trained to map a 2D manifold to discrete classes. b. PCA applied to the activation of the rich and lazy network, coloured according to the target class. c. Mesh grid of the intrinsic geometry of the representations. d. Similarity between the rich and lazy representation; rich 2 is a different seed.
Figure 6: MSA captures hierarchical structure across neural representations. Networks with different learning regimes, tasks, architectures, and seeds. a. MSA, RSA and CCA applied to pairs of these networks. Note that RSA and CKA are equivalent when mean-centered ( Williams, 2024 ) . MSA captures the hierarchical structure across models while CCA and RSA do not. b. Instead of considering all combinations of such hyperparameters, we hierarchically vary them. All networks receive the same input on a 2-dimensional planar manifold. They have different learning regimes (rich vs. lazy), or different tasks (5 vs. 2 classes), or seeds (S1/S2, defining initial weights).
Figure 7: MSA enables comparing state-space models to recurrent neural networks. a. The network receives a sequence of angular inputs: ui(t)=fi(θ1)\mathds1t=t1+fi(θ2)\mathds1t=t2 for i=1,2 , with f1(x)=cos(x) and f2(x)=sin(x) , which it must keep in memory for a variable delay period. At the Go cue (signalled by u3(t)=\mathds1t=tgo ), it must output same sequence. b. PCA applied to the state of the RNN. c. MSA applied to the full input-time manifolds of different models. d. Eigenvectors of the doubly-centred pairwise MSA similarity matrix (i.e. MDS with MSA distance). e. Similarity of the geometry (RSA), dynamics (DSA) and geometry+dynamics (MSA) between the trained RNN and all other models. f. MSA applied to compare the representations within a single model at two timepoints (after the second input).
Figure 8: The latent space of diffusion models collapses without guidance. a. Schematic of StableDiffusionXL: a backward diffusion process transports a Gaussian distribution to a latent generative distribution. Samples are then mapped to image space via a variational auto-encoder (VAE). b. The diffusion process is conditioned on a text embedding. We generated a manifold of text embeddings via bilinear interpolation: z(π)=π1π2v1+(1-π1)π2v2+π1(1-π2)v3+(1-π1)(1-π2)v4. This defines a statistical manifold of generative distributions. c. Samples across the manifold for a fixed x(1) . d. Similarity between the statistical manifold geometry at any pair of timepoint. e. Visualization of the information geometry using MDS on the MSA distance. f. MSA similarity between the statistical manifold at different guidance levels vs. no guidance ( γ=1 ).
Diffusion geometry is a manifold learning framework that uses random walks defined by Markov transition matrices to characterize the geometry of a dataset at multiple scales. We use diffusion geometry for neural representations, incorporating tools from multi-view learning into this field for the first time. Our key technical observation is that a broad class of similarity measures based on representational similarity matrices (RSMs) admits a closed-form equivalent formulation in terms of row-stochastic Markov matrices, opening the door to manipulations from diffusion geometry. As a first application, we develop multi-scale variants of Centered Kernel Alignment and Distance Correlation, which utilise the tth power of the underlying transition matrix to probe the data geometry at adjustable diffusion scales. Going further, we introduce variants of these measures which fuse the Markov matrices of several layers via alternating diffusion into a single operator that captures the network's joint sample geometry, allowing similarity to be computed across multiple layers and shifting the comparison from layer-to-layer to network-to-network. We perform extensive numerical experiments, evaluating our measures on the Representational Similarity (ReSi) benchmark comprising 14 architectures trained on 7 datasets across three different domains. Our methods achieve SoTA results in accuracy and output correlation for both language and vision tasks across different models. We furthermore show SoTA performance on an additional benchmark evaluating on out-of-distribution data.
Atharva Khandait, Jan E. Gerken
Department of Mathematical Sciences, Chalmers University of Technology and the University of Gothenburg, SE-412 96 Gothenburg, Sweden.
Neural network representations are often analyzed as vectors in a fixed Euclidean space. However, their coordinates are not uniquely defined. If a hidden representation is transformed by an invertible linear map, the network function can be preserved by applying the inverse transformation to downstream weights. Representations are therefore defined only up to invertible linear transformations. We study neural representation spaces from this geometric viewpoint and treat them as vector spaces with a gauge freedom under the general linear group. Within this framework, commonly used similarity measures such as cosine similarity become metric-dependent quantities whose values can change under coordinate transformations that leave the model function unchanged. This provides a common interpretation for several observations in the literature, including cosine-similarity instability, anisotropy in embedding spaces, and the appeal of representation comparison methods such as SVCCA and CKA. Experiments on multilayer perceptrons and convolutional networks confirm that inserting invertible transformations into trained models can substantially distort cosine similarity and nearest-neighbor structure while leaving predictions unchanged. These results indicate that analysis of neural representations should focus either on quantities that are invariant under this gauge freedom or on explicitly chosen canonical coordinates.
Jericho Cain
Physics Department, Portland Community College, Portland, OR, USA
As modern deep learning architectures grow in complexity, representational ambiguity emerges as a critical barrier to their interpretability and reliable merging. For ReLU networks, identical functional mappings can be achieved through entirely different weight configurations due to algebraic symmetries: neuron permutation and positive diagonal scaling. Consequently, traditional parameter-based comparison methods exhibit extreme instability to slight weight perturbations during training. This paper proposes a mathematically grounded approach to constructing a stable canonical representation of neural networks and a robust functional similarity metric. We shift focus from comparing raw weights to analyzing the topology of neuron activation regions. The algorithm first eliminates scaling ambiguity via L2-normalization of weight vectors with subsequent layer compensation. Next, discrete approximations of activation regions are generated as binary functional signatures evaluated over a data sample. To overcome the computational bottleneck of comparing large binary vectors, we adapt Locality-Sensitive Hashing, specifically MinHash, providing a fast and statistically precise approximation of the Jaccard index. The final cross-network neuron matching is formulated as a linear sum assignment problem solved via the Hungarian algorithm. We demonstrate theoretically and experimentally that our metric mitigates the neuron "flickering" effect and exhibits exceptional robustness to minor weight perturbations. This framework provides a solid foundation for model merging, transfer learning, objective assessment during pruning, and Explainable AI paradigms.