[Paper Review] Similarity of Neural Networks with Gradients
This paper proposes a novel similarity index for neural networks that combines feature and gradient vectors into a kernel-based representation, leveraging sketching techniques for scalability and invariance to dataset size differences. The method achieves state-of-the-art performance in comparing independently trained models across different datasets, with Centred Kernel Alignment (CKA) outperforming Normalised Bures Similarity (NBS) in empirical evaluations.
A suitable similarity index for comparing learnt neural networks plays an important role in understanding the behaviour of the highly-nonlinear functions, and can provide insights on further theoretical analysis and empirical studies. We define two key steps when comparing models: firstly, the representation abstracted from the learnt model, where we propose to leverage both feature vectors and gradient ones (which are largely ignored in prior work) into designing the representation of a neural network. Secondly, we define the employed similarity index which gives desired invariance properties, and we facilitate the chosen ones with sketching techniques for comparing various datasets efficiently. Empirically, we show that the proposed approach provides a state-of-the-art method for computing similarity of neural networks that are trained independently on different datasets and the tasks defined by the datasets.
Motivation & Objective
- To develop a robust similarity index for comparing neural networks trained on different datasets.
- To address the limitation of existing similarity indices in handling datasets of varying sizes.
- To incorporate both feature representations and gradient information from the loss landscape for richer model characterization.
- To enable efficient, scalable comparison using sketching techniques that preserve spectral structure.
- To provide empirical and theoretical insights into the interpretability of model similarity through kernel mean embedding norms.
Proposed method
- The method constructs a combined kernel representation using both feature vectors and gradient vectors from a neural network's hidden layers.
- It applies kernel mean embedding to represent the predictive distribution, with the norm of the embedding used as a proxy for model-dataset alignment.
- Sketching techniques are used to project high-dimensional kernel matrices into lower dimensions, enabling efficient computation and invariance to sample size variations.
- The similarity index is computed using CKA or NBS on the sketched representations, with CKA preferred due to better performance in experiments.
- The approach supports comparisons between models trained on different datasets and enables analysis of transferability and adaptation difficulty.
- The method is implemented with batch-parallel gradient computation, reducing time and space complexity compared to prior approaches.
Experimental results
Research questions
- RQ1How can we design a similarity index that effectively compares neural networks trained on different datasets?
- RQ2What role do gradient vectors play in capturing task-specific information for model comparison?
- RQ3Can sketching techniques enable scalable and invariant comparison of neural network representations across datasets of different sizes?
- RQ4How does the norm of the kernel mean embedding reflect the similarity between a model and a dataset?
- RQ5Which similarity index—CKA or NBS—better captures meaningful relationships between models and datasets?
Key findings
- The proposed method achieves state-of-the-art performance in measuring similarity between independently trained neural networks on different datasets.
- Combining feature and gradient vectors in the kernel representation leads to more informative similarity scores than using features alone.
- Sketching enables efficient computation and invariance to varying dataset sizes, making the method scalable.
- The norm of the kernel mean embedding, ||μp||, successfully captures the intuitive notion that models trained on similar datasets (e.g., CIFAR-10 and CIFAR-100) require less adaptation.
- CKA outperforms NBS as a similarity index, as it better reflects true model similarity, especially when datasets differ in size.
- The method reveals that models trained on SVHN show higher similarity to CIFAR-100 than to CIFAR-10, consistent with domain similarity expectations.
Read this paper
Open the full text in the Nubint reader and ask about any passage as you read.
Read this paper on NubintThis review was generated by AI from the original paper. Please check the paper before citing it.