AI Wiki中文/EN

Representation collapse

表示坍塌

Use spectra, rank and an exact training recurrence to distinguish lost dimensions from low loss.

On this pageIntuitionMathematics & methodImplementationLimitationsExercisesResearch connections

Start with the problem

A representation can look busy and still carry only one degree of variation. Imagine a spreadsheet with columns t, 2t and −t: every column changes, but knowing the first determines the other two. Checking only each column’s variance would miss the lost dimensions.

Complete collapse maps all observed examples to one vector. Dimensional collapse restricts them to a smaller subspace, even when individual examples remain distinguishable. Jing and colleagues document dimensional collapse in contrastive learning as well as mechanisms in particular linear-model analyses. Their results should not be expanded into a claim that every contrastive objective inevitably collapses. Understanding Dimensional Collapse in Contrastive Self-supervised Learning — arXiv v2

This chapter uses covariance spectra to distinguish constant, redundant and strongly anisotropic features. A separate alignment-only training loop shows how a decreasing loss can reward the disappearance of information.

Definitions and derivation

Center an N-by-d feature table Z and compute its sample covariance. Its eigenvalues measure variance along mutually orthogonal directions:

Zc=Z−1Zˉ,C=Zc⊤ZcN−1,C=Udiag⁡(λ1,…,λd)U⊤,λj≥0.Z_c=Z-\mathbf1\bar Z,\qquad C=\frac{Z_c^\top Z_c}{N-1},\qquad C=U\operatorname{diag}(\lambda_1,\ldots,\lambda_d)U^\top,\quad \lambda_j\ge0.

For nonzero total variance, define the participation ratio. It lies between one and the number of positive eigenvalues, reaching that number when those eigenvalues are equal. We assign zero to the constant case as an explicit convention:

rpart=(∑jλj)2∑jλj2,rpart=0 if C=0,rank⁡(C)≤min⁡(d,N−1).r_{\rm part}=\frac{(\sum_j\lambda_j)^2}{\sum_j\lambda_j^2},\qquad r_{\rm part}=0\ \text{if }C=0,\qquad \operatorname{rank}(C)\le\min(d,N-1).

The bound follows from Cauchy–Schwarz on the nonzero eigenvalues. Unlike rank, this ratio detects concentration of variance before an eigenvalue reaches zero. It is invariant to a common nonzero scaling and an orthogonal coordinate change, but not to arbitrary per-coordinate rescaling. It is not a semantic quality score.

Now use the same linear encoder W for views X and Y, and minimize only their squared discrepancy. With D=X−YD=X-Y, the exact update is:

L(W)=12N∥DW∥F2,∇WL=1ND⊤DW,Wt+1=(I−ηD⊤D/N)Wt.L(W)=\frac1{2N}\|DW\|_F^2,\qquad \nabla_W L=\frac1N D^\top DW,\qquad W_{t+1}=\left(I-\eta D^\top D/N\right)W_t.

If D⊤DD^\top D is positive definite and the step size contracts every eigenmode, W tends to zero. If D has a null space, directions in that null space can survive. This proof is for our alignment-only quadratic, not a proof about InfoNCE or an entire nonlinear training pipeline. VICReg adds separate variance and covariance pressures precisely because alignment alone leaves this problem. VICReg: Variance-Invariance-Covariance Regularization for Self-Supervised Learning — arXiv v3

Covariance eigenvalue shares from the four constructed tables; r is the participation ratio. Constant features have zero total variance, so no normalized shares are plotted. A normalized spectrum hides the overall scale; read total variance separately.
Covariance eigenvalue shares from the four constructed tables; r is the participation ratio. Constant features have zero total variance, so no normalized shares are plotted. A normalized spectrum hides the overall scale; read total variance separately.

Run the calculation

Run with CPython 3.12.4 and NumPy 1.26.4. Eight sign patterns produce three equally varying directions. The one-factor table has three positive coordinate variances but participation ratio one. Scaling the full table by (1, 10⁻⁴, 10⁻⁸) retains numerical rank three while reducing participation to about 1.00000002. In the training loop, 1,000 steps of size 0.1 reduce loss from 0.725 to about 6.32e−10 and total feature variance to 1.60e−8. Finite outputs are tiny, not mathematically identical to zero.

import numpy as np


def diagnostics(features):
    z=np.asarray(features,dtype=float)
    if z.ndim!=2 or len(z)<2 or not np.isfinite(z).all():raise ValueError('Use a finite matrix with at least two examples.')
    centered=z-z.mean(axis=0);cov=centered.T@centered/(len(z)-1);values=np.maximum(np.linalg.eigvalsh(cov),0)[::-1];total=values.sum();participation=0. if total==0 else float(total**2/(values@values))
    return {'variances':np.diag(cov),'eigenvalues':values,'participation':participation,'numerical_rank':int(np.linalg.matrix_rank(centered))}


def views():
    signs=np.array([[(-1.)**((i>>j)&1) for j in range(3)] for i in range(8)]);return signs,signs+signs@np.diag([.3,.6,1.])


def objective(w):
    a,b=views();difference=(a-b)@w;return .5*np.sum(difference**2)/len(a),(a-b).T@difference/len(a)


def train(steps=1000):
    w=np.eye(3);start=objective(w)[0]
    for _ in range(steps):w-=.1*objective(w)[1]
    return w,start,objective(w)[0]


