Neural models learn representations of high-dimensional data on low-dimensional manifolds. Multiple factors, including stochasticities in the training process, model architectures, and additional inductive biases, may induce different representations, even when learning the same task on the same data. However, it has recently been shown that when a latent structure is shared between distinct latent spaces, relative distances between representations can be preserved, up to distortions. Building on this idea, we demonstrate that exploiting the differential-geometric structure of latent spaces of neural models, it is possible to capture precisely the transformations between representational spaces trained on similar data distributions. Specifically, we assume that distinct neural models parametrize approximately the same underlying manifold, and introduce a representation based on the pullback metric that captures the intrinsic structure of the latent space, while scaling efficiently to large models. We validate experimentally our method on model stitching and retrieval tasks, covering autoencoders and vision foundation discriminative models, across diverse architectures, datasets, and pretraining schemes.
Figures & tables
Figure 1: Neural models trained on similar data learn parametrizations of the same manifold. NNs learn parametrizations ( D1,D2 ) of the same underlying manifold Y up to isometries T . Pulling back the metric from Y makes relative geodesic representations invariant to transformations T between latent spaces Z1 and Z2 .
Figure 2: Pairwise latent-space energy matrices for (a) MNIST and (b) CIFAR-10. In each subfigure, the left heatmap shows the straight-line energy approximation and the right shows the geodesic energies of the ground truth geodesic curve. The Spearman rank correlations between the two measures are ρ=0.99 for MNIST and ρ=1.00 for CIFAR-10, demonstrating near-perfect agreements.
Figure 3: Aligning latent spaces of autoencoders : MRR score as a function of the number of anchors on pairs of autoencoders trained with different initializations on the MNIST (left), FashionMNIST (center), CIFAR10 (right) datasets, respectively. In green, we plot the performance of Moschella et al. (2023) ; in red and orange the linear and orthogonal baselines respectively; in blue, our method. The shaded area indicates standard deviation across 5 different random sets of anchors. Relative geodesic consistently outperforms baselines, obtaining peak performance.
Figure 4: Stitching on Autoencoders : We visualize qualitative reconstructions of samples, stitching autoencoders of models trained with different initializations on MNIST (left), FashionMNIST (center), CIFAR10 (right). The first two columns show reconstructions from the original models; middle three columns represent baselines ( Maiorca et al., 2024 ; Moschella et al., 2023 ) ; the rightmost column is our method. Relative geodesic yields the best stitching results using just 5 anchors.
Method
CIFAR-10
CIFAR-100
ImageNet-1k
CUB
SVHN
Rel(Cosine) ( Moschella et al., 2023 )
0.129±0.135
0.166±0.162
0.221±0.178
0.135±0.148
0.068±0.08
RelGeo( L2 )
0.047±0.013
0.112±0.031
0.412±0.09
0.28±0.129
0.025±0.012
RelGeo(Diet)
0.387±0.145
0.445±0.142
0.566±0.111
0.523±0.177
0.314±0.188
Table 1: Average MRR cosine results for different methods across different datasets. Relative representations pulling back from diet decoder ( RelGeo(Diet) ) consistently provides better retrievals.
Figure 5: CUB Accuracies (top) and symmetricized MRR cosine (bottom). RelGeo(Diet) and especially RelGeo( L2 ) provide strong stitching accuracies, while RelGeo(Diet) maintains strong instance identifiability.
Method
CIFAR-10
CIFAR-100
ImageNet-1k
CUB
SVHN
Rel(Cosine) ( Moschella et al., 2023 )
0.907±0.09
0.775±0.132
0.549±0.152
0.531±0.188
0.384±0.115
RelGeo( L2 )
0.955±0.03
0.874±0.055
0.501±0.159
0.595±0.163
0.59±0.054
RelGeo(Diet)
0.915±0.074
0.775±0.115
0.479±0.17
0.559±0.171
0.416±0.079
Table 2: Average stitching performances across different settings. RelGeo( L2 ) often outperforms Rel(Cosine) , while RelGeo(Diet) remains competitive.
Figure 6: Matching multimodal models. Symmetricized MRR cosine on Flickr30k. RelGeo(Diet) substantially improves upon Rel(Cosine) in aligning multimodal models.
Appendix figures & tables40 assets
Supplementary material from the paper’s appendix.
Appendix
Encoder
3×3 conv. 32 stride 2-ReLu
3×3 conv. 64 stride 2-ReLu
Flatten
(64∗k∗k)×h Linear
Latents
Decoder
Appendix
Table 3: Architecture of the convolutional autoencoders.
Table 10
Encoder
Activation
Conv2d(1, 32, kernel = 3, stride=2, pad=1)
ReLU
Conv2d(32, 64, kernel = 3, stride=2, pad=1)
ReLU
Flatten
—
Linear(6477, d )
—
Decoder
Activation
Linear( d , 6477)
ReLU
Appendix
Table 6: ConvAutoencoder architecture (latent dim d ).
Figure 7: Pairwise latent-space energy matrices for (a) MNIST and (b) CIFAR-10, with latent dimensionality 2. In each subfigure, the left heatmap shows the straight-line energy proxy and the right shows the full Riemannian geodesic energies. The Spearman rank correlation between the two measures is 0.99 for MNIST and ρ=1.00 for CIFAR-10, demonstrating near-perfect agreement.
Figure 8: Impact of varying discretization levels on similarity and energy metrics for (a) MNIST and (b) CIFAR - 10 datasets. Each subplot shows how Spearman’s ρ , Pearson’s r , and Euclidean distance change as the number of discretization levels increases.
Figure 9: Results on CIFAR-10. From top to bottom: Accuracy, MRR Cosine Sym, MRR CDist Sym, MRR Cosine, MRR CDist
Figure 10: Results on CIFAR-100. From top to bottom: Accuracy, MRR Cosine Sym, MRR CDist Sym, MRR Cosine, MRR CDist
Figure 11: Results on ImageNet-1k. From top to bottom: Accuracy, MRR Cosine Sym, MRR CDist Sym, MRR Cosine, MRR CDist
Figure 12: Results on CUB. From top to bottom: Accuracy, MRR Cosine Sym, MRR CDist Sym, MRR Cosine, MRR CDist
Figure 13: Results on SVHN. From top to bottom: Accuracy, MRR Cosine Sym, MRR CDist Sym, MRR Cosine, MRR CDist
Method
CIFAR-10
CIFAR-100
ImageNet-1k
CUB
SVHN
Rel(Cosine) [ Moschella et al., 2023 ]
0.098±0.133
0.122±0.164
0.103±0.146
0.046±0.055
0.046±0.081
RelGeo(L2)
0.046±0.013
0.105±0.031
0.179±0.173
0.187±0.141
0.04±0.021
RelGeo(Diet)
0.252±0.189
0.278±0.211
0.462±0.148
0.433±0.212
0.306±0.188
Appendix
Table 7: Aggregated results of MRR CDist Sym.
Method
CIFAR-10
CIFAR-100
ImageNet-1k
CUB
SVHN
Rel(Cosine) [ Moschella et al., 2023 ]
0.08±0.077
0.122±0.109
0.21±0.149
0.089±0.094
0.035±0.034
RelGeo(L2)
0.019±0.005
0.046±0.016
0.236±0.08
0.156±0.089
0.013±0.005
RelGeo(Diet)
0.189±0.108
0.241±0.117
0.358±0.126
0.327±0.184
0.131±0.107
Appendix
Table 8: Aggregated results of MRR Cosine.
Method
CIFAR-10
CIFAR-100
ImageNet-1k
CUB
SVHN
Rel(Cosine) [ Moschella et al., 2023 ]
0.051±0.072
0.071±0.107
0.078±0.105
0.023±0.02
0.02±0.032
RelGeo(L2)
0.019±0.005
0.04±0.015
0.106±0.11
0.108±0.092
0.012±0.005
RelGeo(Diet)
0.127±0.118
0.151±0.138
0.298±0.141
0.269±0.195
0.123±0.103
Appendix
Table 9: Aggregated results of MRR CDist.
Method
ResNet-50
ViT-16
ViT-32
DINOv2
Rel(Cosine) [ Moschella et al., 2023 ]
0.507±0.2
0.669±0.229
0.664±0.218
0.678±0.24
RelGeo(L2)
0.646±0.209
0.709±0.208
0.72±0.194
0.737±0.209
RelGeo(Diet)
0.529±0.194
0.658±0.229
0.661±0.219
0.668±0.237
Appendix
Table 10: Alternatively aggregated results of Accuracy.
Method
ResNet-50
ViT-16
ViT-32
DINOv2
Rel(Cosine) [ Moschella et al., 2023 ]
0.032±0.023
0.212±0.173
0.208±0.175
0.124±0.104
RelGeo(L2)
0.143±0.132
0.197±0.186
0.205±0.189
0.154±0.137
RelGeo(Diet)
0.336±0.143
0.506±0.2
0.526±0.187
0.42±0.106
Appendix
Table 11: Alternatively aggregated results of MRR Cosine Sym.
Method
ResNet-50
ViT-16
ViT-32
DINOv2
Rel(Cosine) [ Moschella et al., 2023 ]
0.009±0.005
0.141±0.156
0.134±0.158
0.049±0.047
RelGeo(L2)
0.052±0.033
0.144±0.146
0.147±0.146
0.103±0.085
RelGeo(Diet)
0.204±0.13
0.432±0.235
0.437±0.232
0.313±0.108
Appendix
Table 12: Alternatively aggregated results of MRR CDist Sym.
Method
ResNet-50
ViT-16
ViT-32
DINOv2
Rel(Cosine) [ Moschella et al., 2023 ]
0.011±0.005
0.138±0.11
0.133±0.112
0.147±0.128
RelGeo(L2)
0.074±0.077
0.107±0.118
0.116±0.126
0.079±0.074
RelGeo(Diet)
0.182±0.107
0.299±0.184
0.316±0.182
0.201±0.076
Appendix
Table 13: Alternatively aggregated results of MRR Cosine.
Method
ResNet-50
ViT-16
ViT-32
DINOv2
Rel(Cosine) [ Moschella et al., 2023 ]
0.007±0.001
0.079±0.086
0.089±0.112
0.019±0.015
RelGeo(L2)
0.023±0.016
0.075±0.096
0.078±0.099
0.051±0.05
RelGeo(Diet)
0.121±0.094
0.253±0.193
0.258±0.194
0.143±0.065
Appendix
Table 14: Alternatively aggregated results of MRR CDist.
Figure 14: Accuracies on CUB with varying number of anchors. From top to bottom: 50, 100, 200, 500, 1000 anchors.
Figure 15: MRR Cosine Sym on CUB with varying number of anchors. From top to bottom: 50, 100, 200, 500, 1000 anchors.
Figure 16: Results of RelGeo(Diet) on CUB with varying number of diet points. Top: accuracies; bottom: MRR Cosine Sym.
Figure 17: Results of RelGeo(L2) on CUB with varying number of discretization steps. Top: accuracies; bottom: MRR Cosine Sym.
Figure 18: Results of RelGeo(Diet) on CUB with varying number of discretization steps. Top: accuracies; bottom: MRR Cosine Sym.
Figure 19: Results of RelGeo(Diet) on CUB with varying diet augmentation strengths. Results with strength 3 can be seen above. Top: accuracies; bottom: MRR Cosine Sym.
Figure 20: Results using the fps scheme to select the anchors. From top to bottom: accuracies, MRR Cosine Sym, MRR CDist Sym, MRR Cosine, MRR CDist.
Figure 21: Results using the kmeans scheme to select the anchors. From top to bottom: accuracies, MRR Cosine Sym, MRR CDist Sym, MRR Cosine, MRR CDist.
Figure 22: Stitching results for multimodal scenario. From top to bottom: MRR Cosine Sym, MRR CDist Sym, MRR Cosine, MRR CDist.
Method
MRR Cosine Sym
MRR CDist Sym
MRR Cosine
MRR CDist
Rel(Cosine) [ Moschella et al., 2023 ]
0.298±0.395
0.293±0.389
0.283±0.382
0.252±0.373
RelGeo(Diet)
0.413±0.353
0.384±0.359
0.317±0.372
0.302±0.378
Appendix
Table 15: Average MRR results for different methods across different datasets. Relative representations pulling back from diet decoder ( RelGeo(Diet) ) consistently provides better retrievals.
Decoder
CIFAR-10
CIFAR-100
ImageNet-1k
CUB
SVHN
Abs
10.467±0.765
10.71±0.655
8.804±0.581
1.593±0.615
15.57±0.843
Diet(0)
3.462±0.03
3.501±0.045
3.556±0.018
3.509±0.028
3.506±0.044
Diet(1)
718.818±216.179
730.446±226.91
1651.49±211.037
1937.656±192.894
705.929±202.844
Diet(2)
735.144±219.211
739.671±222.36
2034.677±276.309
2428.942±196.388
727.477±206.929
Diet(3)
771.299±213.022
767.453±222.62
2645.914±260.069
3201.588±242.339
754.965±202.021
Appendix
Table 16: Times in seconds for training the decoders.
Num Anchors
Time (s) ± Std
MRR
2
0.8480±0.0407
0.0168
3
0.8348±0.0367
0.0807
5
0.8377±0.0435
0.3503
8
0.9450±0.0285
0.7004
10
1.0969±0.0297
0.8384
15
1.2853±0.0264
0.9296
Appendix
Table 17: Running time / accuracy tradeoff of RelGeo(L2).
Num Anchors
Time (s)
Accuracy
200
0.088±0.14
0.425±0.189
500
0.175±0.053
0.531±0.188
1000
0.062±0.091
0.559±0.179
Appendix
Table 18: Running time / accuracy tradeoff of Rel(Cosine).
Num Anchors
Time (s)
Accuracy
200
8.004±3.304
0.5±0.184
500
21.297±8.774
0.595±0.163
1000
47.218±19.486
0.619±0.154
Appendix
Table 19: Running time / accuracy tradeoff of RelGeo(L2).
Num Anchors
Time (s)
Accuracy
200
7.274±3.28
0.459±0.177
500
19.427±8.771
0.559±0.171
1000
43.108±19.502
0.585±0.163
Appendix
Table 20: Running time / accuracy tradeoff of RelGeo(Diet).
Method
CIFAR-10
CIFAR-100
ImageNet-1k
CUB
SVHN
Rel(Cosine) [ Moschella et al., 2023 ]
0.071±0.113
0.184±0.065
0.085±0.124
0.05±0.071
RelGeo(L2)
85.414±40.61
86.079±40.652
258.788±70.064
139.998±66.509
RelGeo(Diet)
89.899±40.599
89.902±40.588
155.991±70.136
147.336±66.505
Appendix
Table 21: Times in seconds of Rel(Cosine) , RelGeo(L2) and RelGeo(Diet) for generating the representations.
Metric
CIFAR-10
CIFAR-100
ImageNet-1k
CUB
SVHN
Accuracy
0.959±0.026
0.894±0.043
0.623±0.103
0.729±0.133
0.625±0.033
MRR Cosine Sym
0.012±0.0
0.021±0.003
0.075±0.014
0.211±0.082
0.034±0.01
MRR CDist Sym
0.012±0.001
0.025±0.004
0.13±0.046
0.201±0.08
0.028±0.008
MRR Cosine
0.012±0.001
0.019±0.003
0.066±0.022
0.152±0.069
0.011±0.002
MRR CDist
0.012±0.001
0.023±0.005
0.111±0.052
0.144±0.073
0.011±0.003
Appendix
Table 22: Results of RelGeo(Fisher).
Figure 23: Results of RelGeo(Fisher) on CIFAR-10.
Figure 24: Results of RelGeo(Fisher) on CIFAR-100.
Figure 25: Results of RelGeo(Fisher) on ImageNet-1k.
King’s College London, London, United Kingdom · Queen Mary University of London, London, United Kingdom · Universitat Pompeu Fabra, Barcelona, Spain +5
Northeastern University, Boston, MA 02115. Work performed during a summer internship at Lawrence Livermore National Laboratory · Lawrence Livermore National Laboratory, Livermore, CA 94551-0808.