slimgroup / InvertibleNetworks.jl

A Julia framework for invertible neural networks
MIT License
148 stars 20 forks source link
bayesian-inference deep-invertible-networks deep-learning invertible-1x1-convolutions invertible-neural-networks julia julia-language machine-learning normalizing-flow normalizing-flows

InvertibleNetworks.jl

Documentation Build Status
CI DOI

Building blocks for invertible neural networks in the Julia programming language.

Installation

InvertibleNetworks is registered and can be added like any standard Julia package with the command:

] add InvertibleNetworks

Uncertainty-aware image reconstruction

Due to its memory scaling InvertibleNetworks.jl, has been particularily successful at Bayesian posterior sampling with simulation-based inference. To get started with this application refer to a simple example (Conditional sampling for MNSIT inpainting) but feel free to modify this script for your application and please reach out to us for help.

mnist_sampling_cond

Building blocks

Examples

GPU support

GPU support is supported via Flux/CuArray. To use the GPU, move the input and the network layer to GPU via |> gpu

using InvertibleNetworks, Flux

# Input
nx = 64
ny = 64
k = 10
batchsize = 4

# Input image: nx x ny x k x batchsize
X = randn(Float32, nx, ny, k, batchsize) |> gpu

# Activation normalization
AN = ActNorm(k; logdet=true) |> gpu

# Test invertibility
Y_, logdet = AN.forward(X)

Reference

If you use InvertibleNetworks.jl in your research, we would be grateful if you cite us with the following bibtex:

@article{orozco2023invertiblenetworks,
  title={InvertibleNetworks. jl: A Julia package for scalable normalizing flows},
  author={Orozco, Rafael and Witte, Philipp and Louboutin, Mathias and Siahkoohi, Ali and Rizzuti, Gabrio and Peters, Bas and Herrmann, Felix J},
  journal={arXiv preprint arXiv:2312.13480},
  year={2023}
}

Papers

The following publications use InvertibleNetworks.jl:

Contributing

We welcome contributions and bug reports! Please see CONTRIBUTING.md for guidance.

InvertibleNetworks.jl development subscribes to the Julia Community Standards.

Authors

This package uses functions from NNlib.jl, Flux.jl and Wavelets.jl