# Non-negative matrix factorization with sparseness constraints

Sparseness constraints make non-negative matrix factorization find parts-based representations

Hoyer, Patrik O. · arXiv · 2004-8-25

- **Problem** Standard NMF produces sparse factors only as a side effect, so the sparseness cannot be chosen in advance. It also does not always recover parts-based structure, such as localized facial features.
- **Method** The authors extend NMF with projected gradient descent. After each gradient step, each factor is projected so its sparseness matches a set target while entries stay non-negative.
- **Results** On ORL faces, basis sparseness of 0.5, 0.6 and 0.75 gave localized bases, where standard NMF gave a global decomposition.

## Why sparseness needs direct control

NMF factorizes a non-negative data matrix V into non-negative factors W and H, so each data vector becomes an additive combination of shared basis vectors. The sparse structure that NMF typically produces is a by-product of the optimization, and the degree of that sparseness cannot be chosen in advance. Where a specific degree of sparseness is needed, this leaves the user without a direct handle on the representation.

The paper extends NMF so that the sparseness of the factors is fixed explicitly, and it argues that this yields parts-based representations that standard NMF does not produce. Standard NMF gives a parts-based result on one face dataset and a global decomposition on another, and it gives circular blobs rather than oriented filters on natural image patches.

## How standard NMF is posed

The data are T measurements of N non-negative variables, and each measurement vector is approximated as \\(v\_t \\approx Wh\_t\\), with the same basis matrix W used for every measurement. Stacking the measurement vectors as columns gives \\(V \\approx WH\\), so any linear representation of this kind is a factorization of the data matrix, including PCA, ICA and vector quantization.

The difference from PCA and ICA is that NMF requires every entry of W and H to be non-negative, so the data are described by additive components only.

Standard NMF minimizes the squared error \\(E(W,H) = \\\|V - WH\\\|^2\\), summed over all entries, over non-negative W and H. The objective is convex in W and in H separately but not in both at once, so the optimization is iterative, with a multiplicative update that Lee and Seung proposed.

## Measuring sparseness with the L1 and L2 norms

The sparseness measure is built from the ratio of the L1 norm to the L2 norm of a vector x of dimension n, so it rewards energy packed into few components. The measure is \\\[\\text{sparseness}(x) = \\frac{\\sqrt{n} - (\\sum\_i \|x\_i\|)/\\sqrt{\\sum\_i x\_i^2}}{\\sqrt{n} - 1}\\\], which is one when x has a single non-zero component and zero when all components have equal magnitude.

## Choosing what to constrain

Whether W, H or both should be sparse depends on the application, and transposing the data matrix swaps the two roles, so the experimenter has to decide. In a disease-symptom example, the coefficients are made sparse and the basis vectors are left unconstrained, whereas for image features both factors may be made sparse so that each object appears in few images and covers only a small part of each image.

The constrained problem minimizes \\(E(W,H) = \\\|V - WH\\\|^2\\) subject to sparseness(w\_i) = S\_w for every column of W and sparseness(h\_i) = S\_h for every row of H, where each constraint is optional. Scale can be traded between \\(w\_i\\) and \\(h\_i\\) without changing their product, so the norm of one of them is free; the method fixes the L2 norm of each \\(h\_i\\) to unity for convenience.

## Projected gradient steps

The method is a projected gradient descent: it steps along the negative gradient of the objective and then projects the result back onto the constraint set, with the step kept small enough that the objective decreases. Factors are initialized to random positive matrices, each column of W is projected to fix its L1 norm while keeping its L2 norm, and each row of H is projected to unit L2 norm with a set L1 norm.

For a constrained W the update is a gradient step \\(W := W - \\mu\_W(WH - V)H^T\\) followed by the projection, and for a constrained H it is \\(H := H - \\mu\_H W^T(WH - V)\\) followed by its projection. A factor without a sparseness constraint is updated with the standard multiplicative step instead, and the step sizes are adapted automatically rather than set by the user.

The implementation monitors the objective throughout the optimization and adapts the stepsizes to keep it converging.

## The projection operator

