CNO

Model Introduction

CNO (Convolutional Neural Operator) is a neural operator model for learning partial differential equation (PDE) operators, proposed by Bogdan Raonić et al. and published at NeurIPS 2023. CNO combines convolutional neural networks with operator learning in continuous function spaces. Its anti-aliased activations and filtered upsampling and downsampling operations reduce errors caused by discretization and changes in resolution. The model can directly predict PDE solutions from initial conditions, source terms, or parameter fields. Using the OneScience skill workflow, this project independently reproduces the CNO experiment that predicts the horizontal velocity component of the two-dimensional incompressible Navier–Stokes equations from (t=0) to (T=1).

Paper: Convolutional Neural Operators for Robust and Accurate Learning of PDEs

Model Description

CNO uses a U-Net-like multiscale encoder-decoder architecture that combines local convolutions, skip connections, and filtered upsampling and downsampling to learn function-to-function mappings for PDEs. Its key feature is an anti-aliasing mechanism in nonlinear activations and scale transformations. This reduces errors caused by discretization and resolution changes, better preserves the properties of continuous operators, and improves both operator-learning accuracy and cross-resolution robustness.

Use Cases

Use case Description
PDE solution-operator learning Learns mappings from initial conditions, source terms, or parameter fields to PDE solutions.
Fluid-dynamics prediction Provides fast surrogate predictions for problems such as Navier–Stokes and compressible Euler equations.
Multiscale physical-field modeling Handles complex PDE solutions containing both low- and high-frequency spatial structures.
Cross-resolution prediction Supports inference at different spatial discretization resolutions to evaluate resolution generalization.
ID/OOD generalization Evaluates model robustness under in-distribution and out-of-distribution PDE parameters or physical conditions.

Usage

1. Using OneCode

Try intelligent, one-click AI4S programming in the OneCode online environment:

Try intelligent, one-click AI4S programming

2. Manual Installation and Usage

Hardware requirements

  • A GPU or DCU is recommended.
  • A CPU can be used for import checks and small-scale connectivity tests, but full training and inference will be slow.
  • DCU users must install DTK in advance. DTK 25.04.2 or later, or the OneScience-recommended version for the current cluster, is recommended.

Download the Model Package

modelscope download --model OneScience/CNO --local_dir ./CNO
cd CNO

Set Up the Runtime Environment

DCU environment

# Activate DTK and Conda first
conda create -n onescience311 python=3.11 -y
conda activate onescience311
# Installation with uv is also supported
pip install onescience[cfd-dcu] -i http://mirrors.onescience.ai:3141/pypi/simple/  --trusted-host mirrors.onescience.ai

GPU environment

# Activate Conda first
conda create -n onescience311 python=3.11 -y libstdcxx-ng=12 libgcc-ng=12 gcc_linux-64=12 gxx_linux-64=12
conda activate onescience311
# Installation with uv is also supported
pip install onescience[cfd-gpu] -i http://mirrors.onescience.ai:3141/pypi/simple/  --trusted-host mirrors.onescience.ai

Training Data

The experiment uses two-dimensional incompressible Navier–Stokes data from the RPB_CNO dataset. The training file is NavierStokes_64x64_IN.h5. Each sample contains:

  • input: the horizontal velocity component at (t=0), with shape (64, 64);
  • output: the horizontal velocity component at (T=1), with shape (64, 64).

A channel dimension is added after loading, so both inputs and labels in each training batch have shape (batch_size, 1, 64, 64).

The current configuration uses 750 training samples, 128 validation samples, and 128 in-distribution test samples. The out-of-distribution test set contains 128 samples from NavierStokes_128x128_OUT.h5.

Download the data with:

modelscope download --dataset OneScience/RPB_CNO --local_dir ./data

After downloading, set paths.data_dir in config/config.yaml to the directory containing the HDF5 files.

Training

The default configuration corresponds to the two-dimensional incompressible Navier–Stokes experiment in the paper, with spectral viscosity approximately (\nu=4\times10^{-4}). The model learns the mapping from the initial horizontal velocity component at (t=0) to the velocity component at (T=1).

python scripts/train.py --config config/config.yaml --device auto

The complete training state with the lowest median relative L1 error in physical space on the validation set is saved to weight/best_model.pth. It includes the model, optimizer, learning-rate scheduler, and normalization parameters.

Trained Weights

weight/best_model.pth contains the best weights from the full training run and can be used directly for inference.

Inference

Before running inference, make sure the configured data path is valid and weight/best_model.pth exists. The model performs a single-step prediction from the initial horizontal velocity component at (t=0) to the velocity component at (T=1). It does not perform closed-loop multistep or trajectory rollout prediction. The default inference batch size is 16.

python scripts/inference.py --config config/config.yaml

Evaluation and Visualization

After training and inference, run:

python scripts/result.py --config config/config.yaml --sample-index 0

Official OneScience Resources

Citation and License


中文说明

模型简介

