Simple Algorithm
Deep Learning · Emergence · 28 min

Neural Collapse

The symmetric geometry that last-layer features converge to at the end of training.

Keep training a classifier after it gets every training example right, and its last layer becomes strangely tidy. Each example's features shrink onto its class mean, the class means spread into the most symmetric arrangement possible, and the classifier's weights line up with them. This is neural collapse: a geometry that recurs across datasets and architectures, and that a simple model of the last layer explains exactly.

What you’ll learn

  • State the four neural-collapse properties NC1–NC4 precisely, with the statistics used to measure them.
  • Derive the geometry of a simplex equiangular tight frame, including the cosine −1/(K−1)-1/(K-1), and show that it is the most separated arrangement of KK equal-norm vectors.
  • Prove that in the norm-constrained unconstrained-features model with balanced classes, cross-entropy is minimized exactly by collapsed configurations, and state the landscape result under weight decay.
  • Describe collapse under squared error, class imbalance, intermediate layers and language models, and weigh the evidence on what it implies for generalization and transfer.

The terminal phase of training

Papyan, Han and Donoho (2020) followed classifiers into the terminal phase of training: the epochs after the training error first reaches zero, while the cross-entropy keeps falling toward zero. Across seven standard image datasets and three standard architectures they measured the same four phenomena in the last layer. Write hk,i\mathbf h_{k,i} for the last-layer features of example ii of class kk (nn per class, KK classes), μk\boldsymbol\mu_k for the class means, μG\boldsymbol\mu_G for the global mean, and wk\mathbf w_k for the classifier's row for class kk.

ΣW=1Kn∑k,i(hk,i−μk)(hk,i−μk)⊤,ΣB=1K∑k(μk−μG)(μk−μG)⊤\Sigma_W=\frac1{Kn}\sum_{k,i}(\mathbf h_{k,i}-\boldsymbol\mu_k)(\mathbf h_{k,i}-\boldsymbol\mu_k)^\top,\qquad \Sigma_B=\frac1K\sum_k(\boldsymbol\mu_k-\boldsymbol\mu_G)(\boldsymbol\mu_k-\boldsymbol\mu_G)^\top
Within-class and between-class covariances of the last-layer features.

In words: the last layer turns into a perfect, maximally symmetric code. Every class is a single point, the points are as far apart as KK points of equal norm can be, and the linear classifier is just a template-matching rule against those points. Papyan et al. argued that this simple geometry benefits generalization, robustness and interpretability; how far that is true is the subject of the last step.

The simplex equiangular tight frame

DerivationWhy the cosine is −1/(K−1)
  1. 0=∥∑kvk∥2=∑k∥vk∥2+∑j≠k⟨vj,vk⟩=K+K(K−1) c⟹c=−1K−10=\Big\lVert\sum_k\mathbf v_k\Big\rVert^2=\sum_k\norm{\mathbf v_k}^2+\sum_{j\ne k}\langle\mathbf v_j,\mathbf v_k\rangle=K+K(K-1)\,c\quad\Longrightarrow\quad c=-\frac1{K-1}

    Take KK unit vectors v1,…,vK\mathbf v_1,\dots,\mathbf v_K with a common pairwise inner product cc. Centering means they sum to zero, so

  2. 1K(K−1)∑j≠k⟨vj,vk⟩ ≥ −1K−1⟹max⁡j≠k⟨vj,vk⟩≥−1K−1\frac{1}{K(K-1)}\sum_{j\ne k}\langle\mathbf v_j,\mathbf v_k\rangle\ \ge\ -\frac1{K-1}\quad\Longrightarrow\quad\max_{j\ne k}\langle\mathbf v_j,\mathbf v_k\rangle\ge-\frac1{K-1}

    The same identity shows this is the most separated arrangement possible. For any unit vectors, ∥∑kvk∥2≥0\norm{\sum_k\mathbf v_k}^2\ge0 forces the average pairwise cosine to be at least −1/(K−1)-1/(K-1), so the most similar pair always has cosine ≥−1/(K−1)\ge-1/(K-1). The simplex equiangular tight frame (simplex ETF) attains this with equality for every pair at once.

  3. M⊤M=KK−1(IK−1K11⊤):diagonal 1,off-diagonal −1K−1M^\top M=\frac{K}{K-1}\Big(I_K-\frac1K\mathbf 1\mathbf 1^\top\Big):\qquad \text{diagonal }1,\quad\text{off-diagonal }-\frac1{K-1}

    In matrix form, with any U∈Rd×KU\in\R^{d\times K} having orthonormal columns, M=KK−1 U(IK−1K11⊤)M=\sqrt{\tfrac{K}{K-1}}\,U\big(I_K-\tfrac1K\mathbf 1\mathbf 1^\top\big) has exactly this Gram matrix. Its columns span a (K−1)(K-1)-dimensional subspace, so the frame needs d≥K−1d\ge K-1, and MM⊤MM^\top is a multiple of the projection onto that subspace: the frame is tight.

