Estimating Neural Representation Alignment from Sparsely Sampled Inputs and Features — part 1/5

Cleaned-text code points [0, 15658). Bibliography omitted here; source.md includes it.

# Estimating Neural Representation Alignment from Sparsely Sampled Inputs and Features

## Abstract

In both artificial and biological systems, the centered kernel alignment (CKA) has become a widely used tool for quantifying neural representation similarity. While current CKA estimators typically correct for the effects of finite stimuli sampling, the effects of sampling a subset of neurons are overlooked, introducing notable bias in standard experimental scenarios. Here, we provide a theoretical analysis showing how this bias is affected by the representation geometry. We then introduce a novel estimator that corrects for both input and feature sampling. We use our method for evaluating both brain-to-brain and model-to-brain alignments and show that it delivers reliable comparisons even with very sparsely sampled neurons. We perform within-animal and across-animal comparisons on electrophysiological data from visual cortical areas V1, V4, and IT data, and use these as benchmarks to evaluate model-to-brain alignment. We also apply our method to reveal how object representations become progressively disentangled across layers in both biological and artificial systems. These findings underscore the importance of correcting feature-sampling biases in CKA and demonstrate that our bias-corrected estimator provides a more faithful measure of representation alignment. The improved estimates increase our understanding of how neural activity is structured across both biological and artificial systems. Keywords: CKA; Representation Alignment; Disentanglement; Estimation

## Introduction

Over the past decade, the concept of representation similarity has emerged as a powerful framework for comparing complex neural and computational systems ( Kriegeskorte et al., (2008) ; Kriegeskorte & Kievit, (2013) ) . One of the most popular tools is centered kernel alignment (CKA), a measure originally adapted from kernel-based independence metrics but now widely employed across fields such as machine learning, neuroscience, and cognitive science. In machine learning, CKA has become the de facto standard for quantifying how similarly different layers—or even entirely different architectures—encode the same input data ( Kornblith et al., (2019) ) . In neuroscience, CKA has emerged as a core analytical tool to assess whether neural populations, either within or across brain regions and species, produce similar activity patterns in response to identical stimuli ( Yamins & DiCarlo, (2016) ; Schrimpf et al., (2018) ) . Its popularity arises from two advantages: (1) CKA is invariant to orthogonal transformations, making it robust to small perturbations in feature space, and (2) it normalizes for overall variation in activity levels, facilitating meaningful comparisons based on alignment.

Despite these strengths, there is a growing consensus that conventional CKA estimators overlook a critical limitation in many experimental settings, that the sampling of only a subset of “features” as with experimental recordings, can introduce a systematic bias. This is particularly significant in neuroscience, where only a fraction of the total neural population is recorded. Existing CKA estimators often assume that if enough data points (e.g., stimuli or input images) are provided, the measure becomes reliable. Yet this assumption ignores the additional requirement for sufficiently large samples along the “feature” dimension. Consequently, researchers risk drawing misleading conclusions about the alignment of brain regions and neural network layers ( Murphy et al., (2024) ; Cloos et al., (2024) ; Han et al., (2023) ; Sucholutsky et al., (2023) ) .

In this work, we address this pressing concern. First, we show analytically how the geometry of high-dimensional representations contributes to spurious underestimation of similarity when only limited neuronal or model “units” are observed. Second, building on these insights, we introduce a novel estimator designed to remain consistent even with limited feature samples. By systematically correcting for finite-sample effects in both inputs and features, our method offers a more faithful gauge of representation alignment.

We demonstrate the real-world impact of our estimator through analyses of convolutional neural networks and multi-electrode electrophysiological recordings in visual cortices V1, V4, and IT ( Papale et al., (2025) ) . Our new estimator enables more accurate model-to-brain comparisons, revealing alignment trends that are otherwise corrupted by sampling biases. Beyond model-to-brain alignment, we show that the improved CKA estimator illuminates how object-category representations become increasingly disentangled along the primate ventral stream, similar to the observations in deep neural networks. Taken together, these results show that accounting for feature sampling is indispensable for robust representation analysis. Our work thus not only strengthens the theoretical foundations of CKA but also expands its practical utility for probing neural and computational representations.

## Problem Statement

There are many scenarios in which the accurate quantification of the similarity between representations is of central interest ( Figure 1 ). For example, for a given stimulus set, one may want to compare the representations of the brain and a neural network model. To set a benchmark for brain-to-model similarity, it is also useful to measure brain-to-brain similarities across two individual animals or across trials in one animal. In a separate scenario, one may be interested in comparing the neural representations of two stimuli sets, e.g. two image categories, in a single brain region of one individual animal. In all these setups, CKA can be used to quantify the similarities.

