# NICE: Non-linear Independent Components Estimation

NICE learns an invertible map that makes image data easy to model

Laurent Dinh, David Krueger, Yoshua Bengio · arXiv · 2014-10-30

- **Problem** Fitting a density to high-dimensional data with unknown structure is hard when the model must also allow exact likelihood and cheap sampling. Earlier models gave up one of these properties to keep the others.
- **Method** NICE stacks additive coupling layers with unit Jacobian determinant under a factorial prior.
- **Results** NICE reached a test log-likelihood of 5514.71 on TFD and 5371.78 on CIFAR-10. Deep mixtures of factor analysers scored 5250 and 3622 on those datasets, but those are variational lower bounds.

## Why factorize the data with an invertible map

The modeling target is a complex data distribution whose structure is unknown, and NICE tackles it by searching for a representation in which the data becomes easy to model. Concretely, a transformation h = f(x) is learned so that the components of h are independent under a prior, which turns the density of the data into a product of simple one-dimensional terms.

The change of variables rule connects the data density to the prior density of h through the absolute Jacobian determinant of f, so the exact log-likelihood can be written down and maximized directly. The map must be invertible and must have the same dimension as the data, and the determinant and the inverse must both be cheap, because sampling runs the inverse map on prior samples.

Without a constraint, an invertible preprocessing could raise the likelihood simply by contracting the data, and the determinant term in the criterion is there to counter this effect.

## Coupling layers with triangular Jacobians

The design starts from the observation that a triangular matrix has a determinant equal to the product of its diagonal entries, and that such matrices compose. Instead of constraining every weight matrix, the model uses a family of nonlinear maps whose Jacobian is triangular, so that only the diagonal needs to be easy to evaluate.

A coupling layer splits the input into two blocks, copies the first block unchanged, and transforms the second block with a coupling law that depends on the first block through a function m. Because the Jacobian then has an identity block in its upper rows, its determinant reduces to the determinant of the derivative of the transformed block with respect to itself, and the inverse only needs the copied block and the same function m.

The additive coupling law adds the output of m to the second block, so the forward map is y2 = x2 + m(x1) with y1 = x1, and the inverse subtracts m(y1) from y2. The determinant of this layer is 1, the inverse costs the same as the forward pass, and m can be any function, for example a deep network with d inputs and D-d outputs. The authors chose the additive law for numerical stability, noting that the transformation stays piecewise linear when m is a rectified network.

## Stacking layers and scaling the latent space

Each additive layer leaves part of its input fixed, so the roles of the two subsets must alternate between successive layers. The authors found that at least three coupling layers are needed before every dimension can influence every other one, and they generally use four.

Since every additive layer is volume preserving, a composition of such layers would also have unit determinant, which limits how the density can be reshaped. A diagonal scaling matrix S placed as the top layer multiplies the i-th output by S\_ii, so the model can give more weight to some dimensions and less to others.

With this last scaling stage, the criterion becomes a sum over dimensions of the log-prior of each transformed component plus log\|S\_ii\|, written as \\\\(\\\\log p\_X(x)=\\\\sum\_i\[\\\\log p\_{H\_i}(f\_i(x))+\\\\log\|S\_{ii}\|\]\\\\). The prior term pushes S\_ii toward small values, while the log-determinant term keeps S\_ii from reaching zero.

The factorial prior is taken from standard families: a Gaussian, or a logistic distribution whose log-density is written as minus log(1 + exp(h)) minus log(1 + exp(-h)). The authors prefer the logistic family because it tends to give a better behaved gradient, and they use it for MNIST, SVHN and CIFAR-10, while TFD uses a standard normal prior.

For the image experiments, the odd-indexed and even-indexed input components form the two subsets, and the four coupling layers alternate the roles. Each coupling function is a deep rectified network with linear output units, with five hidden layers of 1000 units for MNIST, four hidden layers of 5000 units for TFD, and four hidden layers of 2000 units for SVHN and CIFAR-10.

## Training by exact likelihood and sampling

Training maximizes the log-density of h under the prior plus the sum of the scale exponents s\_i, with the diagonal scale parametrized as exp(s).

