NeurIPS 2026Coming to NeurIPS?Explore papers, orals & directions

Harmony in Diversity: Merging Neural Networks with Canonical Correlation Analysis

Stefan Horoi, Albert Manuel Orozco Camacho, Eugene Belilovsky, Guy Wolf

Introduction

Ensembling multiple neural networks is a standard strategy for improving model performance and robustness. However, the associated computational and storage costs at inference time often make ensembling impractical for resource-constrained environments. Model fusion offers a compelling alternative by merging the parameters of multiple models into a single set of weights.

A primary challenge in model fusion is "permutation invariance": different networks can learn identical functions while representing features in different orders or across different neuron combinations. Traditional methods attempt to find a one-to-one permutation to align models, but this approach is often too restrictive. The authors of this paper propose CCA Merge, which moves beyond rigid permutations to more flexible linear transformations.

The CCA Merge Method

CCA Merge leverages Canonical Correlation Analysis (CCA) to align internal representations. Unlike permutation-based methods that rely on discrete reorderings, CCA Merge utilizes linear transformations to find a common representation space where features are maximally correlated.

Conceptual framework of CCA Merge: Aligning disparate model representation spaces into a common CCA space.

The process involves four key steps:

  1. Activation Collection: Passing a small calibration dataset through the models to collect internal activations.
  2. Common Space Identification: Using CCA to find projection matrices ($P^A$ and $P^B$) that map features into a common space.
  3. Alignment: Deriving a transformation matrix $T$ that rotates and scales the weight space of one model to match another.
  4. Merging: Averaging the aligned weights and biases to produce the final merged model.

Key Insights: The Distributed Feature Hypothesis

A core motivation for CCA Merge is the "Distributed Feature" hypothesis, which suggests that features in deep networks are often represented by linear combinations of multiple neurons rather than single units. Permutation-based methods fail to capture these many-to-many relationships because they force a 1-to-1 match.

Distribution of correlation values across layers, supporting the hypothesis that features are distributed across multiple neurons.

Empirical analysis of correlation values shows that while some features correlate strongly, many others exhibit moderate correlations across a wider set of neurons. CCA Merge's ability to handle these distributed representations allows it to maintain stability even when merging many models, avoiding the "mismatch explosion" that plagues permutation-based techniques.

Experimental Results

The researchers evaluated CCA Merge across several benchmarks, including CIFAR-10 (VGG11), CIFAR-100 (ResNet20), and ImageNet (ResNet18). Key findings include:

  • Superior Accuracy: On CIFAR-10, CCA Merge achieved ~82-84% accuracy, while the best permutation-based methods struggled around 55%.
  • Multi-Model Scaling: When merging five models, CCA Merge maintained an accuracy of ~80%, whereas competing methods saw performance plummet to below 20%.
  • Data Diversity: In scenarios where models were trained on different data distributions (Dirichlet splits), CCA Merge was often the only method to outperform the average of the individual base models.

Limitations and Future Work

While powerful, CCA Merge requires a small amount of calibration data to compute activations, which may be a hurdle in privacy-sensitive settings. Additionally, computing CCA for every layer adds some overhead compared to simple permutations. Future work may explore applying this method to Transformer architectures or cross-task merging scenarios.

Summary updated

BibTeX
@inproceedings{horoi2024harmony,
  author = {Stefan Horoi and Albert Manuel Orozco Camacho and Eugene Belilovsky and Guy Wolf},
  title = {{Harmony in Diversity: Merging Neural Networks with Canonical Correlation Analysis}},
  booktitle = {International Conference on Machine Learning},
  year = {2024},
  url = {https://openreview.net/forum?id=hLuNVjRnY3},
}
Figure