The projection takes any vector x and returns the closest non-negative vector s, in the Euclidean sense, that has a given L1 norm and a given L2 norm. The procedure first shifts x onto the hyperplane where the components sum to the L1 value, then moves radially within that hyperplane onto the intersection with the L2 sphere, centred on the point where all components are equal.

If some components become negative, they are fixed at zero, the remaining components are shifted to keep the sum, and the step is repeated under these extra constraints. For a general vector, the signs of the entries are recorded, the absolute values are projected in the first quadrant, and the signs are restored. In principle the procedure can need as many iterations as the dimension of x, because each pass adds at least one component to the zero set, although in practice it converges much faster.

## Software release

A MATLAB package implements the projection operator, NMF, the sparseness-constrained variant and the other extensions discussed in the paper. It also contains the files needed to reproduce the reported results, but the face image databases are excluded for copyright reasons and must be obtained separately.

## Face image results

Standard NMF gives parts-based features such as the mouth, nose and eyes on the CBCL faces, but a global decomposition on the ORL faces, where the images are less well aligned. The sparseness-constrained method was applied to both face datasets to compare against these baselines.

On CBCL, a basis sparseness of 0.8 with unconstrained coefficients gives a local representation similar to the one standard NMF finds. A basis sparseness of 0.2 gives a non-local representation, and constraining the coefficients to 0.8 instead gives a global representation that resembles vector quantization. The authors stress that the constrained method does not always produce local solutions, since the sparseness setting determines which kind of representation emerges.

On ORL, basis sparseness set to 0.5, 0.6 and 0.75 yields localized bases, in contrast to the global decomposition of standard NMF. The authors report that the result is not very sensitive to the particular sparseness level within these settings.

## Oriented features from natural image patches

Standard NMF applied to ON/OFF-filtered natural image patches produces circular features rather than oriented filters. The authors argue that this is not a simple sparsifying of the standard NMF result, because the constrained method finds a qualitatively different parts-based representation, and they relate the oriented features to those used by the early visual system.

## Convergence of the projection step

The convergence tests vary the dimensionality, the desired sparseness and the initial sparseness of the vector. Desired and initial sparseness were each set to 0.1, 0.3, 0.5, 0.7 and 0.9, and dimensionality ranged from 2 up to 10000, with all combinations analysed. The worst case was a desired sparseness of 0.9 starting from an initial sparseness of 0.1.

The average iteration count grows very slowly with dimensionality, while the minimum and maximum over identical random trials are also plotted.

## Relation to earlier NMF extensions

LNMF produces local features on the ORL database, similar to those of the present method, but it does not give oriented filters from natural image data and offers no explicit control of sparseness. The author's earlier non-negative sparse coding made sparseness adjustable, but the setting had to be found by trial and error.

ICA usually does not restrict the signs of its components, and its sparseness enters through the objective rather than as a fixed target; the non-negative ICA methods treat non-negativity as an objective, not a constraint.

## Limitations

The experimenter must decide which factor to constrain, and the sparseness target is set by the user for each case. The authors give no analytical bounds on the performance of the projection algorithm, and their convergence result is empirical.

The face and natural-image comparisons are presented as basis images and judged qualitatively, and the text reports no quantitative score for how parts-based a result is. The ORL sensitivity check covers only the sparseness levels 0.5, 0.6 and 0.75.

## Paper info