Pixel data are dequantized by adding uniform noise and rescaling into \[0, 1\]^D, while CIFAR-10 is rescaled into \[-1, 1\]^D after its own uniform noise is added. TFD is used as unlabeled data, so only the image values enter training.

Sampling is ancestral: a latent vector is drawn from the prior, and the inverse map returns the data sample, so the samples are unbiased in the sense the authors use. Unbiased samples from models trained on MNIST, TFD, SVHN and CIFAR-10 are shown in Fig. 5.

## Log-likelihood on four image datasets

NICE reaches test log-likelihoods of 1980.50 on MNIST, 5514.71 on TFD, 11496.55 on SVHN and 5371.78 on CIFAR-10.

On TFD the value is 5514.71 against 5250 for deep mixtures of factor analysers, and on CIFAR-10 it is 5371.78 against 3622. Those baseline values come from prior work, and they are variational lower bounds, so the comparison does not hold a shared evaluation protocol fixed. A GRBM entry in the same comparison table gives 2413 on TFD and 2365 on CIFAR-10.

The authors make no comparison for MNIST, because generative models on continuous MNIST are usually evaluated with Parzen window estimation, which cannot be matched fairly to an exact likelihood.

## Inpainting with the trained model

Observed pixels are clamped to their ground-truth values, and the masked hidden dimensions are updated by projected gradient ascent on the likelihood, with Gaussian noise added to each step so the input stays in its original range. The update is \\\\(x\_{H,i+1}=x\_{H,i}+\\\\alpha\_i\\\\left(\\\\partial \\\\log p\_X((x\_O,x\_{H,i}))/\\\\partial x\_{H,i}+\\\\epsilon\\\\right)\\\\) with \\\\(\\\\epsilon\\\\sim\\\\mathcal{N}(0,I)\\\\), where \\\\(\\\\alpha\_i\\\\) is a step size that depends on the iteration i.

With the middle masks almost no information about the digit remains, so those cases test the prior more than the observed pixels.

The completions look reasonable qualitatively even though the model was trained only for density estimation, but the procedure sometimes produces spurious modes.

## Links to variational and autoregressive models

Their training criterion is a variational lower bound on the log-likelihood, which can be suboptimal with respect to the true log-likelihood.

The authors argue that when the transformation and its inverse form a perfect auto-encoder pair, the reconstruction term is a constant and can be dropped, leaving a prior term log p\_H(f(x)) and an entropy-like term log\|det(∂f(x)/∂x)\|. They read the Kullback-Leibler form of the variational criterion as close to the NICE criterion, and they note that a reparametrization trick combined with two affine coupling layers yields the same structure in Appendix C.

NADE is a tractable autoregressive model with a strictly triangular adjacency matrix, which is a structure related to the triangular Jacobian used here. Its element-by-element sampling makes ancestral sampling computationally expensive and hard to parallelize on high-dimensional image data.

## Limits of the evidence

The log-likelihood comparison rests on two reference values from prior work for TFD and CIFAR-10, which are variational lower bounds, and no MNIST baseline is compared.

Inpainting is assessed only qualitatively on MNIST, the model was not trained for that task, and spurious modes occasionally appear.

The reported configurations use four coupling layers on four image datasets, and the text reports no run with fewer than four layers. The variational auto-encoder connection is argued in the text and Appendix C rather than tested in experiments.

## Paper info

