Abstract
Achieving disentangled representations—where individual latent dimensions correspond to specific, independent physical attributes—is a fundamental challenge in generative modeling. While unsupervised methods often lack stability and fully supervised methods require prohibitive labeling, this paper introduces SW-VAE (Swap Variational Autoencoder). By utilizing weak supervision in the form of image pairs with shared attributes, SW-VAE employs a novel latent factor swapping mechanism and consistency loss to isolate generative factors. Experimental results across benchmarks like dSprites and MPI3D demonstrate that SW-VAE significantly outperforms unsupervised baselines and matches or exceeds existing weakly supervised techniques.
Introduction
In representation learning, a "disentangled" code is one where a single latent unit is sensitive to changes in a single generative factor (e.g., object color) while being relatively invariant to changes in others (e.g., rotation). Such representations are highly desirable for downstream tasks, including controllable image synthesis, robotic manipulation, and interpretable decision-making.
Historically, the field has been divided between unsupervised approaches like $\beta$-VAE, which rely on information-theoretic bottlenecks, and fully supervised models. Unsupervised methods often suffer from identifiability issues, as there is no inherent signal to force the model toward human-intuitive factors. Conversely, full supervision is rarely scalable. SW-VAE targets the middle ground of weak supervision, assuming access to pairs of observations where only a subset of factors differ, a scenario common in video sequences or controlled experimental setups.
Methodology
The Swap-VAE Framework
The core innovation of SW-VAE is the use of latent factor swapping to enforce disentanglement. Given a pair of images $(x^{(l)}, x^{(m)})$ that share some attributes but differ in others, the model proceeds through four primary stages:
- Pairwise Encoding: Both images are mapped to latent distributions in a VAE framework.
- Factor Detection via KL Divergence: The model identifies which latent dimensions correspond to "changing" factors and which correspond to "shared" factors by calculating the Kullback-Leibler (KL) divergence between the latent distributions of the pair. Dimensions with high divergence are flagged as changing; those with low divergence are considered shared.
- The Swapping Mechanism: The model constructs "swapped" latent codes. Specifically, it retains the unique (changing) dimensions for each image but swaps the shared dimensions between the two codes.
- Consistency Loss: If the latent space is truly disentangled, swapping the shared factors should not alter the identity of the reconstructed images. The model is trained to minimize the reconstruction error between the original images and the images generated from these swapped codes.
Model Variants and Training
The authors propose two implementations: SW-VAE$_{SIM}$, which utilizes standard pixel-wise reconstruction losses (MSE or BCE), and SW-VAE$_{GAN}$, which incorporates an adversarial discriminator to improve the visual fidelity of the swapped reconstructions.
To stabilize training, the paper introduces two curriculum learning strategies:
- Increasing Swapped Factors (ISF): The model begins by swapping only a single factor and gradually increases the number of swapped dimensions as training progresses.
- Increasing Generative Factors (IGF): The complexity of the input pairs is increased over time, starting with pairs that differ by only one physical attribute and moving toward more complex variations.
Experimental Results
Quantitative Performance
SW-VAE was evaluated on standard disentanglement benchmarks, including dSprites, 3dshapes, and MPI3D. On the dSprites dataset, SW-VAE achieved a Mutual Information Gap (MIG) of 0.4637, a substantial improvement over the unsupervised $\beta$-VAE (0.1115) and the semi-supervised DSD (0.3937). These metrics indicate that the latent dimensions in SW-VAE are significantly more aligned with the true generative factors of the data.
Robustness and Qualitative Analysis
A key strength of SW-VAE is its performance on the MPI3D-Real dataset. While many models struggle to transfer from synthetic renders to real-world robotic footage, SW-VAE maintained high disentanglement scores. Qualitative latent traversals—where one latent dimension is varied while others are held constant—reveal that SW-VAE successfully isolates attributes like horizontal position, scale, and orientation without the "leakage" (where changing one attribute accidentally affects another) common in less robust models.
Discussion and Conclusion
SW-VAE demonstrates that weak supervision, specifically through the lens of latent factor swapping, provides a powerful inductive bias for disentanglement. By using KL divergence as a diagnostic tool to identify changing factors, the model avoids the need for explicit attribute labels.
While the model requires paired data with a known maximum number of changing factors, it represents a significant step toward practical, scalable disentangled representation learning. Future research may explore applying this swapping logic to more complex architectures, such as Diffusion Models, to achieve high-resolution controllable synthesis in unconstrained environments.
Summary updated