Skip to main content
nops logo

Neural Operators made simple.

PyPI version Python License: MIT Code Style: Black

graph LR
    subgraph nops_FNO [nops: FNO Architecture]
        direction LR
        Input["Input<br/>(Batch, C_in, X, Y...)"] --> Grid{Append<br/>Grid?}
        Grid -- Yes --> InputGrid[Input + Grid]
        Grid -- No --> InputGrid
        
        InputGrid --> Lifting["Lifting Layer<br/>(Projection P)"]
        
        subgraph FourierLayers [Fourier Layers x N]
            direction TB
            FFT[FFT] --> SpecConv["Spectral Conv<br/>(R * Weights)"]
            SpecConv --> iFFT["Inverse FFT"]
            iFFT --> Skip{"Skip<br/>Connection"}
            
            Skip --> Attention{"Attention<br/>Gating?"}
            Attention -- Yes --> AttnBlock["Attention Weights"]
            Attention -- No --> SumBlock["Sum"]
            
            AttnBlock --> OutputLayer
            SumBlock --> OutputLayer
        end
        
        Lifting --> FourierLayers
        FourierLayers --> Projection["Projection Layer<br/>(Q)"]
        Projection --> Output["Output<br/>(Batch, C_out, X, Y...)"]
    end

A human-centric interface for operating with Neural Operators (FNO, GNO, DeepONet, etc.).


nops is designed to be an elegant, high-level layer over complex neural operator architectures. Whether you are a researcher prototyping a new PDE solver or an engineer deploying a model to production, nops abstracts the complexity while retaining the flexibility you need.

✨ Features

  • Human-Friendly API: Intuitive classes and methods that make sense.
  • Multi-Dimensional: Seamless support for 1D, 2D, and 3D FNO models.
  • Production Ready: Built with modularity, type hinting, and efficiency in mind.
  • Batteries Included:
  • Attention Gating: Advanced mechanisms to weight parallel Fourier branches.
  • Flexible Gridding: Automatic handling of grid coordinates.
  • Padding Management: Easy handling of boundary conditions.

📦 Installation

Install nops easily via pip:

pip install nops

Note: Requires Python 3.12+

🚀 Quick Start

Solving a PDE with a Fourier Neural Operator (FNO) has never been this simple.

import torch
import torch.nn as nn
from nops.fno.models.original import FNO

# 1. Define your configuration
model = FNO(
    modes=[16, 16],               # 16 Fourier modes for height and width
    num_fourier_layers=4,         # Depth of the network
    in_channels=3,                # (e.g., u, v, p)
    out_channels=1,               # (e.g., pressure field)
    lifting_channels=64,
    projection_channels=64,
    mid_channels=64,
    activation=nn.GELU(),
    add_grid=True,                # Auto-append x,y coordinates
    attn_gating=True              # Enable attention mechanism
)

# 2. Forward pass
# Batch size: 8, Channels: 3, Resolution: 128x128
input_data = torch.randn(8, 3, 128, 128)
output = model(input_data)

print(f"Output Field Shape: {output.shape}")
# > Output Field Shape: torch.Size([8, 1, 128, 128])

🗺️ Roadmap

  • FNO (Fourier Neural Operator): Original implementation with attention extensions.
  • DeepONet: Implementation of Deep Operator Networks.
  • GNO (Graph Neural Operator): Support for irregular meshes.
  • Physics-Informed Losses: Built-in loss functions for PDE constraints.
  • Data Loaders: Standard datasets (Burgers, Navier-Stokes, Darcy Flow).

🤝 Contributing

We welcome contributions! nops is a community-driven project to make neural operators accessible to everyone.

  1. Fork the repository.
  2. Create a Feature Branch (git checkout -b feature/AmazingFeature).
  3. Commit your changes (git commit -m 'Add some AmazingFeature').
  4. Push to the branch (git push origin feature/AmazingFeature).
  5. Open a Pull Request.

Please ensure your code follows the existing style and includes tests.

📄 License

Distributed under the MIT License. See LICENSE for more information.


Built with ❤️ by the nops community.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

nops-0.3.0.tar.gz (505.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

nops-0.3.0-py3-none-any.whl (96.9 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: nops-0.3.0.tar.gz
  • Upload date:
  • Size: 505.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for nops-0.3.0.tar.gz
Algorithm Hash digest
SHA256 1cf6858fe205758fec7306ca1e346ad4633fc3d5fc11a02c895aac461534f6e9
MD5 bb5aea0bf693d802ddf98094b675a0e1
BLAKE2b-256 ce887b6751970cd3e4a19f01a1e5b07782fbdcce8b84949654156648702cf376

See more details on using hashes here.

Provenance

The following attestation bundles were made for nops-0.3.0.tar.gz:

Publisher: pypi.yml on abelsr/nops

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

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

File metadata

  • Download URL: nops-0.3.0-py3-none-any.whl
  • Upload date:
  • Size: 96.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for nops-0.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 eacf85b7de13177900734c982fbb3b2fde744a1fac42772d79fe95d27b151ce9
MD5 9fb79ead67ad86aec545ae166f8571a2
BLAKE2b-256 32f194a8a1a688cc8dbee99986b25c1b2b735c3a15824bb9e6ffcc058c121833

See more details on using hashes here.

Provenance

The following attestation bundles were made for nops-0.3.0-py3-none-any.whl:

Publisher: pypi.yml on abelsr/nops

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Release history Release notifications | RSS feed

This release

0.3.0 This release

2 files

0.2.0

2 files

0.1.1

2 files

0.1.0

1 file

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page