Neural Importance Sampling
Project description
ZüNIS: Normalizing flows for neural importance sampling
ZüNIS (Zürich Neural Importance Sampling) a work-in-progress Pytorch-based library for Monte-Carlo integration based on Neural imporance sampling [1], developed at ETH Zürich. In simple terms, we use artificial intelligence to compute integrals faster.
The goal is to provide a flexible library to integrate black-box functions with a level of automation comparable to the VEGAS Library [2], while using state-of-the-art methods that go around the limitations of existing tools.
Installation
Using pip
The library is available on PyPI:
pip install zunis
The latest version can be installed directly from GitHub:
pip install 'git+https://github.com/ndeutschmann/zunis#egg=zunis&subdirectory=zunis_lib'
Setting up a development environment
If you would like to contribute to the library, run the benchmarks or try the examples, the easiest is to clone this repository directly and install the extended requirements:
# Clone the repository
git clone https://github.com/ndeutschmann/zunis.git ./zunis
# Create a virtual environment (recommended)
python3.7 -m venv zunis_venv
source ./zunis_venv/bin/activate
pip install --upgrade pip
# Install the requirements
cd ./zunis
pip install -r requirements.txt
# Run one benchmark (GPU recommended)
cd ./experiments/benchmarks
python benchmark_hypersphere.py
Library usage
For basic applications, the integrator is provided with default choices and can be created and used as follows:
import torch
from zunis.integration import Integrator
device = torch.device("cuda")
d = 2
def f(x):
return x[:,0]**2 + x[:,1]**2
integrator = Integrator(d=d,f=f,device=device)
result, uncertainty, history = integrator.integrate()
The function f
is integrated over the d
-dimensional unit hypercube and
- takes
torch.Tensor
batched inputs with shape(N,d)
for arbitrary batch sizeN
ondevice
- returns
torch.Tensor
batched inputs with shape(N,)
for arbitrary batch sizeN
ondevice
A more systematic documentation is under construction here.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file zunis-0.3.tar.gz
.
File metadata
- Download URL: zunis-0.3.tar.gz
- Upload date:
- Size: 41.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.2 importlib_metadata/4.6.4 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.2 CPython/3.8.9
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | a270954ee9752250317c54aa975be1a5d6a7b94317192a11a32feac670d5c96c |
|
MD5 | 9ebed6e09953502a92bf421a4a4148a5 |
|
BLAKE2b-256 | cacf3f305c7c06968285ae87a4c14dc9974b1c424db52f5eaec66fe74b046bed |
File details
Details for the file zunis-0.3-py3-none-any.whl
.
File metadata
- Download URL: zunis-0.3-py3-none-any.whl
- Upload date:
- Size: 59.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.2 importlib_metadata/4.6.4 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.2 CPython/3.8.9
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 34c0fb9a0d8a198e687ecac98301116e93b7e3229bf9328066e86b7dfcf38519 |
|
MD5 | a3861fae7081265c011890fcb41f62a5 |
|
BLAKE2b-256 | b8d97f9813b9b0a767cfc5ff0bf948ae2783e89f2f62569c99140b74bd13ed24 |