Papers
Topics
Authors
Recent
Search
2000 character limit reached

Semi-Conditional Normalizing Flow (SCNF)

Updated 14 December 2025
  • SCNF is a semi-supervised model that explicitly defines the joint distribution over inputs and labels using a two-stage (unconditional and conditional) flow architecture.
  • It leverages conditional affine coupling layers to enable tractable density computation and efficient marginal likelihood estimation via a log-sum-exp formulation.
  • Empirical results on benchmarks like MNIST demonstrate SCNF’s state-of-the-art performance with low error rates, validating its design and optimization strategy.

Semi-Conditional Normalizing Flow (SCNF) is a class of normalizing flow models designed for semi-supervised learning through explicit modeling of the joint distribution over inputs and discrete labels. By employing a two-stage (semi-conditional) flow architecture—comprising an unconditional flow followed by a conditional component—SCNF efficiently leverages both labeled and unlabeled data. The architecture enables efficient computation of marginal likelihoods, supports principled parameter learning using exact joint and marginal maximum likelihood, and yields state-of-the-art performance in semi-supervised settings on canonical benchmarks (Atanov et al., 2019).

1. Joint Density Model and Decomposition

SCNF constructs an explicit model of the joint distribution p0(x,y)p_0(x, y) for input data xRdx \in \mathbb{R}^d and discrete labels y{1,,K}y \in \{1, \ldots, K\},

p0(x,y)=p0(y)p0(xy)p_0(x, y) = p_0(y) \, p_0(x \mid y)

where p0(y)=1/Kp_0(y)=1/K (uniform prior), and p0(xy)p_0(x \mid y) is defined by a normalizing flow with a latent Gaussian base. Introducing an invertible mapping f0(x;y,θ)f_0(x; y, \theta) yields, via change of variables,

logp0(xy)=logpz(z;y)+logdetf0(x;y)/x\log p_0(x \mid y) = \log p_z(z; y) + \log |\det \partial f_0(x; y)/\partial x|

with pz(z;y)=N(z0,I)p_z(z; y) = \mathcal{N}(z \mid 0, I). The joint log-density thus decomposes as

logp0(x,y)=logp0(y)+logN(z0,I)+logdetJf0(x;y)\log p_0(x, y) = \log p_0(y) + \log \mathcal{N}(z \mid 0, I) + \log |\det J_{f_0}(x; y)|

This explicit formulation allows the model to maximize both joint and marginal likelihoods in a unified semi-supervised learning objective.

2. Semi-Conditional Architecture and Mapping Structure

SCNF divides the invertible mapping into two cascaded components:

  1. Unconditional flow xRdx \in \mathbb{R}^d0: Maps input xRdx \in \mathbb{R}^d1 to a semantic latent xRdx \in \mathbb{R}^d2 and auxiliary latent xRdx \in \mathbb{R}^d3, with xRdx \in \mathbb{R}^d4.
  2. Conditional flow xRdx \in \mathbb{R}^d5: Maps xRdx \in \mathbb{R}^d6 to xRdx \in \mathbb{R}^d7 and conditions explicitly on xRdx \in \mathbb{R}^d8.

Formally,

xRdx \in \mathbb{R}^d9

y{1,,K}y \in \{1, \ldots, K\}0

The Jacobian determinant for the composition factorizes as

y{1,,K}y \in \{1, \ldots, K\}1

This two-stage structure underpins efficient marginalization over classes, with y{1,,K}y \in \{1, \ldots, K\}2 computed once per input and y{1,,K}y \in \{1, \ldots, K\}3 applied y{1,,K}y \in \{1, \ldots, K\}4 times (once for each label class).

3. Conditional Affine Coupling Layers

The conditional flow y{1,,K}y \in \{1, \ldots, K\}5 and portions of the unconditional flow y{1,,K}y \in \{1, \ldots, K\}6 are constructed from conditional affine-coupling blocks. Each block partitions the input y{1,,K}y \in \{1, \ldots, K\}7 into y{1,,K}y \in \{1, \ldots, K\}8 and applies the transformation

y{1,,K}y \in \{1, \ldots, K\}9

where p0(x,y)=p0(y)p0(xy)p_0(x, y) = p_0(y) \, p_0(x \mid y)0 and p0(x,y)=p0(y)p0(xy)p_0(x, y) = p_0(y) \, p_0(x \mid y)1 are neural networks conditioned on p0(x,y)=p0(y)p0(xy)p_0(x, y) = p_0(y) \, p_0(x \mid y)2 and the one-hot encoded label p0(x,y)=p0(y)p0(xy)p_0(x, y) = p_0(y) \, p_0(x \mid y)3. The inverse transformation is

p0(x,y)=p0(y)p0(xy)p_0(x, y) = p_0(y) \, p_0(x \mid y)4