if __name__=='__main__':
    a,b=views();cases={'full':a,'constant':np.ones_like(a),'one-factor':a[:,0,None]*np.array([1.,2.,-1.]),'anisotropic':a*np.array([1.,1e-4,1e-8])}
    for name,z in cases.items():
        d=diagnostics(z);print(name,'variances',d['variances'].tolist(),'participation',round(d['participation'],9),'centered numerical rank',d['numerical_rank'])
    w,start,end=train();print('alignment-only loss',start,end,'encoder diagonal',np.diag(w).tolist(),'final feature variance sum',float(diagnostics(a@w)['variances'].sum()))
full variances [1.1428571428571428, 1.1428571428571428, 1.1428571428571428] participation 3.0 centered numerical rank 3
constant variances [0.0, 0.0, 0.0] participation 0.0 centered numerical rank 0
one-factor variances [1.1428571428571428, 4.571428571428571, 1.1428571428571428] participation 1.0 centered numerical rank 1
anisotropic variances [1.1428571428571428, 1.1428571428571429e-08, 1.1428571428571432e-16] participation 1.00000002 centered numerical rank 3
alignment-only loss 0.7250000000000001 6.31715429153884e-10 encoder diagonal [0.00011848257529216725, 1.1940813157722135e-16, 1.206570002987732e-39] final feature variance sum 1.6043566454701807e-08

When the method fails

Rank depends on tolerance in floating-point computation. The program reports rank of the centered features, not rank of the squared-condition-number covariance matrix; the two can produce different numerical judgments near machine precision. Inspect singular values and the scale of the input before labeling a small eigenvalue “zero.” In the long recurrence, roundoff mixes extremely small modes: absolute error is meaningful where a relative comparison to a value around 10⁻⁴⁶ is not.

A low-dimensional representation is not automatically bad. If a task needs one latent factor, suppressing unrelated factors may help. Conversely, isotropic noise can achieve participation ratio near d while predicting nothing useful. Check downstream tasks, held-out examples and augmentation assumptions alongside spectra.

Batch covariance cannot reveal more than N−1 centered directions. Comparing a 64-example batch against a 1,024-example batch without accounting for this bound can create a false story about model quality. Record encoder versus projector output, batch size, centering convention and tolerance; a projector can have a different spectrum from the backbone. Understanding Dimensional Collapse in Contrastive Self-supervised Learning — arXiv v2

Exercises with answers

  1. What are the rank and participation ratio of columns t, 2t and −t for nonconstant t?

Answer 1: Both are one, even though all three coordinate variances are positive.

  1. Can centering ten examples yield covariance rank twenty?

Answer 2: No. Centering limits the rank to at most nine.

  1. Does participation ratio change if all features are multiplied by seven?

Answer 3: No. Eigenvalues scale by 49, which cancels from the ratio.

  1. When can a nonzero encoder survive the alignment-only loss?

Answer 4: When its columns lie in the null space of X−Y, or when optimization has not converged. Positive-definite discrepancy covariance removes the former option.

Sources and next steps

Read the dimensional-collapse paper’s model assumptions before transferring its dynamical conclusions to another loss. Compare VICReg for explicit variance/covariance constraints and linear probes for a complementary task-based test. A useful report plots both total variance and the normalized spectrum: normalizing alone hides an encoder whose entire output is vanishing. Understanding Dimensional Collapse in Contrastive Self-supervised Learning — arXiv v2; VICReg: Variance-Invariance-Covariance Regularization for Self-Supervised Learning — arXiv v3

Make a prediction, then check

All three feature coordinates have positive variance. What follows?

Choose one answer

Learning objectives

  • Distinguish coordinate variance, rank, spectrum concentration and total scale.
  • Prove collapse of a specified alignment-only quadratic.

Prerequisites & connections

Explore related knowledge →

References

  1. Understanding Dimensional Collapse in Contrastive Self-supervised Learning — arXiv v2
    Li Jing; Pascal Vincent; Yann LeCun; Yuandong Tian · 2022
  2. VICReg: Variance-Invariance-Covariance Regularization for Self-Supervised Learning — arXiv v3
    Adrien Bardes; Jean Ponce; Yann LeCun · 2022

Version1 · Editorial status: Recorded technical checks completed

View technical check record (AI)

Codex · 2026-09-07 · Codex single-AI-author technical check: primary-source scope, explicit assumptions, original calculations, independent mathematical references and bilingual tests; not independent human or second-agent review.

  • Single-AI-author technical check: bounded primary-source reading, explicit assumptions, original calculations, executable examples and corresponding bilingual equations, code and exercises. Not independent human or second-agent review.
  • Four CPython 3.12.4 checks per chapter: spectra and exact recurrence with scale-aware tolerances, frozen ridge probes, literal graded retrieval metrics, whitening/SVD constraints, finite balancing marginals and stopped targets, pseudo-label denominator, exact noise expectation and temperature-weighted distillation as applicable, plus bilingual structure. All eight programs use NumPy 1.26.4; no real image/text benchmark reproduction claimed.
  • Promoted the full prose, equations, code and exercises. Tests read formal MDX only; removed temporary fallbacks/draft skips and updated review assertion to checked. Algorithm and independent references are unchanged; final record binds both locale hashes.
  • Publication navigation points published topics to complete articles and removes corresponding pending wording, retaining directory entries for unwritten targets. Principles, equations, programs and exercises are unchanged; final article SHA values rebound.
  • Compact bilingual Matplotlib 3.9.1 charts use executed functions for eigenvalue shares, accepted-label coverage/precision and shifted-test error. Numerical samples and both SVGs are hash-bound. Zero-variance and undefined-precision cases are not plotted as invented measurements.

Source locations checked:

Related topics

No matches. Try a synonym or acronym.

0 results shown

Wrap the whole query in double quotes for a phrase match.