|
|
A deep learning framework for amortized trans-dimensional inference using slot-based conditional normalizing flows. |
We propose SlotFlow, an amortized inference framework for decomposing signals into sinusoidal components when the number of sources is unknown. The model jointly infers both the cardinality
- Dual-Stream Encoding: Parallel frequency- and time-domain encoders extract complementary spectral and temporal features.
-
Dynamic Slot Allocation: Instantiates exactly
$\hat{K}$ slots based on cardinality prediction, avoiding wasted capacity. - Permutation-Invariant Training: Hungarian-matched conditional normalizing flows enable robust posterior estimation.
The architecture processes time-series observations, predicts a distribution over component counts
We assume the observed signal
where
Infer the posterior over
Likelihood: Assuming additive Gaussian noise,
We learn a classifier
with
where shared global context
Total Loss:
Classification Loss:
Flow Loss with Hungarian Matching: Let
Noise Supervision Loss: Parallel encoder predicts log noise level
Posterior samples enable per-slot signal reconstruction:
where $(\hat{a}_k, \hat{\phi}_k, \hat{f}k) \sim q\phi(\theta_k | c_k)$.
The architecture operates in four stages:
- Dual-Stream Encoding: Frequency pathway processes FFT representations, time pathway processes raw signals, both refined via positional encoding and multi-head attention
-
Cardinality Estimation: Frequency features undergo global self-attention and pooling to produce
$q_\phi(K | x)$ -
Slot Context Generation: Global context
$g$ (fused frequency-time embeddings) is concatenated with one-hot slot identifiers:$c_k = [g, s_k]$ -
Conditional Flow Inference: Shared 8-layer rational-quadratic spline flow produces per-slot posteriors
$q_\phi(\theta_k | x, k)$
- Cardinality Accuracy: 99.85% on test set with K ∈ {1,...,10}
- Posterior Quality: Wasserstein distances W₂ < 0.01 (amplitude), < 0.03 (phase), 0.0006 (frequency) vs. RJMCMC
- Calibration: < 3% absolute bias across all parameters and cardinalities
- Speed: 13 ms inference time (1.5×10⁶× speedup over RJMCMC for the paper's example cases)
- Scalability: O(K) computational cost with embarrassingly parallel slot inference
SlotFlow/
├── README.md
├── media/
│ └── (example figures, etc.)
├── pretrained_model/
│ └── (model configuration and model weights)
├── slurm/
│ └── (job scripts & logs)
├── src/
│ ├── dataset.py
│ ├── loss.py
│ ├── model.py
│ ├── utils.py
│ └── wrapper.py
├── Eval.ipynb
├── Train-cluster.py
To use the codes in this repository, create an environment:
conda create -n slotflow python=3.12 matplotlib pytorch scipy jupyter
conda activate slotflow- Run Inference: To load a pretrained SlotFlow model and perform cardinality estimation or posterior sampling, simply open and execute Eval.ipynb. It demonstrates: loading the pretrained checkpoint predicting the number of components K sampling posteriors and reconstructing signals.
- Train a New Model: To train SlotFlow from scratch with custom settings, run Train-cluster.py. For large-scale training, we recommend launching it on an HPC cluster using the SLURM batch scripts provided in the slurm/ directory. Cluster-specific adjustments (paths, modules, partitions, GPUs) may be required.
Download the pretrained SlotFlow model from the release page:
https://github.com/nhouba/slotflow-inference/releases/latest
Or download directly:
wget https://github.com/nhouba/slotflow-inference/releases/download/v1.0.0/best_model.ckpt- Multi-scale encoders with fine/coarse-stride branches for improved frequency precision
- Time-frequency representations (wavelets, STFT) for non-stationary signals
- Graph neural networks for explicit inter-slot dependencies
- Application to gravitational-wave astronomy (LISA data) and neural spike sorting
[1] Locatello, F., Weissenborn, D., Unterthiner, T., Mahendran, A., Heigold, G., Uszkoreit, J., Kipf, T., & Dosovitskiy, A. (2020). Object-Centric Learning with Slot Attention. NeurIPS.
[2] Houba, N. (2025). Deep source separation of overlapping gravitational‑wave signals and nonstationary noise artifacts. Phys. Rev. Research. https://doi.org/10.1103/6bjw‑xjj2.
[3] Houba, N., Giarda, G., & Speri, L. (2025). SlotFlow: Amortized Trans-Dimensional Inference with Slot-Based Normalizing Flows. arXiv.
If you use SlotFlow in your research, please cite:
@misc{houba2025slotflowamortizedtransdimensionalinference,
title={SlotFlow: Amortized Trans-Dimensional Inference with Slot-Based Normalizing Flows},
author={Niklas Houba and Giovanni Giarda and Lorenzo Speri},
year={2025},
eprint={2511.23228},
archivePrefix={arXiv},
primaryClass={astro-ph.IM},
url={https://arxiv.org/abs/2511.23228},
}This project is licensed under the MIT License - see the LICENSE file for details.
For questions or issues, please contact:
- Niklas Houba: nhouba@phys.ethz.ch
This research was funded by the Gravitational Physics Professorship at ETH Zurich. Computational resources provided by the Euler Cluster at ETH Zurich and the Clariden supercomputer at CSCS through the Swiss AI Initiative (Grant SIGMA-GW).