The log-Jacobian determinant for a single block is p0(x,y)=p0(y)p0(xy)p_0(x, y) = p_0(y) \, p_0(x \mid y)5. This parameterization allows tractable density computation and invertibility for both conditional and unconditional components.

4. Marginal Likelihood and Computational Efficiency

The marginal likelihood for unlabeled instances computes as

p0(x,y)=p0(y)p0(xy)p_0(x, y) = p_0(y) \, p_0(x \mid y)6

Given that p0(x,y)=p0(y)p0(xy)p_0(x, y) = p_0(y) \, p_0(x \mid y)7 does not depend on p0(x,y)=p0(y)p0(xy)p_0(x, y) = p_0(y) \, p_0(x \mid y)8, the flow computation p0(x,y)=p0(y)p0(xy)p_0(x, y) = p_0(y) \, p_0(x \mid y)9 is executed once. For each possible label p0(y)=1/Kp_0(y)=1/K0, p0(y)=1/Kp_0(y)=1/K1 is passed through p0(y)=1/Kp_0(y)=1/K2 to obtain p0(y)=1/Kp_0(y)=1/K3. The marginal log-likelihood thus becomes

p0(y)=1/Kp_0(y)=1/K4

This log-sum-exp formulation allows for efficient exact computation of both value and gradients, with posterior responsibilities p0(y)=1/Kp_0(y)=1/K5 facilitating gradient computation with respect to model parameters.

5. Training Objective and Optimization Strategy

SCNF maximizes the exact joint log-likelihood on labeled data and the marginal log-likelihood on unlabeled data: p0(y)=1/Kp_0(y)=1/K6 For labeled pairs, the calculation follows the full joint density expression, while for unlabeled data, the marginal (log-sum-exp) form is used. Stochastic gradient ascent (e.g., Adam optimizer) is applied directly to this objective. An EM-SGD variant—alternating between computing the class posteriors p0(y)=1/Kp_0(y)=1/K7 and performing a parameter update—yields similar performance. No variational approximations or bounds are required.

On more complex datasets, it is sometimes beneficial to introduce an auxiliary classification loss on p0(y)=1/Kp_0(y)=1/K8 to promote label separation, though this was unnecessary for MNIST.

6. Model Architecture and Hyperparameters

The SCNF architecture and associated hyperparameters employ the following components:

  • Data preprocessing: Inputs (MNIST) are dequantized to p0(y)=1/Kp_0(y)=1/K9, then transformed via p0(xy)p_0(x \mid y)0 with p0(xy)p_0(x \mid y)1.
  • Unconditional Flow p0(xy)p_0(x \mid y)2: Multi-scale Glow-style network with three levels of "squeezing", ActNorm, invertible p0(xy)p_0(x \mid y)3 convolutions, and affine-coupling layers. Each coupling layer uses 4-layer residual MLPs (hidden width 64) for p0(xy)p_0(x \mid y)4.
  • Conditional Flow p0(xy)p_0(x \mid y)5: Four channel-wise conditional coupling layers, also parameterized by residual MLPs processing the input and one-hot p0(xy)p_0(x \mid y)6. The dimension is reduced by factoring out features at two points, but best results used p0(xy)p_0(x \mid y)7.
  • Training: Adam optimizer, learning rate p0(xy)p_0(x \mid y)8, batch size p0(xy)p_0(x \mid y)9 (half labeled, half unlabeled), weight decay f0(x;y,θ)f_0(x; y, \theta)0. The model is trained for f0(x;y,θ)f_0(x; y, \theta)1K iterations per MNIST split.

A summary table of key architecture values from the MNIST setup follows:

Component Parameterization Typical Value
Unconditional flow f0(x;y,θ)f_0(x; y, \theta)2 Glow, 3 scales, 4-layer residual MLPs f0(x;y,θ)f_0(x; y, \theta)3, f0(x;y,θ)f_0(x; y, \theta)4 f0(x;y,θ)f_0(x; y, \theta)5
Conditional flow f0(x;y,θ)f_0(x; y, \theta)6 4 conditional affine-coupling layers, MLPs f0(x;y,θ)f_0(x; y, \theta)7
Optimizer Adam, learning rate, batch size f0(x;y,θ)f_0(x; y, \theta)8, f0(x;y,θ)f_0(x; y, \theta)9

7. Empirical Evaluation and Ablation Findings

