This is a tutorial on Planar Flows and their generalization to Sylvester Flows for AI Sweden's ctrl-allt-dela learning series.
Author: Bobby robert.bridges@ai.se
A few slides are here: https://docs.google.com/presentation/d/11r8P696WUBZubXXUJ8eGihV5Ji42xbBt/edit?usp=sharing&ouid=103663031827858753966&rtpof=true&sd=true
├── README.md ## this file! ├── Ctrl-Allt-Dela-NF-talk-notes.pdf # remarkable tablet notes ├── learn_sylvester_flows.ipynb # this notebook implements a sylvester flow for sampling from an improper density. do it after the planar flows ├── maf_nf.ipynb # this notebook implements a masked autoregressive flow for synthesizing data ├── normalizing_flows.py # these are PyTorch classes of flows that are imported by the planer and sylvester flows notebooks ├── planar_nf.ipynb # this notebook implements a planar flow for sampling from an improper density ├── plotting_utils.py # thes are functions imported by the notebooks to plot stuff └── talk_info.md # talk abstract and references
We used pyenv for managing different versions of python and venv for our python virtual envrionment.
Quick background and useful commands appear at the bottom of this readme.
The setup follows reference: https://www.freecodecamp.org/news/manage-multiple-python-versions-and-virtual-environments-venv-pyenv-pyvenv-a29fb00c296f/
Steps:
-
Install python 3.12.0 via pyenv using
pyenv install 3.12.0) -
Set pyenv envrionment to python 3.12.0 using
pyenv local 3.12.0 -
Initialize virtual envrionment in the .venv folder
python3 -m venv .venv. Now, in the new folder.venv/binshould be a copy of python 3.12.0Note that the
.venvfolder is gitignored and should not ship with the repo. -
Start virtual envrionment:
source .venv/bin/activateAt this point running
which pipandwhich pythonshould produce a path to thepipandpythoninstances in.venv/bin/.Running
python --versionshould produce 3.12.0.VS Code and Jupyter users may need to point their environment to the right Python interpreter. (
.vinv/bin/python) -
We shipped our
pip freezeoutput as therequirements_*.txtfiles file, so one can (try to) install all packages withpip install -r requirements.txt. If that is problematic, one can trycat requirements.txt | xargs -n 1 pip installfollowing https://stackoverflow.com/questions/22250483/stop-pip-from-failing-on-single-package-when-installing-with-requirements-txt (For some reason to install scikit requires:python3 -m pip install scikit-learn)