For K=2K=2 the means are opposite (180°180°); for K=3K=3 they sit at the corners of an equilateral triangle (120°120°); for K=4K=4, a regular tetrahedron (109.5°109.5°). As KK grows the angle approaches 90°90°: many classes can be nearly orthogonal, but never more than slightly obtuse.

Predict before you look

A network trained to collapse on CIFAR-10 (K=10K=10 classes). What cosine similarity do any two centered class means approach?

Show the answer

-0.11

−1/(K−1)=−1/9≈−0.111-1/(K-1)=-1/9\approx-0.111, an angle of about 96.4°96.4°. Each class mean is slightly further than orthogonal from every other, the best that ten equal-norm, zero-sum vectors can do.

Why: the unconstrained features model

A deep network is so flexible that its last-layer features can be placed almost anywhere. The unconstrained features model (Mixon, Parshall & Pi, 2020) takes this literally: treat the features hi\mathbf h_i as free variables, optimized together with the classifier. Fang, He, Long and Su (2021) called the version with norm constraints the layer-peeled model, since it peels the top layer away from the rest of the network. With N=KnN=Kn examples:

min⁡W, H 1N∑i=1NℓCE(Whi, yi)s.t.1K∑k=1K∥wk∥2≤EW,1N∑i=1N∥hi∥2≤EH\min_{W,\,H}\ \frac1N\sum_{i=1}^N\ell_{\text{CE}}\big(W\mathbf h_i,\,y_i\big)\quad\text{s.t.}\quad \frac1K\sum_{k=1}^K\norm{\mathbf w_k}^2\le E_W,\qquad \frac1N\sum_{i=1}^N\norm{\mathbf h_i}^2\le E_H
Without the constraints the loss could be pushed to zero by scaling alone; with them, the question becomes which geometry is best.
DerivationProof that collapse is optimal (balanced classes, d ≥ K − 1)
  1. ℓi=log⁡(1+∑j≠kezij−zik) ≥ g(1K−1∑j≠k(zij−zik)),g(t)=log⁡(1+(K−1)et)\ell_i=\log\Big(1+\sum_{j\ne k}e^{z_{ij}-z_{ik}}\Big)\ \ge\ g\Big(\frac1{K-1}\sum_{j\ne k}(z_{ij}-z_{ik})\Big),\qquad g(t)=\log\big(1+(K-1)e^t\big)

    For example ii of class kk with logits zij=⟨wj,hi⟩z_{ij}=\langle\mathbf w_j,\mathbf h_i\rangle, apply Jensen's inequality to the average of the K−1K-1 exponentials (exp⁡\exp is convex):

  2. L ≥ g(−KK−1⋅1N∑i⟨wyi−wˉ,hi⟩),1N∑i⟨wyi−wˉ,hi⟩≤1N∑i∥wyi−wˉ∥2 1N∑i∥hi∥2\loss\ \ge\ g\Big(-\frac{K}{K-1}\cdot\frac1N\sum_i\langle\mathbf w_{y_i}-\bar{\mathbf w},\mathbf h_i\rangle\Big),\qquad \frac1N\sum_i\langle\mathbf w_{y_i}-\bar{\mathbf w},\mathbf h_i\rangle\le\sqrt{\frac1N\sum_i\norm{\mathbf w_{y_i}-\bar{\mathbf w}}^2}\ \sqrt{\frac1N\sum_i\norm{\mathbf h_i}^2}

    With wˉ=1K∑jwj\bar{\mathbf w}=\tfrac1K\sum_j\mathbf w_j, the argument equals −KK−1⟨wk−wˉ,hi⟩-\tfrac{K}{K-1}\langle\mathbf w_k-\bar{\mathbf w},\mathbf h_i\rangle. Since gg is convex and increasing, Jensen again over all NN examples, then Cauchy–Schwarz, give

  3. L ≥ log⁡(1+(K−1) exp⁡(−KK−1EWEH))\loss\ \ge\ \log\Big(1+(K-1)\,\exp\Big(-\frac{K}{K-1}\sqrt{E_WE_H}\Big)\Big)

    Balance gives 1N∑i∥wyi−wˉ∥2=1K∑k∥wk∥2−∥wˉ∥2≤EW\tfrac1N\sum_i\norm{\mathbf w_{y_i}-\bar{\mathbf w}}^2=\tfrac1K\sum_k\norm{\mathbf w_k}^2-\norm{\bar{\mathbf w}}^2\le E_W, so a bound that no configuration can beat:

  4. Equality forces collapse. Cauchy–Schwarz is tight only if hi=c (wyi−wˉ)\mathbf h_i=c\,(\mathbf w_{y_i}-\bar{\mathbf w}) with one constant cc, and the norm bound only if wˉ=0\bar{\mathbf w}=0: features equal their class's classifier row (NC1, NC3). The first Jensen step is tight only if each example's wrong-class logits c⟨wj,wk⟩c\langle\mathbf w_j,\mathbf w_k\rangle are all equal, and the second only if all margins c∥wk∥2c\norm{\mathbf w_k}^2 are equal. Equal norms, equal pairwise inner products and zero sum: the rows of WW form a simplex ETF (NC2), and NC4 follows. Conversely the ETF configuration attains the bound, which is why d≥K−1d\ge K-1 is needed.