Comprehensive empirical analysis demonstrates the effectiveness of SCNF in semi-supervised scenarios:

  • Toy 2D classification (moons, circles, logp0(xy)=logpz(z;y)+logdetf0(x;y)/x\log p_0(x \mid y) = \log p_z(z; y) + \log |\det \partial f_0(x; y)/\partial x|0 labeled): SCNF-GLOW achieves logp0(xy)=logpz(z;y)+logdetf0(x;y)/x\log p_0(x \mid y) = \log p_z(z; y) + \log |\det \partial f_0(x; y)/\partial x|1 test error and NLL logp0(xy)=logpz(z;y)+logdetf0(x;y)/x\log p_0(x \mid y) = \log p_z(z; y) + \log |\det \partial f_0(x; y)/\partial x|2, significantly outperforming SCNF-GMM (logp0(xy)=logpz(z;y)+logdetf0(x;y)/x\log p_0(x \mid y) = \log p_z(z; y) + \log |\det \partial f_0(x; y)/\partial x|3 error) and unconditional flows.
  • MNIST (100 labels): Kingma et al.'s VAE achieves logp0(xy)=logpz(z;y)+logdetf0(x;y)/x\log p_0(x \mid y) = \log p_z(z; y) + \log |\det \partial f_0(x; y)/\partial x|4 test error; SCNF-GMM yields logp0(xy)=logpz(z;y)+logdetf0(x;y)/x\log p_0(x \mid y) = \log p_z(z; y) + \log |\det \partial f_0(x; y)/\partial x|5 (insufficient), whereas SCNF-GLOW attains logp0(xy)=logpz(z;y)+logdetf0(x;y)/x\log p_0(x \mid y) = \log p_z(z; y) + \log |\det \partial f_0(x; y)/\partial x|6 error, bits/dim logp0(xy)=logpz(z;y)+logdetf0(x;y)/x\log p_0(x \mid y) = \log p_z(z; y) + \log |\det \partial f_0(x; y)/\partial x|7. EM-SGD versus direct SGD yielded identical performance.
  • Ablation—latent dimension logp0(xy)=logpz(z;y)+logdetf0(x;y)/x\log p_0(x \mid y) = \log p_z(z; y) + \log |\det \partial f_0(x; y)/\partial x|8: logp0(xy)=logpz(z;y)+logdetf0(x;y)/x\log p_0(x \mid y) = \log p_z(z; y) + \log |\det \partial f_0(x; y)/\partial x|9 underfits with pz(z;y)=N(z0,I)p_z(z; y) = \mathcal{N}(z \mid 0, I)0 test error; pz(z;y)=N(z0,I)p_z(z; y) = \mathcal{N}(z \mid 0, I)1 achieves pz(z;y)=N(z0,I)p_z(z; y) = \mathcal{N}(z \mid 0, I)2; pz(z;y)=N(z0,I)p_z(z; y) = \mathcal{N}(z \mid 0, I)3 yields optimal pz(z;y)=N(z0,I)p_z(z; y) = \mathcal{N}(z \mid 0, I)4; pz(z;y)=N(z0,I)p_z(z; y) = \mathcal{N}(z \mid 0, I)5 or pz(z;y)=N(z0,I)p_z(z; y) = \mathcal{N}(z \mid 0, I)6 leads to overfitting.
  • Data obfuscation/fairness: Classifier on pz(z;y)=N(z0,I)p_z(z; y) = \mathcal{N}(z \mid 0, I)7 overfits and generalizes poorly; classifier on pz(z;y)=N(z0,I)p_z(z; y) = \mathcal{N}(z \mid 0, I)8 attains near pz(z;y)=N(z0,I)p_z(z; y) = \mathcal{N}(z \mid 0, I)9 test accuracy, indicating that logp0(x,y)=logp0(y)+logN(z0,I)+logdetJf0(x;y)\log p_0(x, y) = \log p_0(y) + \log \mathcal{N}(z \mid 0, I) + \log |\det J_{f_0}(x; y)|0 removes class information from logp0(x,y)=logp0(y)+logN(z0,I)+logdetJf0(x;y)\log p_0(x, y) = \log p_0(y) + \log \mathcal{N}(z \mid 0, I) + \log |\det J_{f_0}(x; y)|1. t-SNE confirms class separation in logp0(x,y)=logp0(y)+logN(z0,I)+logdetJf0(x;y)\log p_0(x, y) = \log p_0(y) + \log \mathcal{N}(z \mid 0, I) + \log |\det J_{f_0}(x; y)|2 and mixing in logp0(x,y)=logp0(y)+logN(z0,I)+logdetJf0(x;y)\log p_0(x, y) = \log p_0(y) + \log \mathcal{N}(z \mid 0, I) + \log |\det J_{f_0}(x; y)|3.

Collectively, these results show that the two-stage semi-conditional flow architecture supports exact joint/marginal likelihood training, efficient inference in semi-supervised settings, and improved classification performance over VAE-based baselines on MNIST (Atanov et al., 2019).

Definition Search Book Streamline Icon: https://streamlinehq.com
References (1)

Topic to Video (Beta)

No one has generated a video about this topic yet.

Whiteboard

No one has generated a whiteboard explanation for this topic yet.

Follow Topic

Get notified by email when new papers are published related to Semi-Conditional Normalizing Flow (SCNF).