Insights on representational similarity in neural networks with canonical correlation

Ari S. Morcos, Maithra Raghu, Samy Bengio

TL;DR

This paper introduces Projection Weighted Canonical Correlation Analysis (PWCCA), a robust tool for measuring the similarity between neural network representations. By distinguishing between task-critical "signal" and stochastic "noise," the authors demonstrate that networks which generalize converge to more similar internal states than those that merely memorize, and that RNNs, like CNNs, learn in a distinct "bottom-up" fashion.

What Problem Does This Paper Address?

Deep neural networks are notoriously difficult to peer into. Even when two networks are trained on the exact same task, their internal weights and activations look completely different. This is due to several factors: neurons can be permuted without changing the output, and representations can undergo linear transformations (like scaling or rotation) that don't affect the network's expressive power but make direct comparison impossible.

Previous work introduced SVCCA to solve this by using Canonical Correlation Analysis (CCA), which is invariant to linear transforms. However, SVCCA treats all correlated directions as equally important. The authors of this paper argue that many of these directions are actually "noise"—parts of the representation that don't contribute to performance and never truly converge. The challenge is to find a similarity metric that focuses only on the "signal" that actually drives the network's computation.

Methods

The authors build upon CCA, a statistical technique that finds the best linear relationship between two sets of multidimensional variables (in this case, layers of neurons).

Their key innovation is Projection Weighting (PWCCA). Instead of taking a simple average of all correlation coefficients (as in SVCCA), they calculate a weighted mean. The weights ($\alpha_i$) are determined by how much of the original neuron activations are accounted for by each CCA vector.

PWCCA is more robust to noise than SVCCA or unweighted means as the signal-to-noise ratio decreases.

As shown in Figure 2, this weighting makes the metric significantly more robust. It effectively ignores "unstable" parts of the representation that fluctuate throughout training and focuses on the "stable" parts that correlate with the network's actual performance.

Datasets

The study evaluates these methods across different architectures and tasks:

  • CNNs: Trained on CIFAR-10 for image classification.
  • RNNs (LSTMs): Trained on Penn Treebank (PTB) and WikiText-2 for language modeling.
  • Synthetic Data: Used to validate the robustness of PWCCA against controlled levels of noise.

Key Insights and Ideas

  • Generalization vs. Memorization: One of the most striking findings is that networks that generalize (trained on true labels) converge to much more similar internal representations than networks that memorize (trained on random labels). Memorizing networks are as different from each other as they are from generalizing ones, suggesting they find highly idiosyncratic ways to store data.
  • The "Lottery Ticket" and Width: Wider networks converge to more similar solutions than narrow ones. This supports the idea that larger networks are more likely to contain similar "lucky" sub-networks that drive successful learning.
  • Learning Rate Clusters: Networks with the same architecture but different learning rates converge to distinct "clusters" of solutions. Even if they reach similar accuracy, their internal strategies are fundamentally different.
  • RNN Learning Dynamics: RNNs exhibit a "bottom-up" convergence pattern during training, where earlier layers stabilize their representations before later layers. This mirrors what has been observed in CNNs.

Key Results

  • Accuracy Prediction: The authors found a remarkably high correlation (-0.96) between the PWCCA distance of a network's representations and its final test accuracy (Figure 4b). This suggests that representational similarity to a known "good" model could potentially predict performance without a validation set.
  • Generalization Gap: In later layers of a CNN, generalizing networks are significantly more similar to each other than memorizing networks are to one another (Figure 3).
Generalizing networks become more similar in later layers, while memorizing networks remain diverse.
  • RNN Stability: While RNNs converge bottom-up over training time (Figure 6), their hidden states are highly variable across sequence timesteps. CCA reveals that these states are often not even linearly similar, suggesting the recurrent dynamics are deeply nonlinear.
RNNs show clear bottom-up convergence, with early layers stabilizing first.

Limitations and Future Work

While PWCCA is a powerful tool, it is technically a "pseudo-distance" because it is non-symmetric. Furthermore, because it relies on CCA, it only captures linear similarities. The authors note that in RNNs, hidden states across sequence steps often vary nonlinearly, which CCA struggles to account for.

Future work could explore using these similarity insights as a regularizer to improve training or investigating exactly what makes certain representational "directions" so special that they are preserved across different random initializations.

Summary updated

BibTeX
@inproceedings{morcos2018insights,
  author = {Ari S. Morcos and Maithra Raghu and Samy Bengio},
  title = {{Insights on representational similarity in neural networks with canonical correlation}},
  booktitle = {Advances in Neural Information Processing Systems},
  year = {2018},
  url = {https://openreview.net/forum?id=rk-GBP-_WB},
}
Figure