Introduction
Deep learning models are often characterized as "black boxes," where the internal logic of high-dimensional activations remains opaque. To understand these models, researchers attempt to compare the "representations"—the patterns of neuron activations—across different layers, architectures, or training runs. However, comparing these representations is non-trivial because neurons may be permuted or scaled differently between models. This paper introduces Centered Kernel Alignment (CKA), a robust similarity index designed to provide a meaningful comparison of neural network internal structures.
The Invariance Paradox
Previous attempts to measure representational similarity relied heavily on Canonical Correlation Analysis (CCA). CCA is invariant to any invertible linear transformation, which initially seems advantageous. However, the authors argue that this high degree of invariance is a "bug" rather than a feature. If a layer contains more neurons than there are data points, CCA can find a transformation to make any two representations appear identical, failing to distinguish meaningful similarity from mathematical coincidence. For a similarity metric to be useful, it must respect the relative importance (scale) of different features within the representation.
Centered Kernel Alignment (CKA)
The proposed solution, CKA, shifts the focus from comparing features directly to comparing how the network perceives relationships between examples. For a given layer, an $n \times n$ Representational Similarity Matrix (RSM) is computed, where $n$ is the number of examples. This matrix captures how similar every pair of images is to each other according to that specific layer's activations.
CKA compares these RSMs using the Hilbert-Schmidt Independence Criterion (HSIC). Unlike CCA, CKA is invariant to orthogonal transformations and isotropic scaling but not to all invertible linear transformations. This allows it to capture the "shape" of the representation that CCA ignores.
Key Insights and Results
The Sanity Check
A critical test for any similarity metric is its ability to identify a layer's "twin" in an identical network trained with a different random seed. In this task, CKA achieved a remarkable 99.3% accuracy. In contrast, CCA-based methods struggled significantly, often failing to identify the correct corresponding layer as shown in the heatmaps above.
Architecture Mapping and Depth
CKA proves highly effective at mapping correspondences between different architectures. When comparing networks of different depths, CKA reveals that the additional layers in deeper models effectively "interpolate" between the representations of shallower models. This suggests that increasing depth allows for a more gradual refinement of features rather than entirely new representational stages.
Width and Consistency
The authors found that as network width (number of channels) increases, the learned representations become increasingly similar to other networks of the same width. Furthermore, early layers appear to learn nearly identical representations even when trained on entirely different datasets (e.g., CIFAR-10 vs. CIFAR-100), whereas later layers become highly specialized to the specific task.
Conclusion
Centered Kernel Alignment provides a powerful new lens for peering into the black box of deep learning. By balancing invariance with sensitivity to feature scale, CKA enables researchers to verify that wider networks learn more consistent features and to visualize how different architectures relate to one another. This work moves the field toward a more principled understanding of how neural networks represent information.
Summary updated