Code accompanying mariogemoll.com/normalizing-flows.
A normalizing flow trained on the two-moons dataset, with interactive browser visualizations that show the change-of-variables principle, the individual flow layers, training, and sample generation.
py/— PyTorch reference implementation and training notebook (normalizing-flows.ipynb).ts/— TypeScript / TensorFlow.js port that powers the interactive widgets on the page. Entry point:ts/src/page.ts, bundled tots/dist/page.jsvia esbuild. Trained weights live ints/model.json/ts/model.weights.bin.sh/checkpy.sh— lint the Python code with ruff and verify the notebook.
cd py
uv sync
uv run jupyter lab normalizing-flows.ipynbcd ts
npm install
npm run buildThen open ts/page.html in a browser (WebGPU-capable recommended).