- **Authors**: Laurent Dinh, David Krueger, Yoshua Bengio
- **Venue**: arXiv · Preprint
- **First published**: 2014-10-30
- **Added**: 2026-11-6
- **Updated**: 2015-4-10
- **Version**: v6
- **arXiv**: 1410.8516
- **Category**: cs.LG
- **Original paper terms**: [arXiv non-exclusive 1.0](https://arxiv.org/licenses/nonexclusive-distrib/1.0/)
- **What we show**: Paper info and commentary

[Original paper ↗](https://arxiv.org/abs/1410.8516v6) · [PDF ↗](https://arxiv.org/pdf/1410.8516v6)

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

Laurent Dinh, David Krueger, Yoshua Bengio (2014). NICE: Non-linear Independent Components Estimation. arXiv:1410.8516v6. https://arxiv.org/abs/1410.8516v6

**BibTeX**

```
@misc{dinh2014nice,
  title = {{NICE: Non-linear Independent Components Estimation}},
  author = {Laurent Dinh and David Krueger and Yoshua Bengio},
  year = {2014},
  eprint = {1410.8516},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/1410.8516v6}
}
```

## Other paper commentary

- [Gaussian Error Linear Units (GELUs)](https://refivu.com/en/papers/264fd129-ba49-4e4c-ac1f-59466a4e43ea-gaussian-error-linear-units-gelus.md)
- [Flood forecasting with machine learning models in an operational framework](https://refivu.com/en/papers/8c06bfa1-bf42-4eb0-a60b-e8159e870151-flood-forecasting-with-machine-learning-models-in-an.md)
- [Towards Learning Universal, Regional, and Local Hydrological Behaviors via Machine-Learning Applied to Large-Sample Datasets](https://refivu.com/en/papers/c1ee1227-dd45-4aef-9943-a760b7a45dbc-towards-learning-universal-regional-and-local-hydrological.md)
- [Explaining a Series of Models by Propagating Shapley Values](https://refivu.com/en/papers/156a125e-30ec-4bbb-8d1f-a941c551d78c-explaining-a-series-of-models-by-propagating-shapley.md)
- [The Reliability Function of Error-Correcting Output Codes with Noisy Binary Classifiers](https://refivu.com/en/papers/8c266525-b2cc-4dc5-bfd3-2f2927e30f5a-the-reliability-function-of-error-correcting-output-codes.md)
- [Typical Angina, Reversed: A Long-Standing Documentation Error in the UCI Heart Disease Data](https://refivu.com/en/papers/b1cd0f68-7d26-46cf-88cd-e57ef82a37ed-typical-angina-reversed-a-long-standing-documentation-error.md)
- [Fast R-CNN](https://refivu.com/en/papers/cf1d88ea-f632-4173-bcfd-eec504e5c175-fast-r-cnn.md)
- [End-to-End Training of Deep Visuomotor Policies](https://refivu.com/en/papers/67bd34bf-8571-4d8e-9691-251431e21af1-end-to-end-training-of-deep-visuomotor-policies.md)
- [Conditional Generative Adversarial Nets](https://refivu.com/en/papers/d3b21f1b-88e4-4eb8-87c5-4d87d9be7555-conditional-generative-adversarial-nets.md)
- [Unsupervised Deep Anomaly Detection for Multi-Sensor Time-Series Signals](https://refivu.com/en/papers/878b018b-6c5e-4a6c-9708-982ce4d20f8a-unsupervised-deep-anomaly-detection-for-multi-sensor-time.md)
- [Adaptive Fourier Neural Operators: Efficient Token Mixers for Transformers](https://refivu.com/en/papers/e1ad5f0d-a89a-4cb3-8342-dd757fe4cb2a-adaptive-fourier-neural-operators-efficient-token-mixers-for.md)
- [GPT Understands, Too](https://refivu.com/en/papers/1bee23a9-1e12-440d-bf82-0263604d14f2-gpt-understands-too.md)

## Terms in this paper

- [CIFAR-10](https://refivu.com/en/terms/19035a518d0a-cifar-10)
- [MNIST](https://refivu.com/en/terms/28b9bb66d1c6-mnist)
- [ADAM](https://refivu.com/en/terms/0e9ad0199e08-adam)
- [Inpainting](https://refivu.com/en/terms/dc2386251bc9-inpainting)
- [ancestral sampling](https://refivu.com/en/terms/bff41f4f1f7f-ancestral-sampling)
- [NICE](https://refivu.com/en/terms/dc8b2ee78055-nice)
- [change of variables formula](https://refivu.com/en/terms/e338e6e4ef31-change-of-variables-formula)
- [coupling layer](https://refivu.com/en/terms/edd4ec7637e8-coupling-layer)
- [prior distribution](https://refivu.com/en/terms/b6ea35b09899-prior-distribution)
- [Toronto face dataset](https://refivu.com/en/terms/c5e0c2402fbd-toronto-face-dataset)

---

AI-written text can contain mistakes. [Refivu](https://refivu.com/en/papers/f56da4f3-4308-4b66-a0bf-e0d6e495195a-nice-non-linear-independent-components-estimation)
