Kernel: Python 3.7.13 ('py3713')
Mapping a 2d standard Gaussian to a more complex distribution using an invertible MLP
Author: George Papamakarios
Based on the example by Eric Jang from https://blog.evjang.com/2018/01/nf1.html
Reproduces Figure 23.1 of the book Probabilistic Machine Learning: Advanced Topics by Kevin P. Murphy
Imports and definitions
In [1]:
Out[1]:
|████████████████████████████████| 272 kB 3.9 MB/s
|████████████████████████████████| 72 kB 102 kB/s
|████████████████████████████████| 342 kB 5.1 MB/s
|████████████████████████████████| 145 kB 5.1 MB/s
Installing build dependencies ... done
Getting requirements to build wheel ... done
Preparing wheel metadata ... done
|████████████████████████████████| 88 kB 3.8 MB/s
|████████████████████████████████| 125 kB 33.8 MB/s
|████████████████████████████████| 1.1 MB 59.9 MB/s
Building wheel for probml-utils (PEP 517) ... done
Building wheel for TexSoup (setup.py) ... done
Building wheel for umap-learn (setup.py) ... done
Building wheel for pynndescent (setup.py) ... done
In [2]:
Out[2]:
/usr/local/lib/python3.7/dist-packages/probml_utils/plotting.py:26: UserWarning: LATEXIFY environment variable not set, not latexifying
warnings.warn("LATEXIFY environment variable not set, not latexifying")
Create flow model
In [3]:
Define target distribution
In [10]:
Out[10]:
Train model
In [36]:
Out[36]:
In [37]:
Out[37]:
Step 0, loss = 28.584
Step 100, loss = 13.013
Step 200, loss = 6.087
Step 300, loss = 2.099
Step 400, loss = 1.636
Step 500, loss = 1.369
Step 600, loss = 1.823
Step 700, loss = 1.543
Step 800, loss = 1.327
Step 900, loss = 1.921
Step 1000, loss = 1.274
Step 1100, loss = 1.437
Step 1200, loss = 1.702
Step 1300, loss = 1.678
Step 1400, loss = 1.831
Step 1500, loss = 1.465
Step 1600, loss = 1.283
Step 1700, loss = 1.316
Step 1800, loss = 1.678
Step 1900, loss = 1.444
Step 2000, loss = 1.705
Step 2100, loss = 1.312
Step 2200, loss = 1.673
Step 2300, loss = 1.388
Step 2400, loss = 1.701
Step 2500, loss = 1.717
Step 2600, loss = 1.833
Step 2700, loss = 1.529
Step 2800, loss = 1.597
Step 2900, loss = 1.337
Step 3000, loss = 1.518
Step 3100, loss = 1.405
Step 3200, loss = 1.842
Step 3300, loss = 1.613
Step 3400, loss = 1.166
Step 3500, loss = 1.956
Step 3600, loss = 1.648
Step 3700, loss = 1.374
Step 3800, loss = 1.324
Step 3900, loss = 1.473
Step 4000, loss = 1.735
Step 4100, loss = 1.461
Step 4200, loss = 1.541
Step 4300, loss = 1.917
Step 4400, loss = 1.502
Step 4500, loss = 1.863
Step 4600, loss = 1.415
Step 4700, loss = 1.399
Step 4800, loss = 1.930
Step 4900, loss = 1.485
CPU times: user 7min 1s, sys: 1min 33s, total: 8min 34s
Wall time: 6min 37s
In [38]:
Out[38]:
Create plot with intermediate distributions
In [39]:
In [40]:
Out[40]:
/usr/local/lib/python3.7/dist-packages/probml_utils/plotting.py:80: UserWarning: set FIG_DIR environment variable to save figures
warnings.warn("set FIG_DIR environment variable to save figures")