Normalising flows using nflows
Project description
Glasflow
glasflow is a Python library containing a collection of Normalizing flows using PyTorch. It builds upon nflows.
Installation
glasflow is available to install via pip
:
pip install glasflow
or via conda
:
conda install glasflow -c conda-forge
PyTorch
Important: glasflow
supports using CUDA devices but it is not a requirement and in most uses cases it provides little to no benefit.
By default the version of PyTorch installed by pip
or conda
will not necessarily match the drivers on your system, to install a different version with the correct CUDA support see the PyTorch homepage for instructions: https://pytorch.org/.
Usage
To define a RealNVP flow:
from glasflow import RealNVP
# define RealNVP flow. Change hyperparameters as necessary.
flow = RealNVP(
n_inputs=2,
n_transforms=5,
n_neurons=32,
batch_norm_between_transforms=True
)
Please see glasflow/examples for a typical training regime example.
nflows
glasflow uses a fork of nflows which is included as submodule in glasflow and can used imported as follows:
import glasflow.nflows as nflows
It contains various bugfixes which, as of writing this, are not included in a current release of nflows
.
Using standard nflows
There is also the option to use an independent install of nflows (if installed) by setting an environment variable.
export GLASFLOW_USE_NFLOWS=True
After setting this variable glasflow.nflows
will point to the version of nflows installed in the current python environment.
Note: this must be set prior to importing glasflow.
Contributing
Pull requests are welcome. You can review the contribution guidelines here. For major changes, please open an issue first to discuss what you would like to change.
Citing
If you use glasflow in your work please cite our DOI. We also recommend you also cite nflows following the guidelines in the nflows readme.
Project details
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 glasflow-0.3.1.tar.gz
.
File metadata
- Download URL: glasflow-0.3.1.tar.gz
- Upload date:
- Size: 62.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.9.19
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | d8727e64fd8d517598b27844807a9c8d3b3b3770bd0e3656e7efcbc85927ab80 |
|
MD5 | 7da99e8cd85da6f6dfbeeeb7bbd2e697 |
|
BLAKE2b-256 | 330c5bcb636167a9bc4975005a1d420629f16a9ea7b18ddbf7c7a01dd620171d |
File details
Details for the file glasflow-0.3.1-py3-none-any.whl
.
File metadata
- Download URL: glasflow-0.3.1-py3-none-any.whl
- Upload date:
- Size: 74.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.9.19
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1c6aadea28df74603d9507546d7ec1216e84b677224a2613f43515948c19b32f |
|
MD5 | fb15a0fc335c0d289a6116d9604d7a99 |
|
BLAKE2b-256 | a2235fb5e6b21070dd896cb307d9cc9f258ab10c41c7efe065207900e0e24ea9 |