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) for input data x∈Rd and discrete labels y∈{1,…,K},
p0(x,y)=p0(y)p0(x∣y)
where p0(y)=1/K (uniform prior), and p0(x∣y) is defined by a normalizing flow with a latent Gaussian base. Introducing an invertible mapping f0(x;y,θ) yields, via change of variables,
logp0(x∣y)=logpz(z;y)+log∣det∂f0(x;y)/∂x∣
with pz(z;y)=N(z∣0,I). The joint log-density thus decomposes as
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:
Unconditional flowx∈Rd0: Maps input x∈Rd1 to a semantic latent x∈Rd2 and auxiliary latent x∈Rd3, with x∈Rd4.
Conditional flowx∈Rd5: Maps x∈Rd6 to x∈Rd7 and conditions explicitly on x∈Rd8.
Formally,
x∈Rd9
y∈{1,…,K}0
The Jacobian determinant for the composition factorizes as
y∈{1,…,K}1
This two-stage structure underpins efficient marginalization over classes, with y∈{1,…,K}2 computed once per input and y∈{1,…,K}3 applied y∈{1,…,K}4 times (once for each label class).
3. Conditional Affine Coupling Layers
The conditional flow y∈{1,…,K}5 and portions of the unconditional flow y∈{1,…,K}6 are constructed from conditional affine-coupling blocks. Each block partitions the input y∈{1,…,K}7 into y∈{1,…,K}8 and applies the transformation
y∈{1,…,K}9
where p0(x,y)=p0(y)p0(x∣y)0 and p0(x,y)=p0(y)p0(x∣y)1 are neural networks conditioned on p0(x,y)=p0(y)p0(x∣y)2 and the one-hot encoded label p0(x,y)=p0(y)p0(x∣y)3. The inverse transformation is
p0(x,y)=p0(y)p0(x∣y)4
The log-Jacobian determinant for a single block is p0(x,y)=p0(y)p0(x∣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(x∣y)6
Given that p0(x,y)=p0(y)p0(x∣y)7 does not depend on p0(x,y)=p0(y)p0(x∣y)8, the flow computation p0(x,y)=p0(y)p0(x∣y)9 is executed once. For each possible label p0(y)=1/K0, p0(y)=1/K1 is passed through p0(y)=1/K2 to obtain p0(y)=1/K3. The marginal log-likelihood thus becomes
p0(y)=1/K4
This log-sum-exp formulation allows for efficient exact computation of both value and gradients, with posterior responsibilities p0(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/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/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/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/K9, then transformed via p0(x∣y)0 with p0(x∣y)1.
Unconditional Flow p0(x∣y)2: Multi-scale Glow-style network with three levels of "squeezing", ActNorm, invertible p0(x∣y)3 convolutions, and affine-coupling layers. Each coupling layer uses 4-layer residual MLPs (hidden width 64) for p0(x∣y)4.
Conditional Flow p0(x∣y)5: Four channel-wise conditional coupling layers, also parameterized by residual MLPs processing the input and one-hot p0(x∣y)6. The dimension is reduced by factoring out features at two points, but best results used p0(x∣y)7.
Training: Adam optimizer, learning rate p0(x∣y)8, batch size p0(x∣y)9 (half labeled, half unlabeled), weight decayf0(x;y,θ)0. The model is trained for f0(x;y,θ)1K iterations per MNIST split.
A summary table of key architecture values from the MNIST setup follows:
Comprehensive empirical analysis demonstrates the effectiveness of SCNF in semi-supervised scenarios:
Toy 2D classification (moons, circles, logp0(x∣y)=logpz(z;y)+log∣det∂f0(x;y)/∂x∣0 labeled): SCNF-GLOW achieves logp0(x∣y)=logpz(z;y)+log∣det∂f0(x;y)/∂x∣1 test error and NLLlogp0(x∣y)=logpz(z;y)+log∣det∂f0(x;y)/∂x∣2, significantly outperforming SCNF-GMM (logp0(x∣y)=logpz(z;y)+log∣det∂f0(x;y)/∂x∣3 error) and unconditional flows.
MNIST (100 labels): Kingma et al.'s VAE achieves logp0(x∣y)=logpz(z;y)+log∣det∂f0(x;y)/∂x∣4 test error; SCNF-GMM yields logp0(x∣y)=logpz(z;y)+log∣det∂f0(x;y)/∂x∣5 (insufficient), whereas SCNF-GLOW attains logp0(x∣y)=logpz(z;y)+log∣det∂f0(x;y)/∂x∣6 error, bits/dim logp0(x∣y)=logpz(z;y)+log∣det∂f0(x;y)/∂x∣7. EM-SGD versus direct SGD yielded identical performance.
Ablation—latent dimension logp0(x∣y)=logpz(z;y)+log∣det∂f0(x;y)/∂x∣8:logp0(x∣y)=logpz(z;y)+log∣det∂f0(x;y)/∂x∣9 underfits with pz(z;y)=N(z∣0,I)0 test error; pz(z;y)=N(z∣0,I)1 achieves pz(z;y)=N(z∣0,I)2; pz(z;y)=N(z∣0,I)3 yields optimal pz(z;y)=N(z∣0,I)4; pz(z;y)=N(z∣0,I)5 or pz(z;y)=N(z∣0,I)6 leads to overfitting.
Data obfuscation/fairness: Classifier on pz(z;y)=N(z∣0,I)7 overfits and generalizes poorly; classifier on pz(z;y)=N(z∣0,I)8 attains near pz(z;y)=N(z∣0,I)9 test accuracy, indicating that logp0(x,y)=logp0(y)+logN(z∣0,I)+log∣detJf0(x;y)∣0 removes class information from logp0(x,y)=logp0(y)+logN(z∣0,I)+log∣detJf0(x;y)∣1. t-SNE confirms class separation in logp0(x,y)=logp0(y)+logN(z∣0,I)+log∣detJf0(x;y)∣2 and mixing in logp0(x,y)=logp0(y)+logN(z∣0,I)+log∣detJf0(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).
“Emergent Mind helps me see which AI papers have caught fire online.”
Philip
Creator, AI Explained on YouTube
Sign up for free to explore the frontiers of research
Discover trending papers, chat with arXiv, and track the latest research shaping the future of science and technology.Discover trending papers, chat with arXiv, and more.