E XPLORING N EURAL N ETWORK R EPRESENTATIONAL S IMILARITY USING F ILTER S UBSPACES
Anonymous authors
Paper under double-blind review
A BSTRACT
Analyzing representational similarity in neural networks is crucial to numerous tasks, such as interpreting or transferring deep models.
One typical approach is to input probing data into convolutional neural networks (CNNs) as stimuli to reveal their deep representation for model similarity analysis.
Those methods are often computationally expensive and stimulus-dependent.
By representing filter subspace in a CNN as a set of filter atoms, previous work has reported competitive performance in continual learning by learning a different set of filter atoms for each task while sharing common atom coefficients across tasks.
Inspired by this observation, in this paper, we propose a new paradigm for reducing representational similarity analysis in CNNs to filter subspace distance assessment.
Specifically, when filter atom coefficients are shared across networks, model representational similarity can be significantly simplified as calculating the cosine distance among respective filter atoms, to achieve millions of times computation reduction.
We provide both theoretical and empirical evidence that this simplified filter subspace-based similarity preserves a strong linear correlation with other popular stimulus-based metrics, while being significantly more efficient and robust to probing data.
We further validate the effectiveness of the proposed method in various applications, such as analyzing training dynamics as well as in federated and continual learning.
We hope our findings can help further explorations of real-time large-scale representational similarity analysis in neural networks.
I NTRODUCTION
Deep neural networks have shown unprecedented performance in a large variety of tasks (Krizhevsky et al., 2012; Ronneberger et al., 2015).
The cornerstone to the success is the deep representation learned by neural networks (NNs), which contains high-level semantic information about a task.
By viewing deep representation as to the characterization of each task in a highdimensional space, the representational similarity between a pair of deep models can be exploited to understand the intrinsic relationship between associated tasks.
In this way, the representational similarity provides a way to open the black box of deep learning by showing the training dynamics (Kornblith et al., 2019), and it further empowers machine learning systems with the ability to transfer knowledge from one task to another (Huang et al., 2021a).
Previous works (Raghu et al., 2017; Morcos et al., 2018) measure representational similarity directly relying on deep representations revealed by input data.
These approaches introduce heavy computation from both the forward pass of numerous stimulus inputs and the calculation of high-dimensional covariance matrices.
Since these similarity metrics are stimulus-dependent, their quality can potentially deteriorate when probing data are inappropriately chosen, scarce or unavailable.
We are inspired by the continual learning framework in Miao et al.
(2021), where a group of tasks is simultaneously modeled using NNs by learning for each task a different set of filter atoms while sharing common atom coefficients across tasks.
Miao et al.
(2021) has in detail analyzed and validated this framework in a continual learning context.
In the above setting, it is easy to observe that the representation variations across different NNs now become dominated by respective filter atoms.
Thus, Miao et al.
(2021) adopts in experiments filter subspace distance to assess task relevancy, however, without formal justification.
In this paper, we formally explore NN representational similarity using filter subspace distance, with detailed theoretical and empirical justifications.
We first simplify the filter subspace distance to the cosine distance of two sets of filter atoms, to eliminate heavy computation of singular value decomposition in calculating principal angles.
Then, we show both theoretically and empirically that the obtained filter atom-based similarity preserves a strong linear correlation with other popular stimulus-dependent similarity measures such as CCA (Raghu et al., 2017).
Our representational similarity is also immune to inappropriate choices of probing data, while stimulus-dependent metrics can be perturbed drastically.
The proposed filter atom-based similarity shows extreme efficiency in both memory and computation.
Since the similarity computation does not involve network forward pass, no GPU memory access is required, whereas other stimulus-based measures consume the same amount of GPU memory as regular inference.
On the other hand, the proposed method involves only inner product calculations on filter atoms, which takes neglectable time for similarity evaluation.
The evaluation time of stimulus-based measures includes the time of both the forward pass of probing data and the calculation of high-dimensional covariance matrices.
We report later the dramatically improved evaluation time of the proposed method against other popular method, e.g., CKA (Kornblith et al., 2019).
We further validate our atom-based similarity for knowledge transfer with various continual learning and federated learning tasks.
In both settings, we fix the atom coefficients, learn the filter atoms for each task, and finally conduct knowledge transfer among tasks by recalling the most similar models for the ensemble.
Compared with stimulus-based similarity metrics, the proposed measure achieves competitive performance with millions of times reduction in the computational cost.
We summarize our contributions as follows,
• We formally explore NN representational similarity measure using filter subspace distance.
• We show both theoretically and empirically that the proposed filter atom-based measure preserves a strong linear correlation with other popular stimulus-dependent measures while being significantly more robust and efficient in both memory and computation.
• We demonstrate the effectiveness of the proposed similarity measure under various example settings, such as analyzing training dynamics as well as in federated and continual learning.
M ETHODOLOGY
In this section, we first provide a filter subspace formulation for NNs and propose a model similarity metric based on a simplified filter subspace distance.
Then, we review stimulus-based representational similarities and show their limitations.
We further demonstrate that under certain assumptions, the proposed measure shows a strong linear relationship with popular stimulus-based measures, while exhibiting dramatic improvement in computational efficiency and data robustness.
These unique characteristics of the proposed measure can potentially enable real-time large-scale
NN similarity assessment, e.g., helping fast knowledge transfer across a large number of models.
2. R EPRESENTATIONAL S IMILARITY IN F ILTER S UBSPACE
Filter subspace.
As in Qiu et al.
(2018), the convolutional filter W ∈ R c ′ ×
c × k × k
( c ′ and c are the number of input and output channels, k is the kernel size) can be decomposed as m filter atoms
D [ i ] ∈
R k × k ( i = 1 , ..., m ) , linearly combined by atom coefficients α ∈ R m × c ′ × c as W = α × D .
The filter subspace is then expressed as V =
Span { D [1] , ..., D [ m ] } .
With this formulation, we consider a paradigm where atom coefficients are shared across different deep models while filter subspaces are model specific.
This paradigm has been in detail analyzed and validated in Miao et al.
and reports state-of-the-art performance in a continual learning context.
In this setting, we dive deep into the relationship between filter atoms and representations.
For simplicity, let c = c ′ = 1 , and the argument extends.
Given an input image X ( b ) ( b ∈ B , B ⊂ Z 2 ), define the local input norm ||
X || F,N b :=
( (cid:80) b ′ ∈ N b X ( b − b ′ ) 2 ) 1 / 2 and the convolution ⟨ X , w ⟩ N b := (cid:80) b ′ ∈ N b X
( b − b ′ )
w ( b ′ ) , where N b ⊂ B is a local Euclidean grid centered at b .
Then the decomposed convolution can be written as Z ( b )
= σ ( (cid:80) m i =
1 α i ⟨ X , D i ⟩ N b ) , where D [ i ] denotes the i -th atom, α i is the corresponded i -th coefficient.
Proposition 1.
Suppose D u and D v are two different sets of filter atoms for a convolutional layer with the common atom coefficients α , and the activation function σ is non-expansive, we can upper bound the changes in the corresponding features Z u , Z v with atom changes,
[Equation]
[Figure]
[Figure]
[Figure]
𝑫
[Figure]
[Figure] [Figure] [Figure]
[Figure]
Stimulus-based similarity
Atom
[Figure]
based similarity
[Figure]
The proof is provided in Appendix A.1.
We further empirically validate this relationship in Sec
Filter subspace similarity The above theorem suggests the possibility to measure the representational similarity of two CNNs by simply measuring the distance of their filter subspaces.
As proposed in Miao et al.
(2021), the representational similarity of two models with different filter subspaces V u , V v can be assessed by the similarity based on Grassmann distance between V u , V v as,
[Equation]
where θ i is the i -th principal angle between V u and V v .
However, the above metric requires costly singular value decomposition.
Note that filter atoms in different models are intrinsically aligned under shared atom coefficients, which allows us to approximate the filter subspace similarity using the cosine similarity of the corresponding filter atoms.
To this end, as shown in Figure 1, we propose a significantly simplified representational similarity measure with filter atom similarity.
Definition 1.
Suppose two convolution neural networks F u , F v share atom coefficients layer-wise which assume to be full-rank matrices, and their model-specific filter atoms are D u , D v , then the atom-based representational similarity is defined as,
[Equation]
The above definition is a layer-wise similarity, allowing us to compare the similarity of different networks per layer, and we simply average layer-wise similarities for the network-wise similarity.
We further show that S Atom and S Gras are equivalent under certain assumption.
Proposition 2.
Assume D u , D v ∈ R k 2 × m are orthogonal matrices, then S Gras = S Atom .
The proof is provided in Appendix A.1.
We empirically show in Figure 2(a) that the atom-based similarity has still a strong linear correlation with the Grassmann subspace similarity even without imposing the above orthogonality over atoms.
Note that our atom-based similarity measure only involves linear operations of vectorized atoms of around 100 dimensions, which requires neglectable computation.
Additionally, the proposed method depends solely on models themselves and eliminates the reliance on probing data, equipping our similarity with robustness to inappropriate choice of probing data.
[Figure]
2. R EPRESENTATIONAL S IMILARITY IN F EATURE S PACE
[Figure]
Intuitively, the representational similarity can be directly assessed via features generated from different neural networks.
As shown in Figure 1, it usually includes three steps to evaluate stimulus-based representational similarity between two NNs F u and F v : (1) Collect an appropriate and sufficient amount of probing data X p ∈ R n × c ′ ×
h ′ × w ′ that can represent the whole data distribution, (2) Generate the feature Z u and Z v ( Z u , Z v ∈ R n × c × h × w ) by the forward pass of probing data through different neural networks,
Z u = F u ( X p , θ u ) and Z v = F v ( X p , θ v ) , where θ u , θ v denote parameters of two NNs; (3) Choose a stimulus-based metric to assess the model similarity.
Several popular methods can be adopted in step (3), below we will give a brief introduction.
CCA.
Raghu
et al.
(2017) proposes to analyze the representational similarity by conducting canonical correlation analysis on two Z u , Z v , which is a recursive process of finding projection directions for two matrices that their correlation is maximized.
Specifically, let Q u , Q v denote the orthonormal bases of Z u , Z v , the CCA can be denoted as,
[Equation]
where σ l denotes the l -th eigenvalue of Λ u,v = Q ⊺ u Q v .
CKA.
Kornblith et al.
(2019) proposes another way to assess the similarity based on Centered
Kernel Alignment (CKA).
Let K u
=
Z u Z ⊺ u , K v =
Z v Z ⊺ v denote the Gram matrices of two feature space, the CKA is computed by,
[Equation]
where HSIC is the Hilbert-Schmidt Independence Criterion (Gretton et al., 2005).
However, in addition to the forward pass, all the aforementioned approaches further introduce significant computational costs while performing evaluation in the representation space.
Nevertheless, their qualities rely heavily on the mindful choice of probing data X p , which undermines their robustness.
2. A LGORITHM C OMPLEXITY A NALYSIS
Here, we provide a detailed comparison of computation complexity between the proposed atombased similarity and stimulus-based similarities.
Consider one convolutional layer with filter W ∈
R c ′ ×
c × k × k ( W = α × D , D ∈ R m × k × k ) which transforms the input X p ∈ R n × c ′ ×
h ′ × w ′ to output
Z ∈ R n × c × h × w .
The complexity of our method is dominated by inner product of two tiny filter atoms, O ( m · k 2 ) , e.g. , m = 9 , k = 3 in a typical setting.
In contrast, stimulus-based similarity measure first forward feed n probing samples with a complexity of O ( n · h ′ w ′ · k 2 · cc ′ ) , then calculates covariance matrix with complexity of O ( n 2 · hw · c ) .
In total, the time complexity of CCA is O ( n · h ′ w ′ · k 2 · cc ′ + n 2 · hw · c ) .
Our method is at least n · h ′ w ′ · k 2 · cc ′ + n 2 · hw · c m · ktimes more efficient than stimulus-based similarity measures.
As h ≫ k , cc ′ ≫ m , the computational cost of our method is negligible.
For example, with 10k probing datapoints, the CCA calculation requires 1 .
14 × 10 7 times more FLOPs than the proposed atom-based similarity.
2. R ELATIONSHIP WITH S TIMULUS - BASED S IMILARITIES
The proposed atom-based measure not only shows extreme efficiency, but also exhibits a linear relationship with other popular stimulus-based similarities.
Here, we analyze the proposed atom-based similarity S Atom with CCA S CCA (Raghu et al., 2017).
Suppose forward passes of decomposed convolutional layer for F u and F v are Z u
= α X
p D u , Z v = α X p D v , respectively.
To start with, we show that the S CCA is upper bounded by the proposed S Atom .
Theorem 1.
Let T =
Tr( X ⊺ p α ⊺ α X p ) , C =
σ min ( X ⊺ p α ⊺ α X p ) .
Assume K
( Z ⊺ u Z u ) , K ( Z ⊺ v Z v ) ≤ γ .
Then S CCA ( F u , F v ) is upper bounded by S Atom ( F u , F v ) ,
[Equation]
(6) where Tr( · ) denotes trace of a matrix, σ min indicates the minimum eigenvalue, K ( A ) denotes the condition number of matrix A .
We provide the proof in Appendix A.1.
Since S CCA is stimulus-dependent, the calculated value varies depending on the choice of probing data, and the value range shows bounded by our atom-based similarity, as in the theorem above.
With additional assumptions imposed, we can further show a simple linear relationship between
CCA and our atom-based similarity.
Assumption 1.
Suppose the diagonal elements of Z ⊺ u Z u , Z ⊺ u Z v and Z ⊺ v Z v are larger than nondiagonal element,
i.e., ( Z ⊺ u Z u ) ii
≫ ( Z ⊺ u Z u ) ij .
The Assumption 1 suggests different channels of feature Z have a low correlation.
Reducing channel-wise dependencies has been studied in Zhang et al.
and has been shown to benefit model stability.
Theorem 2.
If Assumption 1 holds, S CCA ( F u , F v ) is approximately linear to atom-based similarity, √
[Equation]
where γ 1 , γ 2 and γ 3 contain higher order of features, which can be found in detail with the proof in
Appendix A.1.
As in Figure 2, we empirically observe the linear correlation between CCA and atom-based similarity, which agrees with our theoretical findings.
In addition, we find that the proposed similarity also shows a strong correlation with CKA with different kernels.
E XPERIMENTS
In this section, we first validate our theorems with several simple experiments, and then demonstrate various applications of the proposed atom-based similarity in efficiently analyzing training dynamics as well as in federated and continual learning scenarios.
3. S IMPLE V ALIDATION E XPERIMENTS
We empirically validate that the change of features is bounded by the change of atoms, and the nearlinear relationship between atom-based and stimulus-based similarity.
Besides, we demonstrate the limit of stimulus-based similarities, as well as the verification of our assumption and theorems.
Representation dependency on filter atoms.
We first validate the dependency of deep features on filter atoms in Proposition 1 with a simple experiment.
The model F here is a 2-layer CNN with coefficient α and atom D generated from normal distribution N (0 , 1) .
The input sample X is also generated from normal distribution N (0 , 1) .
Figure 4(a) shows the relation between ∥ Z u − Z v ∥ F and ∥ D u − D v ∥ F by fixing coefficient α and input sample X and randomly varying filter atoms D .
[Figure]
All the points are below the line which is the bound provided by Proposition 1, reflecting that the representation variations are dominated by filter atoms.
Correlation of CCA and atom-based similarity.
We next empirically verify that CCA and atombased similarity have a strong correlation.
In this experiment, 10 tasks are generated from CIFAR100 (Krizhevsky et al., 2009) with 10 classes in each task.
Only the filter atoms of each task are trained while the atom coefficients are fixed.
We calculate CCA and atom-based similarity among 45 pairs of models.
The correlation between CCA and atom-based similarity is 0.8638 which is shown in Figure 2(b).
Similarly, the correlation between CKA and atom-based similarity is also reported in Figure 2 (Table).
These results clearly show that the proposed atom-based similarity has high linear relationship with popular stimulus-based similarities, which agrees with Theorem 1 and
Theorem 2.
Effect of channel decorrelation.
We further design a regularization term β (cid:80) i ̸
= j ( Z ⊺ u Z u ) 2 ij to approach ( Z ⊺ u Z u ) ii ≫ ( Z ⊺ u Z u ) ij in Assumption.
As shown in Figure 4(b), the correlation between
CCA and atom-based similarity keeps increasing as β increases.
The correlation reaches 0.985 when β = 3 × 10 − 3 , indicating a near-linear relationship, which is aligned with Theorem. 2.
Limitations of stimulus-based similarities.
Depending on stimulus data, the stimulus-based similarities can be inconsistent.
We expect a high value while evaluating the similarity between two models trained on the same dataset.
In this experiment, we train two models on CIFAR-100.
As shown in Figure 4 (Table), the CCA similarity of two models with stimuli from CIFAR-100 is 0.8793, but it drops to 0.4862 with stimuli from SVHN (Netzer et al., 2011).
The CKA similarity demonstrates the same inconsistency in values with different choices of stimuli.
However, our atom-based similarity of two models is 0.9136, which is aligned with our expectation.
3. L EARNING D YNAMICS
The atom-based similarity has various applications in analyzing NNs.
It is capable of reflecting the data similarity and measuring the evolution of model similarity during the training time.
We examine the training dynamics based on the heat map of atom-based similarities.
In this experiment,
AlexNet (Krizhevsky et al., 2012) is trained on CIFAR-100 (Krizhevsky et al., 2009) for 150 epochs and VGG11 (Simonyan & Zisserman, 2014) is fine-tuned on ImageNet (Russakovsky et al., 2015) for 20 epochs.
For both models, we train and store atoms at each epoch.
Figure 5 shows heat maps of similarities of the model among different training epochs.
Figure 5(a-c) are heat maps of the 1st, 3rd and 5th convolutional layers of Alexnet.
We mark the epoch when the parameters of each layer reaches 0.99 similarity with the their states in the last epoch.
The first layer reaches 0.99 similarity at epoch 36 which is earlier than final layers.
In Figure 5(d-f), VGG11 shows a similar behavior.
Several previous works have also indicated this bottom-up learning dynamics where layers closer to the input solidify into their final states faster than very top layers (Raghu et al., 2017; Morcos et al., 2018).
Our atom-based similarity provides a highly efficient way to examine the training dynamics while showing results in accord with previous studies.
Moreover, we can apply our method to calculate the similarity of a model
[Figure] [Figure]
[Figure]
trained on different tasks, so we can track the process of the same model interacting with different datasets.
The details are shown in Appendix A.2.
F EDERATED L EARNING
Federated learning (FL) aims at learning models collaboratively by leveraging the local computational power and data of all users with the concern of privacy (McMahan et al., 2017).
Personalized
Federated Learning (PFL) emerges to address some challenges in FL, such as poor convergence on heterogeneous data and lack of solution personalization (Tan et al., 2022).
In this setting, our framework achieves personalization by enforcing FL models with the shared atom coefficients for all users and specific filter atoms for each user.
As illustrated in Figure 7, the shared coefficients preserve the common knowledge, while user-specific atoms hold personalized information about each user.
Then, we can assess model relationships with our atom-based similarity without any stimuli data, which meets the privacy requirement of the FL scenario.
The shared atom coefficients can be achieved in different ways.
With our framework, the coefficient can be obtained from a model pre-trained on a public dataset or from a global model trained by other FL approaches.
We can also get the coefficients by training the model locally and evolving the coefficients at each communication round.
[Figure]
strategies: Models are selected with different similarity measures in each setting.
The model ensemble performance using our atom-based method is comparable with stimulus-based methods while being millions of times faster and consuming much fewer resources.
[Table]
[Table]
Measuring user similarity.
With the shared atom coefficients and user-specific filter atoms, we can simply get relations of users by calculating atom-based similarity.
To be specific, we expect that users with similar data have a higher similarity.
In this experiment, we combine two datasets,
CIFAR-100 (Krizhevsky et al., 2009) and SVHN (Netzer et al., 2011), and separate data onclients.
Specifically, SVHN are randomly split into 20 tasks and each task contains 5 classes;
CIFAR-100 are also split in the order of the class into 20 tasks and each task contains 5 classes.
20 clients are trained on 20 SVHN tasks, with each learning one task, while the other 100 clients are trained on 20 CIFAR-100 tasks, where every 5 clients equally share the data of one task by partitioning the data in a class-balanced way.
The models share the same random initialization and filter atoms are trained independently without communication with other clients.
The experimental details are described in Appendix A.2.
Figure 6 shows the atom-based similarity among last 40 clients of CIFAR-100 task and 20 clients of
SVHN task.
In Figure 6(c), where clients are trained for 90 epochs, we can clearly see the cluster of 20 SVHN clients: The SVHN clients have a higher similarity among themselves but are dissimilar from CIFAR clients.
Every 5 CIFAR clients who share the same task also have a high similarity among themselves.
We can see the cluster appears at the early stage of training in Figure 6(a)(b).
It can be applied to quickly find clusters in FL (Tan et al., 2022).
The full results of all 120 clients are shown in Appendix Figure 8.
We compare atom-based similarity with CCA and CKA.
Note that stimulus-based similarities need probing data which could violate the privacy requirement of FL.
The computational cost of three different approaches is shown in Figure 3.
Notably, calculating the atom-based similarity is significantly faster ( million times), requiring
GPU memory usage than stimuli-based methods.
Note that the advantages in computational efficiency of atom-based similarity become more prominent as the number of models increases.
Improving personalized model with ensemble of similar users.
Once we get the relationships of users, we can further improve the accuracy of the current model by the ensemble of similar models, which is effective to mitigate the data heterogeneity problem in FL.
The experiment is described in detail in Appendix A.2.
The final results are shown in Table 1.
With ensemble, the accuracies of all
FL methods can be improved.
Note that the results of model ensemble selected by our atom-based similarity are comparable with stimulus-based methods while consuming much fewer resources.
3. C ONTINUAL L EARNING
Continual learning is an open problem in machine learning in which data from multiple tasks arrive sequentially and the model is learned to adapt to new tasks while not forgetting the knowledge from the past (Parisi et al., 2019).
Note that some of the tasks in continual learning are related, so models trained with these tasks can be benefited from aggregating knowledge from each other.
We adopt the setting in Miao et al.
(2021), and apply atom-based similarity to find related models.
Specifically, we 10-Split CIFAR-100 dataset, where the 100 classes is broken down into 10 tasks with 10 classes per task.
We train AlexNet including atoms and atom coefficients on the first task, and train only the atoms on the following tasks.
Then, we calculate the task similarity with atom-based similarity, and report the model ensemble result with most similar members.
The accuracy and the similarity computation costs are shown in Table 2.
Our method provides higher results and has faster speed compared with stimulus-based methods.
R ELATED W ORK 4. M ODEL S IMILARITY
Representational similarity analysis (RSA) (Kriegeskorte et al., 2008) demonstrates the method of understanding brain activities by computing similarities between brain responses in different regions.
Measuring the similarity of models is beneficial for understanding neural network (NN) architectures and learning dynamics (Raghu et al., 2017; Kornblith et al., 2019;
Morcos et al., 2018;
Dwivedi & Roig, 2019).
Model similarity can be used to understand or incorporate various machine learning paradigms across different areas, including contrastive learning (Islam et al., 2021; Hua et al., 2021), knowledge distillation (Stanton et al., 2021), meta-learning (Raghu et al., 2019a), and transfer learning (Raghu et al., 2019b; Neyshabur et al., 2020; Bolya et al., 2021).
Multiple approaches are proposed to estimate the representational similarity of NNs.
Some early works show that individual neurons can capture meaningful information (Bau et al., 2017; Zeiler &
Fergus, 2014; Zhou et al., 2016; Bau et al., 2018).
Later, gradient-based methods emerge to provide a visual explanation of deep neural networks (Selvaraju et al., 2017).
Current popular representational similarity methods rely on features of NN.
Raghu et al. (2017) proposes SVCCA to measure similarity by calculating the covariance matrix of the features of each layer after channel alignments.
Kornblith et al. (2019) discusses the invariance properties of similarity indices and proposes CKA with consistent correspondences between layers.
Stimulus-based similarities are data-dependent and computationally expensive.
But our method measures the representational similarity only via atoms, a portion of model parameters, which is data-agnostic and much more efficient.
4. L EARNING P ARADIGM WITH N UMEROUS M ODELS
Some machine learning tasks involve numerous models.
For example, in Federated learning (Tan et al., 2022), thousands of models are trained across clients.
In Continual learning, there are multiple models generated across time (Kirkpatrick et al., 2017).
Federated learning (FL) aims to improve the performance of the system by continuously training and aggregating models from users without collecting data (McMahan et al., 2017; Smith et al., 2017; Kone ˇ cn ` y et al., 2016).
FL requires communication efficiency while thousands or even millions of clients may be involved (Li et al., 2020a).
It also required to achieve personalization (Tan et al., 2022; Huang et al., 2021b) considering data heterogeneity of different users (Li et al., 2020a; Kairouz et al., 2021).
Estimating user similarity can effectively address these challenges in FL.
Continual learning (CL) aims at providing long-term knowledge accumulation, and the main challenge is to avoid catastrophic forgetting by learning new tasks while remembering the old ones (Kirkpatrick et al., 2017; Aljundi et al., 2018; Lee et al., 2017; Zenke et al., 2017; Kolouri et al., 2019).
One promising way is to store neural networks for each task (Lopez-Paz & Ranzato, 2017;
Rusu et al., 2016; Yoon et al., 2018; Jerfel et al., 2019; Li et al., 2019).
As the number of tasks increases, a large number of models are generated and stored.
It is important to find a way to access their relations to reuse models.
C ONCLUSION
In this paper, we proposed a new paradigm for reducing representational similarity analysis in CNNs to filter subspace distance assessment.
We provided both theoretical and empirical evidence that the proposed filter subspace-based similarity exhibits a strong linear correlation with popular stimulusbased metrics, while being significantly more efficient and robust in probing data.
It was evaluated on both federated learning and continual learning tasks, and achieves competitive performance with millions of times reduction in computational cost.
Our method currently assumes respective layers among compared CNNs to have coefficients with the same dimension.
For our future work, we will explore the way to share coefficient among layers to achieve atom-based similarity with different dimensions.
A A PPENDIX A. T HEORETICAL P ROOFS
Proposition 1.
Suppose D u and D v are two different sets of filter atoms for a convolutional layer with the common atom coefficients α , and the activation function σ is non-expansive, we can upper bound the changes in the corresponding features Z u , Z v with atom changes,
[Equation]
Proof.
Recall the decomposed convolution can be expressed as,
[Equation]
Since σ is non-expansive [Equation] ∀ b we have,
[Equation]
By Cauchy-Schwarz inequality
[Equation]
we have that [Equation] [Equation] and observe that (cid:88)
[Equation]
i
[Equation]
where |B| is the area of the domain of X .
Then Eq.
12 becomes
[Equation]
which proves that || Z u − Z v || F ≤ ( || α || F λ ) (cid:112) |B| · || ( D u − D v ) || F as claimed.
Proposition 2.
Assume filter atoms D u , D v are orthogonal matrices, then S Gras = S Atom .
Proof.
Since D u , D v ∈ R k 2 × m are orthogonal matrices, i.e., D Tu D u = D Tv D v
= I , the Grassmann similarity can be represented as,
[Equation]
where σ i = Σ ii , U Σ V =
D
Tu D v .
S Atom is defined as,
[Equation]
[Equation]
Analyze each part separately, we have < vec ( D u ) , vec ( D v ) > =
Tr( D Tu D v ) =
(cid:80) mi σ i , || vec ( D u ) ||
F = (cid:112)
Tr( D Tu D u ) =
(cid:112)
Tr( I ) = √ m , and also || vec ( D v ) || F = √ m .
In total, the atom-based similarity becomes,
[Equation]
which equals S Gras .
The claimed theorem is proved.
Lemma 1.
For two positive semidefinite matrices A , B ,
[Equation]
where σ min denotes the minimum eigenvalue of A .
Proof.
It is equivalent to prove that,
[Equation]
Let C , D be matrices such that A − σ min ( A )
I = C ⊺ C , B
= D ⊺ D , then
[Equation]
Theorem 1.
Suppose the forward of decomposed convolution layer for the u -th model is Z u = α XD u .
Z u , Z v nearly have zero-mean since X p is preprocessed to be normalized.
CCA coefficient is defined as S ( Z u , Z v ) =
(cid:113) 1 c (cid:80) ci =1 σ 2 i , where σ 2 i denotes the i -th eigenvalue of Λ u,v = Q u ⊺ Q v ,
Q u =
Z u ( Z ⊺ u Z u ) − 12 .
Then S ( Z u , Z v ) is upper bounded,
[Equation]
where T =
Tr( X ⊺ α ⊺ α X ) , C =
σ min ( X ⊺ α ⊺ α X ) .
Proof.
Consider S 2 = 1 c (cid:80) ci =1 σ 2 i .
[Equation]
[Equation]
22) where
[Equation]
As defined above, we have
[Equation]
Then Equation 23 becomes,
[Equation] [Equation]
By Cauchy-Schwartz Inequality,
[Equation]
Then we analyze these terms individually,
[Equation]
As for Tr(( Z ⊺ u Z u ) − 1 ) , let λ 1 , λ 2 , ..., λ c be eigenvalues for Z ⊺ u Z u listed in descending order ( λ 1 ≥ λ 2 ≥ ... ≥ λ c ), and assume the condition number of Z ⊺ u Z u and Z ⊺ v Z v satisfy λ max /λ min ≤ γ , then,
[Equation] [Equation]
where λ 1 = ||
Z ⊺ u Z u
|| 2 , || · || 2 denotes the operator norm induced by the vector L 2 -norm.
With the norm inequalities of any positive semidefinite matrix A ,
[Equation]
(29) where || · || F , ||
· || ∗ denote the Frobenius norm and the nuclear norm, respectively.
Equation (30) then becomes,
[Equation]
By Lemma 1,
[Equation]
where vec ( · ) denotes vectorization of a matrix
[Equation]
Then Equation 30 is further derived as,
[Equation]
Similarly, we have
[Equation]
Finally, with Tr( D ⊺ u D v ) =
< vec ( D u ) , vec ( D v ) >
[Equation]
we have
[Equation] [Equation]
and thus,
[Equation]
Then the claimed theorem is proved.
Lemma 2.
For two matrices A , B , their frobenius norm satisfies,
[Equation]
where ∆
[Equation]
B
[Equation]
[Equation]
Proof.
According to the definition of frobenius norm ∥ A ∥ F = (cid:113)(cid:80) ij |
A ij | 2 we have,
[Equation]
Note that ( (cid:80) i x i y i )
=
( (cid:80) i x 2 i )( (cid:80) i
y 2 i ) · cos 2 ( ⟨ x, y ⟩ )
=
( (cid:80) i x 2 i )( (cid:80) i y 2 i ) − ( (cid:80) i x 2 i )( (cid:80) i
y 2 i ) · sin 2 ( ⟨ x, y ⟩ ) , where ⟨ x, y ⟩ is the angle of two vectors x and y .
We have,
[Equation]
where A i : is the i -th row of A and B : j is the j -th column of B , ∆ 1 = (cid:80) ij ( (cid:80)
k
A 2 ik )( (cid:80) k B 2 kj ) · sin 2 ( ⟨ A i : , B : j ⟩ ) .
As A i : and B : j are more correlated, ⟨ A i : , B : j ⟩ −→ 0 , thus, ∆ 1 ≪ ∥
A ∥ 2 F ∥ B ∥ 2 F .
Lemma 3.
[Equation]
Proof.
According to Lemma 2, we have,
[Equation]
Thus,
[Equation]
where ∆ 1 A 1 / 2 = (cid:80) ij ( (cid:80) k
( A 1 / 2 ) 2 ik )
( (cid:80) k
( A 1 / 2 ) 2 kj ) · sin 2 ( ⟨ ( A 1 / 2 ) i : , ( A 1 / 2 ) : j ⟩ ) .
As ( A 1 / 2 ) i : and ( A 1 / 2 ) : j are more correlated, ⟨ ( A 1 / 2 ) i : , ( A 1 / 2 ) : j ⟩ −→ 0 , thus, ∆ 1 A 1 / 2 ≪ ∥
A ∥ 2 F .
Lemma 4.
For three matrices A , B , and C , their frobenius norm satisfies,
[Equation]
42) where ∆ 2 = 12 [ ∥
A
[Equation]
+
[Equation]
ik
[Equation]
kl ) · sin 2 (
[Equation]
A i : , B : l ⟩ )] and ∆
[Equation]
BC
[Equation]
sin
[Equation] [Equation]
BC )
[Equation]
⟩ ) + (cid:80) ij ( (cid:80) l ( AB ) 2 il )( (cid:80) l C 2 lj ) · sin 2 ( ⟨ ( AB ) i : , C : j ⟩ )] .
Proof.
Based on Lemma 2, we have,
[Equation]
[Equation]
Symmetrically, we also have,
[Equation] [Equation]
Thus
[Equation]
ABC
[Equation]
A ∥ 2 F ∥ B ∥ 2 F ∥ C ∥ 2 F − ∥ C
∥ 2 F (cid:88) il ( (cid:88) k
A 2 ik )( (cid:88) k
B 2 kl ) · sin 2 ( ⟨ A i : , B : l ⟩ ) − (cid:88) ij ( (cid:88) l ( AB ) 2 il )
( (cid:88) l
C 2 lj ) · sin 2 ( ⟨ ( AB ) i : , C : j ⟩ )] =
∥
A ∥ 2 F ∥ B ∥ 2 F ∥ C ∥ 2 F − ∆ 2 − ∆ 3 , (45) where ∆ 2 = 12 [ ∥
A ∥ 2 F (cid:80) kj ( (cid:80) l B 2 kl )( (cid:80) l C 2 lj ) · sin 2 ( ⟨ B k : , C : j ⟩ ) + ∥ C ∥ 2 F (cid:80) il ( (cid:80)
k
A 2 ik )( (cid:80) k B 2 kl ) · sin 2 ( ⟨ A i : , B : l ⟩ )] and ∆= 1 2 [ (cid:80) ij ( (cid:80) k
A 2 ik )( (cid:80) k ( BC ) 2 kj ) · sin 2 ( ⟨ A i : , ( BC ) : j ⟩ ) + (cid:80) ij ( (cid:80) l ( AB ) 2 il )( (cid:80) l C 2 lj ) · sin 2 ( ⟨ ( AB ) i : , C : j ⟩ )] .
Therefore,
[Equation]
As A i : and B : l , B k : and C : j are more correlated, ⟨ A i : , B : l ⟩ , ⟨ B k : , C : j ⟩ , ⟨ A i : , ( BC ) : j ⟩ , ⟨ ( AB ) i : , C : j ⟩ −→ 0 , thus, ∆ 2 ≪ ∥
A ∥ 2 F ∥ B ∥ 2 F ∥ C ∥ 2 F and ∆ 3 ≪ ∥
A ∥ 2 F ∥ B ∥ 2 F ∥ C ∥ 2 F .
Lemma 5.
[Equation]
where κ F ( A 1 / 2 ) and κ F ( C 1 / 2 ) are the condition number of A 1 / 2 and C 1 / 2 , κ F ( A 1 / 2 )
= (cid:113) ( (cid:80) σ {+
+}
i ( A 1 / 2 ))
( (cid:80)
[Equation]
A
[Equation]
and κ F ( C 1 / 2 ) =
(cid:113) ( (cid:80) σ
[Equation]
( C
[Equation]
( (cid:80) 1 σ
[Equation]
i ( C
[Equation]
) ; σ 2 i ( A [Equation] 2 ) are singular value of A 1 / 2 and σ 2 i ( C 1 / 2 ) are singular value of C 1 / 2 .
Proof.
Based on Lemma 4, we have,
[Equation]
By the definition of condition number κ
[Equation]
Theorem 2.
Suppose the forward of decomposed convolution layer for the u -th model is Z u = α XD u , CCA coefficient be S ( Z u , Z v )
=
(cid:113) 1 c (cid:80) ci =1 σ 2 i , where σ 2 i denotes the i -th eigenvalue of Λ u,v = Q u ⊺ Q v , Q u
= Z u
( Z ⊺ u Z u ) − 12 .
Then S ( Z u , Z v ) is approximately linear to atom-based similarity,
[Equation]
Proof.
Based on S ( Z u , Z v ) =
(cid:113) 1 c (cid:80) ci =1 σ 2 i and ∥
Λ u,v ∥ F = (cid:112)(cid:80) ci =1 σ 2 i , where σ i are the singular value of Λ u,v ,
[Equation]
According to Lemma.
5, we have
[Equation]
(52) where γ 1 = κ F (( Z ⊺ u Z u ) 12 ) ·
κ F (( Z ⊺ v Z v ) 12 ) and γ 2 = (cid:113) 1 −
[Equation]
As Z u = α XD u and Z v = α XD v , we have
[Equation]
According to Lemma
[Equation]
where γ 3 =
(1 +
[Equation]
As Assumption 1 holds
[Equation]
it becomes
[Equation]
Thus
[Equation]
we have
[Equation]
A. E XPERIMENT S ETTINGS
Model training of Federated Learning.
In each experiment we have 100 clients in total and sample a ratio r = 0 .
1 of all the clients on every round.
All models are randomly initialized and trained for T = 100 communication rounds for the CIFAR datasets.
At each round, the client executes 15 epochs of SGD with momentum to train the local model, the learning rate is 0.01 and momentum is 0.9.
Accuracies are computed by taking the average local accuracies for all users at the final communication round.
As shown in the Table 3, we have different settings for CIFARand CIFAR-100.
For example, (100 , 2) means 100 clients with 2 classes on each client.
For each method, the training takes about 12 hours on Nvidia RTX A5000.
[Figure]
CIFARCIFAR-
[Table]
FedAvg 82.
FedProx 80.
FedPer 81.
FedRep 72.
[Table]
Local 81.
Ours 81.
[Figure]
Evolving shared atom coefficients.
we can get shared atom coefficients by evolving them during the communication, apart from pre-trained models or from other FL approaches.
In FL, the server aggregates models from every involved client at each communication round.
Our method enforces the model with a shared atom coefficient and atoms.
At each communication round, the clients perform training on both atoms and atom coefficients with locally stored data.
Then, the server aggregates only the atom coefficients of selected clients to get an updated coefficient.
In this way, we can get a shared coefficient across clients.
Comparison with other FL approaches.
We compare our approach by evolving shared atom coefficients with various personalized federated learning methods and federated learning methods with local finetuning.
Among these methods, FedPer (Arivazhagan et al., 2019) and FedRep(Collins et al., 2021) have the similar ideas by learning shared global representation and personalized local heads.
Ditto (Li et al., 2021) and FedProx (Li et al., 2020b) induce global regularization to improve the model performance.
We also compare our method with FedAvg (McMahan et al., 2017).
FedRep (Collins et al., 2021) approaches the common knowledge with shared representation.
The codes are adapted from 1 .
We evaluate the test accuracy on CIFAR-10 and CIFAR-100 with different FL setting.
As shown in Table 3, our method achieves comparable performance among different methods.
Fine-tuning models for ensemble.
We select 3 models with different similarity measures for ensemble.
For feature-based similarity methods, we randomly select 1000 examples from CIFARdataset.
The fully-connected layer of each model is fine-tuned on the user’s local data withepochs.
The fine-tuning takes about 12 hours on Nvidia RTX A5000.
After fine-tuning, the accuracy is measured on local test data, with the predictions of current model and 3 selected models.
Similar representations across datasets.
Similar to (Kornblith et al., 2019), we can use atombased similarity to compare networks trained on different datasets.
In Figure 9(a), we show that pairs of models that are both trained on CIFAR-10 and CIFAR-100 have high atom-based similarities.
Models learned on two datasets respectively still show high similarity.
In contrast, similarities between trained and untrained models are significantly lower.
A t o m - b a s e d
S i m il a r it y
[Figure]
z 𝑧 =
[Figure]
𝑦 − 𝑥 + 𝜖
[Figure]
[Figure]
Limitation of stimulus-based methods.
As shown in Figure 9(b), to illustrate sensitivity of stimulus-based similarities to probing data
[Figure]
we perform a simple regression task with data, { ( x i = 0 , y i , z i ) } ni =1 , where z i = f
( x i , y i )
+ ϵ i and y i , ϵ i ∼ N (0 . 5 , 0 . 1) .
Two NN models F 1 and Fwith the same initialization and atom coefficients are trained for their different atoms to learn
F : ( X, Y ) −→ Z .
It is can be simply found that the atom-based similarity of F 1 and F 2 isand the stimulus-based similarity is also 1 with the same { ( x i = 0 , y i ) } as the probing data.
However, if we choose { ( x ′ i =
y i , y ′ i = 0) } as the stimuli data, then the stimulus-based similarities directly become 0 as the data are now orthogonal to model parameters.
Training dynamics.
We investigate the training dynamics of AlexNet (Krizhevsky et al., 2012) and VGG (Simonyan & Zisserman, 2014) separately on CIFAR-100 (Krizhevsky et al., 2009) and
ImageNet (Russakovsky et al., 2015).
The details of training dynamics of models with atoms from different time point during the training are shown in Figure 10 and Figure 11.
Moreover, we examine the similarity between the two participated models shared the same initialization trained only with atoms on two different tasks.
The results is shown in Figure 12 and Figure 13.
The difference is less
[Figure]
[Figure]
on the first few layers, but more on the middle layers.
It reflects the middle layer is more critical than other layers, which is aligned with previous work (Neyshabur et al.,
[Figure]