Representation Topology Divergence: A Method for Comparing Neural Network Representations.

1 INTRODUCTION . Representations of objects are the essential component learnt by deep neural networks . In opposite to the distance in the original space , similarity of representations are proved to be semantically meaningful . Despite of the significant practical success of deep neural networks many aspect of their behaviour are poorly understood . Only few methods study learned representations without relying on their quality on a specific downstream task . In this work , we focus on the comparison of representations from neural networks . Comparison of representations is an ill-posed problem without a “ ground truth ” answer . Early studies were based on variants of Canonical Correlation Analysis ( CCA ) : SVCCA , ( Raghu et al. , 2017 ) , PWCCA ( Morcos et al. , 2018 ) . Hovewer , CCA-like measures define similarity too loosely since they are invariant to any invertible linear transformation . The Centered Kernel Alignment ( CKA ) , ( Kornblith et al. , 2019 ) is the statistical test to measure the independence of two sets of variables . ( Kornblith et al. , 2019 ) proved it to be more consistent with the intuitive similarity of representations . Particularly , neural networks learn similar representation from different seeds as evaluated by CKA . Another line of work studies alignment between groups of neurons ( Li et al. , 2015 ) , ( Wang et al. , 2018 ) . The similarity of representation is also a topic of a study in neuroscience ( Edelman , 1998 ; Kriegeskorte et al. , 2008 ; Connolly et al. , 2012 ) . Representations ’ comparison metrics like CKA and CCA were used to gain insights on representations obtained in meta-learning ( Raghu et al. , 2020 ) , to compare representations from different layers of language models ( Voita et al. , 2019 ) , study the effect of fine-tuning ( Wu et al. , 2020 ) . Finally , ( Nguyen et al. , 2021 ) used CKA to study the phenomenon of a “ block structure ” emerging in wide and deep networks in computer vision and compare their representations . In this paper , we take a topological perspective on representations ’ comparison . We propose the Representation Topology Divergence ( RTD ) score which measures a dissimilarity between two point clouds of equal size with one-to-one correspondence between points . Point clouds are allowed to lie in different ambient spaces . Existing geometrical and topological methods are dedicated to other problems : they are either too general and doesn ’ t incorporate the requirement of one-to-one correspondence ( Khrulkov & Oseledets , 2018 ) , ( Tsitsulin et al. , 2020 ) , or they restrict point clouds to lie in the same ambient space ( Kynkäänniemi et al. , 2019 ) , ( Barannikov et al. , 2021 ) . Such methods ( except for ( Tsitsulin et al. , 2020 ) ) are mostly applied to the evaluation of GANs , where point clouds of real and generated objects are matched . Recently , ( Moor et al. , 2020 ) proposed a loss term to compare a topology of data in original and latent spaces ( with natural one-to-one correspondence ) and applied it as a part of the Topological Autoencoder . In this work , we make the following contributions : 1 . We propose a topologically-inspired approach for comparison of neural network representations ; 2 . We introduce the R-Cross-Barcode ( P , P̃ ) , a tool based on Topological Data Analysis ( TDA ) which measures differences in multi-scale topology of two point clouds P , P̃ with one-to-one correspondence between points ; 3 . Based on the R-Cross-Barcode ( P , P̃ ) , we define the Representation Topology Divergence ( RTD ) , the scalar measuring the multi-scale topological dissimilarity between two representations ; 4 . By doing computational experiments , we show that RTD agrees with an intuitive notion of neural network representations similarity . In contrast with most existing approaches , RTD score is sensitive to cluster and other topological structures of the representations and enjoys very good correlation with disagreement of models predictions . We apply RTD to compare representations in computer vision and NLP domains and various problems : training dynamics analysis , data distribution shift , transfer learning , ensemble learning , disentanglement . We have also compared RTD with CKA , IMD and SVCCA . 2 COMPARING NEURAL NETWORK REPRESENTATIONS . Our starting point is the geometric perspective on representation learning through the lens of the manifold hypothesis ( Goodfellow et al. , 2016 ) , according to which real-world data presented in a high dimensional space are expected to concentrate in vicinity of a manifold of much lower dimension . The low-dimensional manifoldMP underlying the given data representationP can be accessed generally only through discrete sets of samples . The standard approach to recover the manifold MP is to take a sample P and to approximateMP by a set of simplices with vertices from P . A common approach to select the simplices approximating MP is to fix a threshold α > 0 and consider the simplices with edge lengths not exceeding α ( Niyogi et al. , 2008 ; Belkin & Niyogi , 2001 ) . It is difficult in general to guess the correct value of the threshold , hence a reasonable viewpoint is to study all thresholds at once , see e.g . ( Chazal & Michel , 2017 ) . This can be accomplished by means of the mathematical tool , called barcode , that quantifies the evolution of manifold topology features over multiple scales . Given two representations , we consider two corresponding graphs with distance-like weights and compare the difference in the two graphs ’ multiscale topology . 2.1 R-CROSS-BARCODE . Let P ( V ) , P̃ ( V ) be two representations giving two embeddings of the same data . The two embeddings P , P̃ belong in general to different ambient spaces and we have the natural one-to-one correspondence between points in P and P̃ . Given a sample of data V ⊆ V , the representation P = P ( V ) defines the weighted graph Gw with the vertex set V . The weight wAB of an edge AB is given by the distance between points P ( A ) and P ( B ) . Similarly the representation P̃ = P̃ ( V ) defines the weighted graph Gw̃ on the same vertex set . The simplicial approximation to the manifold MP at threshold α consists of simplices whose edges in Gw have weights not exceeding α . Let Gw≤α denote the graph with the vertex set V and the edges with weights not exceeding α . To compare the simplicial approximations to manifolds MP and MP̃ described by the graphs Gw≤α and Gw̃≤α we embed both graphs into the graph Gmin ( w , w̃ ) ≤α . The graph Gmin ( w , w̃ ) ≤α contains an edge between vertices A and B exactly when the distance between the points A and B is smaller than α in at least one of the representations P , P̃ . Recall that Vietoris-Rips complex of a graph G equipped with edge weights ’ matrix m is the collection of k−simplices , k ≥ 0 , which are ( k + 1 ) −elements subsets of the set of vertices of G , with the filtration threshold of a simplex defined by its edges ’ maximal weight : Rα ( Gm ) = { { A0 , . . . , Ak } , Ai ∈ Vert ( G ) ‖mAjAl ≤ α } Our simplicial approximations to the manifolds MP , MP̃ at threshold α are the unions of all simplices from the simplicial complexes Rα ( Gw ) , Rα ( Gw̃ ) . The dissimilarity between the filtered simplicial complexes Rα ( Gw ) and Rα ( Gw̃ ) can be quantified using the homological methods . The relevant tools here are the homology , the Whitehead theorem and the homology exact sequence . Because of the space limitations we sketch how this leads to our construction , described below , in the Appendix , Section B . Concretely , to compare the multi-scale topology of the two weighted graphs Gw and Gw̃ we introduce the weighted graph Ĝ ( w , w̃ ) with doubled set of vertices and with the edge weights defined as follows . For each vertex A ∈ Vert ( G ) we add the extra vertex A′ together with A to Ĝ and define the distance-like edge weights in Ĝ ( w , w̃ ) as : dAB = min ( wAB , w̃AB ) , dAB′ = dA′B = wAB , dAA′ = 0 , dA′B′ = 0 ( 1 ) where B ∈ Vert ( G ) , A 6= B . In practice G , Ĝ are full graphs and the edge weights on the graph Ĝ ( w , w̃ ) are given by 2N × 2N , N = |V | , symmetric matrix m = ( 0 w w min ( w , w̃ ) ) ( 2 ) where w and w̃ are the distance-like edge weights matrices of Gw and Gw̃ . Next , we construct the Vietoris-Rips filtered simplicial complex from the graph Ĝ ( w , w̃ ) . Intuitively , the i−th barcode of Rα ( Ĝ ( w , w̃ ) ) records the i−dimensional topological features that are born in Rα ( Gw̃ ) but are not yet born at the same place in Rα ( Gw ) and the ( i+ 1 ) −dimensional topological features that are dead inRα ( Gw̃ ) but are not yet dead at this place inRα ( Gw ) , see Theorem 1 below . Definition . The R-Cross-Barcodei ( P , P̃ ) is the set of intervals recording the “ births ” and “ deaths ” of i-dimensional topological features in the filtered simplicial complex Rα ( Ĝ ( w , w̃ ) ) . The R-Cross-Barcode∗ ( P , P̃ ) ( for Representations ’ Cross-Barcode ) records the differences in multiscale topology of the two embeddings . The topological features with longer lifespans indicate in general the essential features . Theorem 1 . Basic properties of R-Cross-Barcode∗ ( P , P̃ ) : • if P ( A ) = P̃ ( A ) for any object A ∈ V , then R-Cross-Barcode∗ ( P , P̃ ) = ∅ ; • if all distances within P̃ ( V ) are zero i.e . all objects are represented by the same point in P̃ , then R-Cross-Barcode∗ ( P , P̃ ) = Barcode∗ ( P ) the standard barcode of the point cloud P ; Algorithm 1 R-Cross-Barcodei ( P , P̃ ) Input : w , w̃ : matrices of pairwise distances within point clouds P , P̃ Require : vr ( m ) : function computing filtered complex from pairwise distances matrix m Require : B ( C , i ) : function computing persis- tence intervals of filtered complexC in dimension i m← ( 0 w w min ( w , w̃ ) ) R-Cross-Barcodei ← B ( vr ( m ) , i ) Return : intervals ’ list R-Cross-Barcodei ( P , P̃ ) representing ” births ” and ” deaths ” of topological discrepancies between P and P̃ . Algorithm 2 RTD ( P , P̃ ) , see section 2.3 for details , suggested default values : b = 500 , n = 10 Input : P ∈ R|V|×D , P̃ ∈ R|V|×D̃ : data representations for j = 1 to n do Vj ← random choice ( V , b ) Pj , P̃j ←P ( Vj ) , P̃ ( Vj ) Bj ← R-Cross-Barcode1 ( Pj , P̃j ) intervals ’ list calculated by Algorithm 1 rtdj ← sum of lengths of all intervals in Bj end for RTD ( P , P̃ ) ← mean ( rtd ) Return : number RTD ( P , P̃ ) representing discrepancy between the representations P , P̃ • for any value of threshold α , the following sequence of natural linear maps of homology groups . . .→ Hi ( Rα ( Gw ) ) → Hi ( Rα ( Gmin ( w , w̃ ) ) ) → Hi ( Rα ( Ĝ ( w , w̃ ) ) ) → → Hi−1 ( Rα ( Gw ) ) → Hi−1 ( Rα ( Gmin ( w , w̃ ) ) ) → . . . ( 3 ) is exact ; recall that it means that the kernel of any map is the image of the previous map The proof of the first two properties is immediate and the third property follows from the exactness of the corresponding sequence of simplicial complexes , see Appendix for more details .

Summary: In this paper, the authors proposed a method called “representation topology divergence (RTD)” for comparing structured data (e.g., point clouds and sets of embeddings derived by neural networks). The authors applied RTD to various machine learning tasks and compared it with other classic similarity measurements of structured data (e.g., CKA, SVCCA, IMD). Experimental results verify the rationality of the proposed method.