The landscape result matters: gradient descent with small random perturbations escapes strict saddles, so in this model training finds collapse from almost any start. The model's weakness is its premise. Real features are computed by a network from the inputs and cannot be placed freely, and the model says nothing about test data, on which the network never trained.

Beyond the balanced, cross-entropy case

  • Squared error. Collapse is not special to cross-entropy. Han, Papyan and Donoho (2022) observed it with the mean squared error loss across three architectures and five datasets. They split the loss into a part that assumes the classifier is the least-squares optimum for the current features and a part measuring its deviation; the second part stays negligible in training, which motivates the "central path", along which they derived exact dynamics that predict collapse.
  • Imbalanced classes. In the layer-peeled model with many examples per majority class and few per minority class, Fang et al. (2021) found minority collapse: as the imbalance ratio grows, the minority classes' classifier vectors converge to one another, so the model can no longer tell those classes apart, however long it trains. They confirmed the effect in real networks, and it is one more reason for the rebalancing methods of Reshaping Cross-Entropy.
  • Intermediate layers. Separation by class does not appear only at the end. He and Su (2023) found that, across architectures and datasets, each layer improves a measure of class separation by a roughly constant factor, so separation improves geometrically with depth, and Hui, Belkin and Nakkiran (2022) report a partial "cascading" collapse in earlier layers.
  • Language models. Next-token prediction breaks every textbook condition for collapse: the vocabulary is imbalanced and much larger than the embedding width, so no simplex ETF can even exist (K−1>dK-1>d); the same context can be followed by different tokens; and models see their data for only a few epochs. Wu and Papyan (2024) nevertheless found collapse-like properties emerging with scale and regularization in causal language models, tracking better generalization.
Check your understanding

A language model has a vocabulary of 50,000 tokens and a final hidden width of 4,096. Why can its output embeddings not form a simplex ETF?

  1. Its loss is not cross-entropy
  2. A simplex ETF of KK vectors spans K−1K-1 dimensions, and 49,99949{,}999 is far more than 4,0964{,}096
  3. Simplex ETFs exist only for even KK
  4. Its classes are balanced
Show the answer

B. A simplex ETF of KK vectors spans K−1K-1 dimensions, and 49,99949{,}999 is far more than 4,0964{,}096

The ETF's Gram matrix has rank K−1K-1, so it needs d≥K−1d\ge K-1. With K≫dK\gg d the vectors can at best be spread "as evenly as possible" in dd dimensions, and how close trained models come is an empirical question.

What collapse does and does not explain

The geometry is robustly reproduced on training data; its meaning is debated.

  • An optimization phenomenon? Hui, Belkin and Nakkiran (2022) separated collapse of the training features from collapse on the test distribution. They found the first common and the second absent, and concluded that neural collapse is primarily an optimization phenomenon with unclear connections to generalization. They also found that training longer can make the last-layer features transfer worse to downstream tasks: collapse is not always desirable for representation learning.
  • A route to transfer? Galanti, György and Hutter (2022) argued, theoretically and empirically, that collapse carries over to new samples of the training classes and to new classes, which would explain why features of large classifiers work so well for few-shot transfer.
  • A design prior. If the classifier converges to a simplex ETF anyway, it can be fixed at one from the start. Zhu et al. (2021) report that a fixed ETF classifier with feature dimension equal to the number of classes cut memory use for a ResNet-18 by more than 20% without hurting generalization.

