This repository provides a clean, well-documented, and mathematically faithful implementation of the paper "Latent Space Oddity: on the Curvature of Deep Generative Models" (Arvanitidis et al., ICLR 2018).
The work explores the Riemannian geometry induced by stochastic generators (VAEs) and proposes an expected metric that captures data distortion and uncertainty, enabling the computation of meaningful shortest paths (geodesics) in the latent space.
A stochastic generator
Standard VAE variance functions extrapolate poorly in regions without data. This repository implements the RBF-based precision model:
where
| Paper Concept | Code Implementation | Description |
|---|---|---|
| Stochastic Generator | generative_models.VAE_model |
Implements the mean and variance decoders. |
| Expected Metric | manifolds.MlpMeanInvRbfVar.metric_tensor |
Computes |
| RBF Variance |
reproduce_paper.py (Training) |
Fits RBF network to empirical VAE variance. |
| Geodesic ODE | geodesics.geodesic_system |
Implements the 2nd order ODE for shortest paths. |
| Solvers |
geodesics.solver_bvp, solver_graph
|
Boundary Value Problem and Graph-based initialization. |
- Python 3.8+
- PyTorch
- Scipy, NumPy, Matplotlib, Scikit-Learn
pip install torch numpy scipy matplotlib scikit-learnTo train a VAE on synthetic data, fit the RBF variance model, and visualize latent space geodesics:
python reproduce_paper.pyThis script generates:
- ELBO Convergence Plot: Training progress of the VAE.
-
Metric Measure Visualization: Heatmap of
$\sqrt{\det(\mathbf{M}_{\mathbf{z}})}$ . - Geodesic Plots: Shortest paths connecting points in the latent space.
Original reference implementation: georgiosarvanitidis/geometric_ml
@inproceedings{arvanitidis2018latent,
title={Latent Space Oddity: on the Curvature of Deep Generative Models},
author={Arvanitidis, Georgios and Hansen, Lars Kai and Hauberg, S{\o}ren},
booktitle={International Conference on Learning Representations (ICLR)},
year={2018}
}Maintained by prikarsartam.

