Skip to main content

Learning (Tensorized) Neural Operators in PyTorch.

Project description

PyPI https://github.com/NeuralOperator/neuraloperator/actions/workflows/test.yml/badge.svg

Neural Operator

neuraloperator is a comprehensive library for learning neural operators in PyTorch. It is the official implementation for Fourier Neural Operators and Tensorized Neural Operators.

Unlike regular neural networks, neural operators enable learning mapping between function spaces, and this library provides all of the tools to do so on your own data.

NeuralOperators are also resolution invariant, so your trained operator can be applied on data of any resolution.

Installation

Just clone the repository and install locally (in editable mode so changes in the code are immediately reflected without having to reinstall):

git clone https://github.com/NeuralOperator/neuraloperator
cd neuraloperator
pip install -e .
pip install -r requirements.txt

You can also just pip install the library:

pip install neuraloperator

Quickstart

After you’ve installed the library, you can start training operators seemlessly:

from neuralop.models import FNO

operator = FNO(n_modes=(16, 16), hidden_channels=64,
                in_channels=3, out_channels=1)

Tensorization is also provided out of the box: you can improve the previous models by simply using a Tucker Tensorized FNO with just a few parameters:

from neuralop.models import TFNO

operator = TFNO(n_modes=(16, 16), hidden_channels=64,
                in_channels=3,
                out_channels=1,
                factorization='tucker',
                implementation='factorized',
                rank=0.05)

This will use a Tucker factorization of the weights. The forward pass will be efficient by contracting directly the inputs with the factors of the decomposition. The Fourier layers will have 5% of the parameters of an equivalent, dense Fourier Neural Operator!

Checkout the documentation for more!

Using with weights and biases

Create a file in neuraloperator/config called wandb_api_key.txt and paste your Weights and Biases API key there. You can configure the project you want to use and your username in the main yaml configuration files.

Contributing code

All contributions are welcome! So if you spot a bug or even a typo or mistake in the documentation, please report it, and even better, open a Pull-Request on GitHub. Before you submit your changes, you should make sure your code adheres to our style-guide. The easiest way to do this is with black:

pip install black
black .

Running the tests

Testing and documentation are an essential part of this package and all functions come with uni-tests and documentation. The tests are ran using the pytest package. First install pytest:

pip install pytest

Then to run the test, simply run, in the terminal:

pytest -v neuralop

Citing

If you use NeuralOperator in an academic paper, please cite [1], [2]:

@misc{li2020fourier,
   title={Fourier Neural Operator for Parametric Partial Differential Equations},
   author={Zongyi Li and Nikola Kovachki and Kamyar Azizzadenesheli and Burigede Liu and Kaushik Bhattacharya and Andrew Stuart and Anima Anandkumar},
   year={2020},
   eprint={2010.08895},
   archivePrefix={arXiv},
   primaryClass={cs.LG}
}

@article{kovachki2021neural,
   author    = {Nikola B. Kovachki and
                  Zongyi Li and
                  Burigede Liu and
                  Kamyar Azizzadenesheli and
                  Kaushik Bhattacharya and
                  Andrew M. Stuart and
                  Anima Anandkumar},
   title     = {Neural Operator: Learning Maps Between Function Spaces},
   journal   = {CoRR},
   volume    = {abs/2108.08481},
   year      = {2021},
}

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

neuraloperator-0.3.0.tar.gz (3.9 MB view details)

Uploaded Source

Built Distribution

neuraloperator-0.3.0-py3-none-any.whl (4.0 MB view details)

Uploaded Python 3

File details

Details for the file neuraloperator-0.3.0.tar.gz.

File metadata

  • Download URL: neuraloperator-0.3.0.tar.gz
  • Upload date:
  • Size: 3.9 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.7

File hashes

Hashes for neuraloperator-0.3.0.tar.gz
Algorithm Hash digest
SHA256 65d6da996a15b0b45a591f971f53770e6b39ad83db883e7bb1491cf1e996354a
MD5 30f68adb7adc9bb9390367cbca63106e
BLAKE2b-256 85819259b8f48e792e3b2ab4b352f6f80b3790bd9e12c058e96f3ad73ab5db51

See more details on using hashes here.

File details

Details for the file neuraloperator-0.3.0-py3-none-any.whl.

File metadata

File hashes

Hashes for neuraloperator-0.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 483b358f2d9823c2ccb5dd0c1af8d21f879fd103806ad42959ebb975260e6ec4
MD5 9aa0fc199993dca1c214792216f89a1e
BLAKE2b-256 4ff7348ab3c87fc72eab58fdb765fa411042a25be246599ad09731be11f42317

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page