Key takeaways

  • In the terminal phase of training, last-layer features collapse onto their class means (NC1), the centered means form a simplex ETF (NC2), the classifier rows align with them (NC3), and classification reduces to the nearest class mean (NC4).
  • A simplex ETF of KK equal-norm, zero-sum vectors has pairwise cosine −1/(K−1)-1/(K-1), the most separated arrangement possible, and needs d≥K−1d\ge K-1 dimensions.
  • In the unconstrained-features model with balanced classes, cross-entropy is minimized exactly by collapsed configurations (under norm constraints or weight decay with d≥Kd\ge K), and for d>Kd>K the landscape has no spurious local minima.
  • Collapse also appears with squared error and partly in intermediate layers and language models; imbalance causes minority collapse.
  • Collapse on training data is robust, but its links to generalization and transfer are contested: test features often do not collapse, and over-collapsed features can transfer worse.

Check yourself

In the interactive lesson these are scored with your confidence, and what you miss comes back for review.

Question 1

What does NC1, variability collapse, state?

  1. The class means converge to the origin
  2. The within-class covariance of the last-layer features vanishes relative to the between-class covariance
  3. The classifier weights converge to zero
  4. The training loss reaches exactly zero
Show the answer

B. The within-class covariance of the last-layer features vanishes relative to the between-class covariance

NC1 says each example's features converge to its class mean, measured by 1KTr⁡(ΣWΣB+)→0\tfrac1K\Tr(\Sigma_W\Sigma_B^{+})\to0. The means themselves spread out into a simplex ETF (NC2).

Question 2

With K=5K=5 classes, what pairwise cosine do the centered class means of a collapsed network approach?

  1. 00
  2. −15-\tfrac15
  3. −14-\tfrac14
  4. −1-1
Show the answer

C. −14-\tfrac14

Equal norms and a zero sum force 5+5⋅4 c=05+5\cdot4\,c=0, so c=−14c=-\tfrac14, an angle of about 104.5°104.5°.

Question 3

In the layer-peeled (unconstrained features) model with balanced classes and norm constraints, which statement is proved?

  1. Every minimizer of the cross-entropy has collapsed features, with classifier rows forming a simplex ETF
  2. Collapse occurs on the test set as well as the training set
  3. Collapse requires the squared-error loss
  4. The minimizers depend on the training inputs
Show the answer

A. Every minimizer of the cross-entropy has collapsed features, with classifier rows forming a simplex ETF

Two applications of Jensen's inequality and one of Cauchy–Schwarz give a lower bound on the loss that is attained exactly, and only, by collapsed simplex-ETF configurations.

Question 4

What is "minority collapse" (Fang et al., 2021)?

  1. Minority-class features collapse to their class means faster than majority features
  2. The network stops predicting the majority classes
  3. As the imbalance grows, the classifier vectors of the minority classes converge to one another, so those classes become indistinguishable
  4. The training loss on minority classes reaches zero first
Show the answer

C. As the imbalance grows, the classifier vectors of the minority classes converge to one another, so those classes become indistinguishable

In the layer-peeled model with imbalanced classes, the minority classes' classifier rows move together as the imbalance ratio grows, so the model loses the ability to separate them, however long it trains.

Further reading

  • V. Papyan, X. Y. Han & D. L. Donoho, "Prevalence of neural collapse during the terminal phase of deep learning training," PNAS 117 (2020).
  • D. G. Mixon, H. Parshall & J. Pi, "Neural collapse with unconstrained features," arXiv:2011.11619 (2020).
  • C. Fang, H. He, Q. Long & W. J. Su, "Exploring deep neural networks via layer-peeled model: Minority collapse in imbalanced training," PNAS 118 (2021).
  • Z. Zhu, T. Ding, J. Zhou, X. Li, C. You, J. Sulam & Q. Qu, "A geometric analysis of neural collapse with unconstrained features," NeurIPS (2021).
  • X. Y. Han, V. Papyan & D. L. Donoho, "Neural collapse under MSE loss: Proximity to and dynamics on the central path," ICLR (2022).
  • L. Hui, M. Belkin & P. Nakkiran, "Limitations of neural collapse for understanding generalization in deep learning," arXiv:2202.08384 (2022).