NMF, ICA & Sparse Coding
Parts-based, independent and sparse representations.
PCA finds directions of greatest variance, but its components mix positive and negative parts and need not mean anything. Three other factorizations demand more structure: nonnegative factors that add up parts, statistically independent sources that can be unmixed, and sparse codes over a learned dictionary. Each buys interpretability at a price in identifiability or computation, and this lesson makes both prices precise.
What you’ll learn
- Formulate NMF, derive the Lee–Seung multiplicative updates as rescaled gradient steps, and prove with an auxiliary function that they never increase the objective.
- Show that nonnegative rank can exceed rank, explain why exact NMF is NP-hard yet polynomial for fixed rank, and describe the separability condition that makes it tractable.
- State the ICA model, prove that Gaussian sources cannot be unmixed, state Comon's identifiability theorem, and derive the FastICA fixed-point update.
- Formulate sparse coding and dictionary learning, explain why the atoms must be norm-constrained, and connect them to the lasso, to ICA and to receptive fields in the visual cortex.
NMF: parts by addition
Nonnegative matrix factorization approximates a nonnegative data matrix , whose columns might be images or documents, by with and . Each data column is then , a sum of basis columns with nonnegative weights. Nothing can be subtracted, so the basis columns tend to act as parts that add up. Paatero & Tapper (1994) introduced the idea as "positive matrix factorization" for environmental data, and Lee & Seung (1999) showed it learns localized parts of faces and semantic features of text, where PCA learns holistic "eigenfaces" that cancel one another.
Two losses are common: the squared Frobenius error , and the generalized Kullback–Leibler divergence , which is the negative log-likelihood of a Poisson model for counts, up to terms that do not depend on and .
With , the gradient with respect to is a difference of two nonnegative matrices:
Take a gradient step with a separate step size for each entry, . The subtraction cancels, and the step becomes a multiplication (Lee & Seung, 2000):
The same argument for gives its update. Nonnegative factors stay nonnegative automatically, with no projection and no step size to tune.
The update for acts column by column, so take one column with data column and . Call an auxiliary function if for all and . Minimizing cannot increase :
Take with the diagonal matrix , where is the Hessian of and is entrywise nonnegative. Since is exactly quadratic, holds when , and it does (for positive ):
Minimizing the quadratic gives , which is exactly the multiplicative update:
Monotone decrease is not the end of the story. It does not by itself guarantee convergence to a stationary point, and an entry that reaches zero can never leave it, since every later update multiplies it. Projected-gradient methods converge faster than the multiplicative updates in practice (Lin, 2007), and alternating nonnegative least squares, which solves each factor's constrained problem exactly, is another standard choice (Kim & Park, 2008).
Nonnegative rank, hardness and separability
The nonnegative rank is the smallest with exactly and . Always , and the first inequality can be strict. The standard example is the slack matrix of a square, which records how far each corner of a unit square lies from each of its four sides:
Rank. Rows 1 and 2 add up to , and so do rows 3 and 4, so the rows are linearly dependent; any three of them are independent.
Nonnegative rank. In an exact NMF, with nonnegative terms, so each term is nonzero only on a rectangle (a set of rows times a set of columns) inside the support of . The ones at form a fooling set: for any two of them, and , at least one of and is zero, so no rectangle inside the support contains two of them. Each needs its own term:
Hardness. Vavasis (2009) proved that exact NMF is NP-hard: deciding whether a matrix of rank has a nonnegative factorization with inner dimension , when is part of the input. For fixed the problem is polynomial: Arora, Ge, Kannan & Moitra (2012) gave an algorithm polynomial in and for every constant , and showed that time would yield a subexponential algorithm for 3-SAT; Moitra (2016) brought the running time down to . Even when an exact NMF exists it is never unique in the strict sense, since for any that keeps both factors nonnegative: positive diagonal scalings and permutations always qualify, and other matrices often do.
Separability. Donoho & Stodden (2003) asked when NMF finds the "true" parts, and identified separability: every part has an anchor, a coordinate (a pixel, a word) that no other part uses. The anchor rows of are then scaled copies of the rows of , and every row of is a nonnegative combination of them. Geometrically, the normalized rows of lie in the convex hull of the anchor rows, which convex geometry can find. Arora et al. (2012) gave a polynomial-time algorithm for separable NMF that tolerates noise. A popular choice, the successive projection algorithm, repeatedly picks the normalized row of largest norm and projects every row onto the orthogonal complement of the picked one; Gillis & Vavasis (2014) proved it robust to small perturbations. In topic models the anchors are anchor words, each occurring in only one topic (Arora et al., 2013).
Which statement about the nonnegative rank of a nonnegative matrix is true?
- It always equals the ordinary rank
- It can be read off the singular values
- It is at least the ordinary rank and can be strictly larger
- It is at most the ordinary rank, since nonnegative factors are more constrained
Show the answer
C. It is at least the ordinary rank and can be strictly larger
Every nonnegative factorization is a factorization, so ; the square's slack matrix has rank 3 and nonnegative rank 4. Computing the nonnegative rank is NP-hard in general, so no SVD-like shortcut exists.
ICA: unmixing independent sources
At a party, two microphones record different mixtures of two voices. Independent component analysis models such data as , with a square invertible mixing matrix and sources that are statistically independent, and asks for an unmixing matrix from samples of alone.
Second-order statistics get you most of the way. Whitening, with , makes . Center the sources and scale them to unit variance (their scale cannot be identified anyway); then for an orthogonal matrix . PCA does this much. The remaining rotation is exactly what ICA must find, and covariances cannot see it.
Any rotation of the whitened data is still white, so second-order statistics cannot prefer one rotation to another:
If the sources are Gaussian, , the whole distribution is rotation-invariant: every rotation of has independent standard normal coordinates. Nothing in the data distinguishes the true .
By the central limit theorem, a mixture of independent variables tends to be closer to Gaussian than the variables themselves, so ICA searches for projections that are as non-Gaussian as possible. Two measures are standard. The excess kurtosis (for zero-mean, unit-variance ) is 0 for a Gaussian, negative for light-tailed sources such as uniform noise, and positive for heavy-tailed ones such as speech. The negentropy , where is Gaussian with the same variance, is zero only for a Gaussian, and is approximated by with and a smooth contrast such as (Hyvärinen, 1999).
Optimize subject to . With and a multiplier , the optimality condition is
Solve it by Newton's method, approximating the Jacobian for whitened data by . After simplifying and renormalizing, the step is
For the kurtosis contrast , and . This update converges cubically to a source direction (Hyvärinen & Oja, 1997). Further components come one at a time with orthogonalization against those found, or all at once with symmetric decorrelation.
A source is uniform on , so it has mean 0 and variance 1. What is its excess kurtosis ?
Show the answer
-1.2
, so : lighter-tailed than a Gaussian. For a unit-variance mixture of independent sources, with , so mixing pulls the kurtosis toward 0, and maximizing undoes the mixing.
ICA is routinely used to remove eye-blink and muscle artifacts from EEG recordings, and to separate signals in fMRI and audio. Run on patches of natural images, it learns localized, oriented edge filters (Bell & Sejnowski, 1997), the same kind of features that sparse coding finds.
Sparse coding and dictionary learning
Sparse coding represents each signal as , a combination of a few atoms, the columns of a dictionary that is often overcomplete (). Given , finding the code is a lasso problem, (Tibshirani, 1996), whose penalty sets many coefficients exactly to zero. Dictionary learning also fits to the data.
Scale every atom up by and every code down by . The reconstruction is unchanged, but the penalty shrinks:
Without a constraint the penalty can be made to vanish and sparsity disappears, so the atoms are confined to the unit ball. Alternating minimization then solves a lasso per signal for the codes, and a constrained least-squares problem for the dictionary:
Algorithms. K-SVD (Aharon, Elad & Bruckstein, 2006) alternates sparse coding by a greedy pursuit with an atom-by-atom update: for atom , take the residual of the signals that use it, with atom 's contribution removed, and replace the atom and its coefficients by the best rank-1 approximation of that residual, one SVD. Online dictionary learning (Mairal, Bach, Ponce & Sapiro, 2009) processes one signal or mini-batch at a time and scales to millions of signals.
Brains. Olshausen & Field (1996) learned a sparse code for patches of natural images and found localized, oriented, bandpass atoms resembling the receptive fields of simple cells in the primary visual cortex: evidence that sparsity may be one of the principles the visual system follows. With a square invertible dictionary and no noise, sparse coding with a Laplacian prior on the codes coincides with maximum-likelihood ICA with Laplacian sources, which is why the two find similar features.
Theory. Dictionary learning is nonconvex and hard in the worst case, but identifiable for random, sparse codes. For square dictionaries, Spielman, Wang & Wright (2012) showed that samples determine the coefficient matrix uniquely and gave a polynomial-time algorithm that recovers the dictionary when the codes are sparse enough; Arora, Ge, Ma & Moitra (2015) analyzed the alternating heuristics used in practice and gave provable variants for incoherent, overcomplete dictionaries, some simple enough for a neural circuit.
| Method | Constraint | Fitted by | Identifiable up to |
|---|---|---|---|
| PCA | orthonormal components | SVD | sign, and rotations within repeated eigenvalues |
| NMF | multiplicative or alternating updates; nonconvex | scaling and permutation, only under conditions such as separability | |
| ICA | independent, non-Gaussian sources | non-Gaussianity or likelihood, after whitening | permutation and scale, if at most one source is Gaussian |
| Sparse coding | sparse codes, unit-norm atoms, often overcomplete | lasso plus dictionary updates; nonconvex | permutation and sign, for sufficiently sparse random codes |
Key takeaways
- NMF approximates with nonnegative factors, giving additive, parts-based representations. The Lee–Seung multiplicative updates are diagonally rescaled gradient steps that never increase the objective, by an auxiliary-function argument, but they can stall and they lock zeros in place.
- Nonnegative rank can exceed rank (the square's slack matrix: 3 against 4). Exact NMF is NP-hard in general, polynomial for fixed , and efficiently solvable under separability, where every part has an anchor coordinate that no other part uses.
- ICA recovers independent, non-Gaussian sources up to permutation and scale (Comon). Gaussian sources are unidentifiable because whitened Gaussian data are rotation-invariant. FastICA iterates .
- Sparse coding solves a lasso against a learned, norm-constrained dictionary. On natural image patches it learns localized, oriented, bandpass atoms resembling simple-cell receptive fields, as ICA does.
- Identifiability is the recurring question: PCA up to rotations within repeated eigenvalues, NMF under separability-type conditions, ICA up to permutation and scale, and nonlinear ICA only with auxiliary information.
Check yourself
In the interactive lesson these are scored with your confidence, and what you miss comes back for review.
Why do the Lee–Seung multiplicative updates keep and nonnegative?
- They project onto the nonnegative orthant after every step
- Each entry is multiplied by a ratio of nonnegative quantities; the per-entry step sizes are chosen to turn the gradient step into that multiplication
- They use a learning rate small enough that no entry can cross zero
- The minimum of the objective always has nonnegative factors
Show the answer
B. Each entry is multiplied by a ratio of nonnegative quantities; the per-entry step sizes are chosen to turn the gradient step into that multiplication
With , the gradient step becomes , a product of nonnegative numbers. The flip side: an entry that hits zero stays zero.
Why can ICA not separate two Gaussian sources?
- Gaussian variables are never independent
- Whitening fails for Gaussian data
- Whitened Gaussian data look the same after any rotation, so every rotation gives independent components and the mixing rotation cannot be identified
- The kurtosis of a Gaussian is infinite
Show the answer
C. Whitened Gaussian data look the same after any rotation, so every rotation gives independent components and the mixing rotation cannot be identified
After whitening, the sources are related to the data by an unknown rotation. A standard Gaussian vector is rotation-invariant, so all rotations of it have independent coordinates. Comon's theorem allows at most one Gaussian source for exactly this reason.
What is known about computing an exact nonnegative matrix factorization?
- It can always be read off from the SVD
- It is solvable in time polynomial in the matrix size and the inner dimension
- It is undecidable
- It is NP-hard in general, polynomial in the matrix size for each fixed , and efficiently solvable under separability
Show the answer
D. It is NP-hard in general, polynomial in the matrix size for each fixed , and efficiently solvable under separability
Vavasis (2009) proved NP-hardness; Arora, Ge, Kannan & Moitra (2012) gave an algorithm polynomial for constant and a polynomial-time algorithm under separability; Moitra (2016) reduced the running time to , and time would give a subexponential algorithm for 3-SAT.
Dictionary learning minimizes . Why must the atoms be constrained, say ?
- To make the problem convex
- To make the atoms orthogonal
- Because otherwise scaling the atoms up and the codes down drives the penalty to zero without changing the reconstruction, and sparsity disappears
- Because the lasso has a unique solution only with unit-norm columns
Show the answer
C. Because otherwise scaling the atoms up and the codes down drives the penalty to zero without changing the reconstruction, and sparsity disappears
while the penalty becomes . Letting makes the penalty vanish, so the infimum is the unpenalized fit and the codes need not be sparse.
Further reading
- D. D. Lee & H. S. Seung, "Algorithms for non-negative matrix factorization," Advances in Neural Information Processing Systems 13 (2000).
- S. Arora, R. Ge, R. Kannan & A. Moitra, "Computing a nonnegative matrix factorization — provably," Proceedings of the 44th ACM Symposium on Theory of Computing, 145–162 (2012).
- P. Comon, "Independent component analysis, a new concept?," Signal Processing 36(3), 287–314 (1994).
- A. Hyvärinen & E. Oja, "Independent component analysis: algorithms and applications," Neural Networks 13(4–5), 411–430 (2000).
- B. A. Olshausen & D. J. Field, "Emergence of simple-cell receptive field properties by learning a sparse code for natural images," Nature 381, 607–609 (1996).