Skip to content
/ stribor Public

Library for normalizing flows and neural flows.

License

Notifications You must be signed in to change notification settings

mbilos/stribor

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

28 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Normalizing flows

A normalizing flow library - invertible neural networks that define complicated high-dimensional densities as transformations of random variables.

Install package and dependencies

pip install -r requirements.txt
pip install -e .

Generate synthetic 2D data

python nf/gen/toy.py --N --seed

Default N=10000 and seed=123. Creates 10 datasets in data/.

Run tests

pytest

Usage

To define a normalizing flow, define a base distribution and a series of transformations, e.g.:

import nf
import torch
model = nf.Flow(nf.Normal(0, 1), [nf.Identity()])
>> model.forward(torch.Tensor([1])) # Returns y and log_jac_diag
(tensor([1.]), tensor([0.]))
>> model.sample(5) # Output will differ every time
tensor([0.1695, 1.9026, 0.4640, 0.7100, 0.2773])

Example runnable notebook can be found in notebooks/example_spline_coupling.ipynb.

About

Library for normalizing flows and neural flows.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages