Abstract
Normalising flows (NFs) for discrete data are challenging because parameterising bijective transformations of discrete variables requires predicting discrete/integer parameters. Having a neural network architecture predict discrete parameters takes a non-differentiable activation function (eg, the step function) which precludes gradient-based learning. To circumvent this non-differentiability, previous work has employed biased proxy gradients, such as the straight-through estimator. We present an unbiased alternative where rather than deterministically parameterising one transformation, we predict a distribution over latent transformations. With stochastic transformations, the marginal likelihood of the data is differentiable and gradient-based learning is possible via score function estimation. To test the viability of discrete-data NFs we investigate performance on binary MNIST. We observe great challenges with both deterministic proxy gradients and unbiased score function estimation. Whereas the former often fails to learn even a shallow transformation, the variance of the latter could not be sufficiently controlled to admit deeper NFs.
Introduction
Normalizing Flows (NFs) are powerful generative models that transform a simple base distribution into a complex one through a series of invertible mappings. While they have seen significant success in continuous domains, applying them to discrete data—such as text or binary images—remains a significant challenge. The core difficulty lies in the non-differentiability of discrete transformations. To bijectively map discrete variables, architectures often require discrete parameters (e.g., XOR operations). Predicting these parameters via neural networks necessitates threshold functions, whose derivatives are zero almost everywhere, effectively halting gradient-based learning.
Historically, researchers have relied on the Straight-Through Estimator (STE), which treats the threshold function as an identity mapping during backpropagation. Although STE enables training, it introduces bias and its reliability in deep architectures is not well-established.
Methodology: Latent Transformations
This work proposes a shift from deterministic to stochastic latent transformations. Instead of predicting a single discrete transformation, the model predicts the parameters of a distribution over possible transformations.
Stochastic Treatment and SFE
By treating the transformation as a latent variable, the marginal likelihood of the data becomes an expectation, allowing optimization of the Evidence Lower Bound (ELBO). To obtain gradients through this stochastic process, the Score Function Estimator (SFE)—also known as REINFORCE—is employed. Unlike STE, SFE provides unbiased gradients.
Variance Reduction
To manage the high variance inherent in SFE, several techniques are implemented:
- Self-Critic Baselines: Centering the learning signal by subtracting the performance of an independently sampled transformation.
- Local Factorization: Gradients are factorized so that each pixel and layer receives a "local" reward signal, preventing noise from exploding with depth.
- XOR Flows: The architecture utilizes a generalized XOR transformation as a fundamental building block for discrete bijective mappings.
Experimental Results
The models were evaluated on binarized MNIST, where pixel intensities are treated as Bernoulli probabilities. The performance was measured using Negative Log-Likelihood (NLL).
As shown in the results table, the SFE approach (specifically the "special case" with a running average baseline) achieved an NLL of 190.1, significantly outperforming the best STE model (NLL 205.6 at depth 4). Notably, the SFE model achieved superior results with a single layer, whereas the STE model required greater depth to improve, though it still fell short of the SFE performance.
The "Greedy" evaluation—using the most likely transformation at test time—performed nearly as well as the full stochastic evaluation. This suggests that the model successfully concentrates probability mass on effective transformations during training.
Discussion and Limitations
While unbiased gradients offer a clear performance advantage for shallow models, scalability remains the primary hurdle. The variance of the gradient estimator becomes increasingly difficult to control as the flow depth increases. In this study, SFE models struggled to scale beyond a single layer without excessive noise. Future research may benefit from more advanced estimators like RELAX or REBAR, or more expressive conditioner architectures like Transformers to better manage the variance-depth tradeoff in discrete latent flows.
Summary updated