CNO(卷积神经算子,Convolutional Neural Operator)是用于学习偏微分方程(PDE)算子的神经算子模型,由 Bogdan Raonić 等人提出并发表于 NeurIPS 2023。CNO 将卷积神经网络与连续函数空间的算子学习相结合。抗混叠激活及带滤波的上采样和下采样操作可减少离散化及分辨率变化引起的误差。模型可根据初始条件、源项或参数场直接预测 PDE 的解。本项目通过 OneScience 技能工作流独立复现了 CNO 实验,预测二维不可压缩 Navier–Stokes 方程从 (t=0) 到 (T=1) 的水平速度分量。

论文:用于稳健且精确地学习 PDE 的卷积神经算子

模型描述

CNO 使用类 U-Net 的多尺度编码器-解码器架构,结合局部卷积、跳跃连接和带滤波的上采样与下采样,学习 PDE 的函数到函数映射。其核心特征是非线性激活和尺度变换中的抗混叠机制。该机制减少了离散化及分辨率变化引起的误差,更好地保留连续算子的性质,从而提高算子学习精度和跨分辨率稳健性。

使用场景

使用场景 说明
PDE 求解算子学习 学习从初始条件、源项或参数场到 PDE 解的映射。
流体动力学预测 为 Navier–Stokes 和可压缩 Euler 方程等问题提供快速代理预测。
多尺度物理场建模 处理兼有低频和高频空间结构的复杂 PDE 解。
跨分辨率预测 支持不同空间离散分辨率下的推理(inference),用于评估分辨率泛化能力。
ID/OOD 泛化 评估模型在分布内和分布外 PDE 参数或物理条件下的稳健性。

使用指南

1. 使用 OneCode

通过 OneCode 在线环境体验智能一键 AI4S 编程。

体验智能一键 AI4S 编程

2. 手动安装与使用

硬件要求

  • 建议使用 GPU 或 DCU。
  • CPU 可用于导入检查和小规模连通性测试,完整训练和推理速度较慢。
  • DCU 用户须提前安装 DTK。建议使用 DTK 25.04.2 或更高版本,或使用 OneScience 推荐的适配当前集群的版本。

下载模型包

modelscope download --model OneScience/CNO --local_dir ./CNO
cd CNO

配置运行环境

DCU 环境

# Activate DTK and Conda first
conda create -n onescience311 python=3.11 -y
conda activate onescience311
# Installation with uv is also supported
pip install onescience[cfd-dcu] -i http://mirrors.onescience.ai:3141/pypi/simple/  --trusted-host mirrors.onescience.ai

GPU 环境

# Activate Conda first
conda create -n onescience311 python=3.11 -y libstdcxx-ng=12 libgcc-ng=12 gcc_linux-64=12 gxx_linux-64=12
conda activate onescience311
# Installation with uv is also supported
pip install onescience[cfd-gpu] -i http://mirrors.onescience.ai:3141/pypi/simple/  --trusted-host mirrors.onescience.ai

训练数据

实验使用 RPB_CNO 数据集中的二维不可压缩 Navier–Stokes 数据。训练文件为 NavierStokes_64x64_IN.h5。每个样本包含以下内容。

  • input 为 (t=0) 时的水平速度分量,形状为 (64, 64)
  • output 为 (T=1) 时的水平速度分量,形状为 (64, 64)。

加载后添加通道维度,因此每个训练批次的输入和标签的形状均为 (batch_size, 1, 64, 64)。

当前配置使用 750 个训练样本、128 个验证样本和 128 个分布内测试样本。分布外测试集包含来自 NavierStokes_128x128_OUT.h5 的 128 个样本。

使用以下命令下载数据。

modelscope download --dataset OneScience/RPB_CNO --local_dir ./data

下载后,将 config/config.yaml 中的 paths.data_dir 设为包含 HDF5 文件的目录。

训练

默认配置对应论文中的二维不可压缩 Navier–Stokes 实验,谱黏性约为 (\nu=4\times10^{-4})。模型学习从 (t=0) 的初始水平速度分量到 (T=1) 的速度分量的映射。

python scripts/train.py --config config/config.yaml --device auto

验证集上物理空间相对 L1 误差中位数最低时的完整训练状态保存到 weight/best_model.pth,其中包括模型、优化器、学习率调度器和归一化参数。

训练权重

weight/best_model.pth 包含完整训练得到的最佳权重,可直接用于推理。

推理

运行推理前,请确保数据路径配置有效且 weight/best_model.pth 存在。模型从 (t=0) 的初始水平速度分量单步预测 (T=1) 的速度分量。模型不执行闭环多步预测或轨迹滚动预测。默认推理批大小为 16。

python scripts/inference.py --config config/config.yaml

评估与可视化

训练和推理完成后,运行以下命令。

python scripts/result.py --config config/config.yaml --sample-index 0

OneScience 官方资源

引用与许可证

Downloads last month
31
Inference Providers NEW
This model isn't deployed by any Inference Provider. 🙋 Ask for provider support

Paper for OneScience-Group/CNO