- **Authors**: Hoyer, Patrik O.
- **Venue**: arXiv · Preprint
- **First published**: 2004-8-25
- **Added**: 2026-11-12
- **Updated**: 2004-8-25
- **Version**: v1
- **arXiv**: cs/0408058
- **Category**: cs.LG · cs.NE
- **Original paper terms**: [Check in the original ↗](https://arxiv.org/abs/cs/0408058v1)
- **What we show**: Paper info and commentary

[Original paper ↗](https://arxiv.org/abs/cs/0408058v1) · [PDF ↗](https://arxiv.org/pdf/cs/0408058v1)

AI commentary is a separate explanation from the original paper and may contain errors. The original paper and figures follow each source's terms of use and any rights noted separately.

## Quote from the paper

Hoyer, Patrik O. (2004). Non-negative matrix factorization with sparseness constraints. arXiv:cs/0408058v1. https://arxiv.org/abs/cs/0408058v1

**BibTeX**

```
@misc{o2004negative,
  title = {{Non-negative matrix factorization with sparseness constraints}},
  author = {Hoyer, Patrik O.},
  year = {2004},
  eprint = {cs/0408058},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/cs/0408058v1}
}
```

## Other paper commentary

- [Neural Turing Machines](https://refivu.com/en/papers/98345e56-0459-409a-bde9-37eadc2f2d0a-neural-turing-machines.md)
- [All-Optical Machine Learning Using Diffractive Deep Neural Networks](https://refivu.com/en/papers/818615cb-8c22-447c-a0a6-77954575b98a-all-optical-machine-learning-using-diffractive-deep-neural.md)
- [Paying More Attention to Attention: Improving the Performance of Convolutional Neural Networks via Attention Transfer](https://refivu.com/en/papers/9fd3c7c3-a01f-4f1c-84a7-72570c46bdd4-paying-more-attention-to-attention-improving-the-performance.md)
- [CvT: Introducing Convolutions to Vision Transformers](https://refivu.com/en/papers/4d0c84cf-05bb-4f74-822e-0b8fbc635203-cvt-introducing-convolutions-to-vision-transformers.md)
- [Methods for Interpreting and Understanding Deep Neural Networks](https://refivu.com/en/papers/beae0f88-5d82-43a5-a727-e94025cff266-methods-for-interpreting-and-understanding-deep-neural.md)
- [Learning Multi-Domain Convolutional Neural Networks for Visual Tracking](https://refivu.com/en/papers/5b8779fe-6230-4bef-9d38-11634c64c64a-learning-multi-domain-convolutional-neural-networks-for.md)
- [YOLACT: Real-time Instance Segmentation](https://refivu.com/en/papers/5c58130c-e869-497b-8b85-e21d46848fe1-yolact-real-time-instance-segmentation.md)
- [A Gentle Introduction to Conformal Prediction and Distribution-Free Uncertainty Quantification](https://refivu.com/en/papers/f99c2916-c5f5-45e3-8503-ed9342776182-a-gentle-introduction-to-conformal-prediction-and.md)
- [SiamRPN++: Evolution of Siamese Visual Tracking with Very Deep Networks](https://refivu.com/en/papers/bd27ac05-aab2-4448-8e23-79659dfe759b-siamrpn-evolution-of-siamese-visual-tracking-with-very.md)
- [A Review on Deep Learning Techniques Applied to Semantic Segmentation](https://refivu.com/en/papers/8ae0e955-3ed5-48a2-b638-f9e5d7aa334e-a-review-on-deep-learning-techniques-applied-to.md)
- [Thumbs up? Sentiment Classification using Machine Learning Techniques](https://refivu.com/en/papers/099cc783-1d4a-4899-b08c-ce3886810f1a-thumbs-up-sentiment-classification-using-machine-learning.md)
- [Run, Don't Walk: Chasing Higher FLOPS for Faster Neural Networks](https://refivu.com/en/papers/dffa1011-36cd-44c9-b21a-c10cc00af851-run-don-t-walk-chasing-higher-flops-for.md)

## Terms in this paper

- [Principal component analysis](https://refivu.com/en/terms/5e8334d817e7-principal-component-analysis)
- [independent component analysis](https://refivu.com/en/terms/6d4dccf8a165-independent-component-analysis)
- [squared error](https://refivu.com/en/terms/7c762142beba-squared-error)
- [NMF](https://refivu.com/en/terms/a1b4d51c713f-nmf)
- [non-negative matrix factorization](https://refivu.com/en/terms/3dfb75e5a681-non-negative-matrix-factorization)

---

AI-written text can contain mistakes. [Refivu](https://refivu.com/en/papers/56eb7310-b0a6-4b18-9880-4ca6ff6f54dc-non-negative-matrix-factorization-with-sparseness)