Suppose one measures two separate neural representation matrices, 𝐗 {\mathbf{X}} and 𝐘 {\mathbf{Y}} , where each row corresponds to a distinct stimulus and each column represents a recorded neuron. Here, assume the data has been preprocessed so that each neuron has zero mean across all the recorded stimuli. Typically, in its most intuitive form, the CKA is then computed as

tr ​ ( 𝐗𝐗 ⊤ ​ 𝐘𝐘 ⊤ ) tr ​ ( ( 𝐗𝐗 ⊤ ) 2 ) ​ tr ​ ( ( 𝐘𝐘 ⊤ ) 2 ) \frac{\text{tr}({\mathbf{X}}{\mathbf{X}}^{\top}{\mathbf{Y}}{\mathbf{Y}}^{\top})}{\sqrt{\text{tr}\left(\left({\mathbf{X}}{\mathbf{X}}^{\top}\right)^{2}\right)\text{tr}\left(\left({\mathbf{Y}}{\mathbf{Y}}^{\top}\right)^{2}\right)}} (1) In a hypothetical scenario where one has access to all neurons and stimuli, CKA takes the value 1 1 when the representations are perfectly aligned and 0 0 when they span orthogonal subspaces. The normalization factor in the denominator keeps CKA invariant to the scaling of the representations.

In reality, the representation matrices are actually sampled submatrices of an unobserved larger matrix. Due to practical limitations, we often do not get to observe all neurons in a brain region, and it is not possible to present all possible stimuli from a stimulus set, e.g. natural images. Due to these sampling effects, computing the naive CKA from the measurement matrices is heavily biased. Currently, the estimator derived from Song et al. ((2012)) is widely used in the literature to correct the bias contributed by stimulus sampling. In this paper, we show how to correct the bias in the CKA estimator when both the stimuli and neurons are sampled from the underlying large matrix.

## Our Contribution

We make the following contributions in this paper: • We find that the popular CKA estimator based on Song et al. ((2012)) can take arbitrarily small values under finite sampling of both the stimuli and neurons, even when the underlying representations are perfectly aligned. Through theoretical analysis, we show that the bias increases with the intrinsic dimensionality of the representation.

• To address this issue, we develop a more general CKA estimator that corrects the bias contributed by both the stimulus and neuron sampling. We demonstrate its reliability in both synthetic and neurophysiological data.

• We demonstrate our estimator enables a novel application of CKA that quantifies the representation disentanglement in the brain from real data.

## Definitions

### Centered Kernel Alignment

A neural population ϕ ⁡ ( x ) {\bm{\phi}}(x) defines a representation of stimuli x ∈ 𝒳 x\in\mathcal{X} with a large number of neurons. The associated centered kernel function k ⁡ ( x , x ′ ) k(x,x^{\prime}) measures the similarity of two stimuli in the representation space of ϕ {\bm{\phi}} and is defined as: k ⁡ ( x , x ′ ) ≔ ⟨ ϕ ⁡ ( x ) − 𝔼 ⁡ [ ϕ ] , ϕ ⁡ ( x ′ ) − 𝔼 ⁡ [ ϕ ] ⟩ , \displaystyle k(x,x^{\prime})\coloneqq\Braket{\,{\bm{\phi}}(x)-\mathbb{E}[{\bm{\phi}}]\;,\;{\bm{\phi}}(x^{\prime})-\mathbb{E}[{\bm{\phi}}]\,}, (2) where ⟨ ⋅ , ⋅ ⟩ \braket{\cdot,\cdot} denotes an appropriate inner product. Here, 𝔼 ⁡ [ ϕ ] \mathbb{E}[{\bm{\phi}}] denotes the expectation of ϕ {\bm{\phi}} over the stimuli space 𝒳 \mathcal{X} and is used to center the population activity.

For two distinct neural populations ϕ ( a ) ​ ( x ) {\bm{\phi}}^{(a)}(x) and ϕ ( b ) ​ ( x ) {\bm{\phi}}^{(b)}(x) , we measure their similarity using the Hilbert-Schmidt Independence Criterion (HSIC), a popular metric in machine learning ( Gretton et al., (2005) ) . HSIC compares two populations based on the correlations of their kernel functions k ( a ) k^{(a)} and k ( b ) k^{(b)} , and yields, what we call an ℋ \mathcal{H} -value: ℋ ⁡ ( k ( a ) , k ( b ) ) ≔ 𝔼 x , x ′ ​ [ k ( a ) ​ ( x , x ′ ) ​ k ( b ) ​ ( x , x ′ ) ] . \displaystyle\mathcal{H}(k^{(a)},k^{(b)})\coloneqq\mathbb{E}_{x,x^{\prime}}[k^{(a)}(x,x^{\prime})k^{(b)}(x,x^{\prime})]. (3) A low ℋ \mathcal{H} -value indicates less similarity and is zero if and only if the populations ϕ ( a ) {\bm{\phi}}^{(a)} and ϕ ( b ) {\bm{\phi}}^{(b)} vary independently.

