NICE
11 memberslucid.models.generative.niceNICE family — Dinh, Krueger & Bengio, 2014 (additive-coupling flow).
Dinh, Laurent, David Krueger, and Yoshua Bengio. "NICE: Non-linear Independent Components Estimation." International Conference on Learning Representations, Workshop Track, 2015.
NICE is the first normalizing flow trained on images: instead of bounding the likelihood (VAE) or factorising it over pixels (autoregressive models), it learns an invertible map onto a latent space with a factorised prior, so the exact data log-density falls straight out of the change-of-variables formula
Nothing is approximated — no variational gap, no Markov chain — but every layer now has to be invertible and have a cheap Jacobian determinant, which is a severe architectural constraint.
The construction that satisfies both is the additive coupling layer. Partition the dimensions into two blocks and update only the second, conditioned on the first:
The Jacobian is unit lower-triangular, so its determinant is no matter how deep the coupling network is, and the inverse is the same graph with one sign flipped, . Since one block passes through untouched, consecutive layers must exchange the roles of the two blocks; at least three couplings are required before every dimension can influence every other, and the paper stacks four with deep rectified networks (linear output units) as the 's.
A stack of volume-preserving maps is itself volume-preserving, so NICE closes the flow with a learned diagonal scaling — the only stage that moves the determinant:
The scales behave as learned per-dimension importance weights: directions the model captures well are given small scale, making the non-linear analogue of an eigenvalue spectrum in PCA. The prior is a standard logistic (heavier tails, used for MNIST / SVHN / CIFAR-10) or a standard normal (used for TFD).
Generation is exact and parallel — draw , return — with no decoder and no iterative refinement. The coupling layer introduced here is the direct ancestor of RealNVP (affine couplings, multi-scale spatial masks) and Glow (invertible 1x1 convolutions); the samples look blurry by modern standards, but the recipe defined how exact-likelihood generative models are built.
Classes
Functions
nice_cifar→ NICEModel72.6MConstruct the NICE flow for the CIFAR-10 setup.
nice_cifar_gen→ NICEForImageGeneration72.6MNICE generator for the CIFAR-10 setup (NLL loss + .generate()).
nice_mnist→ NICEModel19.2MConstruct the NICE flow for the MNIST setup.
nice_mnist_gen→ NICEForImageGeneration19.2MNICE generator for the MNIST setup (NLL loss + .generate()).
nice_svhn→ NICEModel72.6MConstruct the NICE flow for the SVHN setup.
nice_svhn_gen→ NICEForImageGeneration72.6MNICE generator for the SVHN setup (NLL loss + .generate()).
nice_tfd→ NICEModel346MConstruct the NICE flow for the Toronto Face Database setup.
nice_tfd_gen→ NICEForImageGeneration346MNICE generator for the TFD setup (NLL loss + .generate()).