The centered kernel alignment (CKA) is essentially the normalized version of HSIC ( Cortes et al., (2012) ; Kornblith et al., (2019) ) and is defined as CKA ​ ( k ( a ) , k ( b ) ) ≔ ℋ ⁡ ( k ( a ) , k ( b ) ) ℋ ⁡ ( k ( a ) , k ( a ) ) ​ ℋ ​ ( k ( b ) , k ( b ) ) . \displaystyle\text{CKA}(k^{(a)},k^{(b)})\coloneqq\frac{\mathcal{H}(k^{(a)},k^{(b)})}{\sqrt{\mathcal{H}(k^{(a)},k^{(a)})\mathcal{H}(k^{(b)},k^{(b)})}}. (4) CKA is normalized to the interval [ 0 , 1 ] [0,1] and invariant to the overall magnitude of population activations.

### Measurement matrix

Greek indices ( α , β , ⋯ \alpha,\beta,\cdots ) denote neurons; Latin indices ( i , j , ⋯ i,j,\cdots ) denote stimuli, and Latin indices ( a , b , ⋯ a,b,\cdots ) denote distinct populations. We use the letter Q Q for the number of neurons and P P for the number of stimuli. Quantities with a hat ( ^ \;\widehat{\;}\; ) indicate empirical estimates.

For each population ϕ ( a ) {\bm{\phi}}^{(a)} , we observe Q a Q_{a} neurons ϕ α ​ ( x ) {\bm{\phi}}_{\alpha}(x) for α = 1 , ⋯ , Q a \alpha=1,\cdots,Q_{a} . Each neuron is measured on the same set of stimuli { x i } \{x_{i}\} for i = 1 , ⋯ , P i=1,\cdots,P , where P P is the number of stimuli. The corresponding measurement matrix 𝚽 ( a ) ∈ ℝ P × Q a {\bm{\Phi}}^{(a)}\in\mathbb{R}^{P\times Q_{a}} with elements 𝚽 i ​ α ( a ) = ϕ α ( a ) ​ ( x i ) {\bm{\Phi}}^{(a)}_{i\alpha}={\bm{\phi}}^{(a)}_{\alpha}(x_{i}) denotes the response of each neuron to stimulus x i x_{i} .

We define the empirical uncentered kernels (also called Gram matrices) by 𝐊 ( a ) = 1 Q a ​ 𝚽 ( a ) ​ 𝚽 ( a ) ⊤ , {\mathbf{K}}^{(a)}=\frac{1}{Q_{a}}{\bm{\Phi}}^{(a)}{{\bm{\Phi}}^{(a)}}^{\top}, and the empirical centered kernels defined in Equation 2 by 𝐊 ¯ ( a ) = 𝐇𝐊 ( a ) ​ 𝐇 , 𝐇 = 𝐈 − 1 P ​ 𝟏𝟏 ⊤ , \displaystyle\bar{\mathbf{K}}^{(a)}={\mathbf{H}}{\mathbf{K}}^{(a)}{\mathbf{H}},\quad{\mathbf{H}}={\mathbf{I}}-\frac{1}{P}\mathbf{1}\mathbf{1}^{\top}, (5) where 𝐇 {\mathbf{H}} is the centering matrix.

## Existing CKA estimators

With these definitions, we now construct estimators of ℋ \mathcal{H} -value from finite data. Here, we convey the overall ideas and provide detailed analyses in Appendix A .

### Naive Estimator

Following the definition of ℋ \mathcal{H} -value in Equation 3 , the naive estimator is ℋ ^ 0 ​ ( k ( a ) , k ( b ) ) \displaystyle\widehat{\mathcal{H}}_{0}(k^{(a)},k^{(b)}) = 1 P 2 ​ ∑ i ≠ j 𝐊 ¯ i ​ j ( a ) ​ 𝐊 ¯ j ​ i ( b ) + 1 P 2 ​ ∑ i 𝐊 ¯ i ​ i ( a ) ​ 𝐊 ¯ i ​ i ( b ) , \displaystyle=\frac{1}{P^{2}}\sum_{i\neq j}\bar{\mathbf{K}}^{(a)}_{ij}\bar{\mathbf{K}}^{(b)}_{ji}+\frac{1}{P^{2}}\sum_{i}\bar{\mathbf{K}}^{(a)}_{ii}\bar{\mathbf{K}}^{(b)}_{ii}, (6) which approaches the true ℋ \mathcal{H} -value as P → ∞ P\to\infty . In this limit, the second term falls as 𝒪 ⁡ ( 1 / P ) \mathcal{O}(1/P) and hence does not contribute to the true ℋ \mathcal{H} -value, demonstrating that the naive estimator ℋ ^ 0 \widehat{\mathcal{H}}_{0} for finite P P is biased 1 1 1 The centering operation is another source of bias for ℋ ^ 0 \widehat{\mathcal{H}}_{0} , which is discussed in Appendix B .

We define CKA ^ 0 ​ ( k ( a ) , k ( b ) ) \widehat{\text{CKA}}_{0}(k^{(a)},k^{(b)}) to be the naive estimator of CKA obtained by replacing ℋ ^ 0 \widehat{\mathcal{H}}_{0} in Equation 4 . Observe that this naive estimator is biased due to the biases of ℋ ^ 0 \widehat{\mathcal{H}}_{0} which appears both in numerator and denominator.

### Stimulus-Corrected Estimator

The cause of the bias in the Equation 6 was the term where two independent stimuli indices ( i , j ) (i,j) coincided. In general, unbiased estimates are obtained by averaging over all indices where each stimulus is used at most once ( Hoeffding, (1948) ) .

An unbiased estimator for ℋ \mathcal{H} -value correcting for these terms was developed by Song et al. ((2012)) and is given by ℋ ^ S ​ ( k ( a ) , k ( b ) ) ≔ 1 P ⁡ ( P − 3 ) \displaystyle\widehat{\mathcal{H}}_{S}(k^{(a)},k^{(b)})\coloneqq\frac{1}{P\left(P-3\right)} (7) × [ tr ​ ( 𝐊 ~ ( a ) ​ 𝐊 ~ ( b ) ) − 2 ​ 𝟏 ⊤ ​ 𝐊 ~ ( a ) ​ 𝐊 ~ ( b ) ​ 𝟏 P − 2 + 𝟏 ⊤ ​ 𝐊 ~ ( a ) ​ 𝟏𝟏 ⊤ ​ 𝐊 ~ ( b ) ​ 𝟏 ( P − 1 ) ​ ( P − 2 ) ] , \displaystyle\times\left[\text{tr}\left(\tilde{\mathbf{K}}^{(a)}\tilde{\mathbf{K}}^{(b)}\right)-2\frac{\mathbf{1}^{\top}\tilde{\mathbf{K}}^{(a)}\tilde{\mathbf{K}}^{(b)}\mathbf{1}}{P-2}+\frac{\mathbf{1}^{\top}\tilde{\mathbf{K}}^{(a)}\mathbf{1}\mathbf{1}^{\top}\tilde{\mathbf{K}}^{(b)}\mathbf{1}}{\left(P-1\right)\left(P-2\right)}\right], where 𝐊 ~ i ​ j = 𝐊 i ​ j ​ ( 1 − δ i ​ j ) \tilde{\mathbf{K}}_{ij}={\mathbf{K}}_{ij}(1-\delta_{ij}) is the uncentered kernel with diagonals removed.

The sample corrected estimator for CKA, denoted by CKA ^ S ​ ( k ( a ) , k ( b ) ) \widehat{\text{CKA}}_{S}(k^{(a)},k^{(b)}) , is obtained by replacing ℋ ^ S \widehat{\mathcal{H}}_{S} in Equation 4 . This is the current version of CKA that is used both in deep learning ( Nguyen et al., (2021) ; Raghu et al., (2021) ; Davari et al., (2022) ) and neuroscience ( Murphy et al., (2024) ) .

Note that this estimator removes the bias due to coinciding stimuli indices. However, the inputs to ℋ ^ S ​ ( k ( a ) , k ( b ) ) \widehat{\mathcal{H}}_{S}(k^{(a)},k^{(b)}) are kernels which involve a sum over neurons. Therefore, if its inputs have shared neurons as in the case of the denominator of CKA, a similar bias discussed in Equation 6 occurs but for neuron indices. Therefore, assuming that the populations ϕ ( a ) {\bm{\phi}}^{(a)} and ϕ ( b ) {\bm{\phi}}^{(b)} have independent neurons, the numerator of CKA ^ S ​ ( k ( a ) , k ( b ) ) \widehat{\text{CKA}}_{S}(k^{(a)},k^{(b)}) remains unbiased, but its denominator is biased due to finite neuron sampling effects (See Section B.2 , Equation S7 ).

### Bias of the Existing Estimator