BPINNs

Model Overview

BPINNs (Bayesian Physics-Informed Neural Networks) incorporate physical-equation constraints into Bayesian neural networks to jointly estimate equation solutions and predictive uncertainty from noisy data. This model package provides an example for solving a one-dimensional Laplace equation:

u_xx + pi^2 sin(pi x) = 0,  x in [0, 1]
u(x) = sin(pi x)

Paper: B-PINNs: Bayesian physics-informed neural networks for forward and inverse PDE problems with noisy data
https://doi.org/10.1016/j.jcp.2020.109913

Model Description

BPINNs are trained jointly on observational data, boundary conditions, and PDE residuals. By default, the model is optimized with Adam and then refined with L-BFGS. During inference, predictive means and standard deviations can be computed from multiple parameter states stored in a checkpoint. The default training workflow produces only one optimized state; full Bayesian uncertainty quantification requires posterior parameter states obtained through Hamiltonian Monte Carlo (HMC), variational inference, or ensemble sampling.

Use Cases

Use Case Description
One-dimensional Laplace equation Train the solution jointly from observation points, boundary points, and collocation points
PDE modeling with noisy data Fit noisy observations subject to physical constraints
Optimizer comparison Compare the effects of Adam and L-BFGS on PINN convergence
Posterior prediction Compute predictive means and standard deviations from multiple parameter states

Usage

1. OneCode

Use the online OneCode environment for an intelligent, one-click AI for Science (AI4S) programming experience:

Launch OneCode for one-click AI4S programming

2. Manual Setup

Hardware Requirements

  • A GPU or DCU can accelerate full training; a CPU is sufficient for pipeline validation.
  • DCU users must install DTK and a PyTorch environment compatible with the target cluster.

Download the Model Package

hf download OneScience-Group/BPINNs --local-dir ./BPINNs
cd BPINNs

Set Up the Runtime Environment

DCU Environment

# Activate DTK and Conda first
conda create -n onescience311 python=3.11 -y
conda activate onescience311
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
pip install onescience[cfd-gpu] -i http://mirrors.onescience.ai:3141/pypi/simple/ --trusted-host mirrors.onescience.ai

Training Data

This example automatically generates interior observation points, boundary points, PDE collocation points, and a test grid from the analytical solution; no external data files are required. The number of observation and collocation points, noise level, and computational domain can be configured in conf/config.yaml.

Training

python scripts/train.py

By default, training produces the base weights at weight/bpinn_laplace1d.pt and saves the training history to result/training_history.npz.

Model Weights

This repository provides weights trained on the one-dimensional Laplace equation in the weight/ directory.

L-BFGS Refinement

python scripts/refine.py

By default, refinement produces weight/bpinn_laplace1d_refined.pt.

Inference, Evaluation, and Visualization

python scripts/inference.py

Inference loads the refined weights when available and otherwise falls back to the base weights. Predictions and visualizations are saved to result/. Model, training, loss, and inference parameters can all be modified in conf/config.yaml.

Official OneScience Resources

Citations and License

  • Yang, L., Meng, X., and Karniadakis, G. E. B-PINNs: Bayesian physics-informed neural networks for forward and inverse PDE problems with noisy data. Journal of Computational Physics, 425, 109913, 2021.
  • This model package is released under the Apache-2.0 license and retains attribution to the original paper.

中文说明

模型概览

BPINNs(Bayesian Physics-Informed Neural Networks,贝叶斯物理信息神经网络)将物理方程约束纳入贝叶斯神经网络,以使用含噪数据共同估计方程的解和预测不确定性。本模型包提供求解一维 Laplace 方程的示例。

u_xx + pi^2 sin(pi x) = 0,  x in [0, 1]
u(x) = sin(pi x)

论文:B-PINNs:用于含噪数据 PDE 正问题与反问题的贝叶斯物理信息神经网络
https://doi.org/10.1016/j.jcp.2020.109913

模型描述

BPINNs 结合观测数据、边界条件和 PDE 残差进行联合训练。默认先使用 Adam 优化模型,再使用 L-BFGS 进一步优化。推理(inference)时,可以根据模型权重(检查点)(checkpoint)中存储的多个参数状态计算预测均值和标准差。默认训练流程仅生成一个优化后的状态。完整的贝叶斯不确定性量化需要通过 Hamiltonian Monte Carlo(HMC)、变分推理或集合采样获得的后验参数状态。

使用场景

使用场景 说明
一维 Laplace 方程 利用观测点、边界点和配点联合训练以求解方程
含噪数据 PDE 建模 在物理约束下拟合含噪观测数据
优化器对比 比较 Adam 和 L-BFGS 对 PINN 收敛的影响
后验预测 根据多个参数状态计算预测均值和标准差

使用指南

1. OneCode

通过 OneCode 在线环境体验面向科学的人工智能(AI4S)智能一键编程。

启动 OneCode 以使用一键 AI4S 编程

2. 手动配置

硬件要求

  • GPU 或 DCU 可以加速完整训练,CPU 可以满足流程验证的需求。
  • DCU 用户须安装 DTK,以及与目标集群兼容的 PyTorch 环境。

下载模型包

hf download OneScience-Group/BPINNs --local-dir ./BPINNs
cd BPINNs

配置运行环境

DCU 环境

# Activate DTK and Conda first
conda create -n onescience311 python=3.11 -y
conda activate onescience311
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
pip install onescience[cfd-gpu] -i http://mirrors.onescience.ai:3141/pypi/simple/ --trusted-host mirrors.onescience.ai

训练数据

本示例根据解析解自动生成内部观测点、边界点、PDE 配点和测试网格,无需外部数据文件。可在 conf/config.yaml 中配置观测点和配点数量、噪声水平及计算域。

训练

python scripts/train.py

默认训练在 weight/bpinn_laplace1d.pt 生成基础权重,并将训练历史保存到 result/training_history.npz。

模型权重

本仓库在 weight/ 目录中提供基于一维 Laplace 方程训练得到的权重。

L-BFGS 进一步优化

python scripts/refine.py

默认优化过程生成 weight/bpinn_laplace1d_refined.pt。

推理、评估与可视化

python scripts/inference.py

推理优先加载进一步优化后的权重,若不可用,则加载基础权重。预测结果及可视化结果保存到 result/。模型、训练、损失和推理的参数均可在 conf/config.yaml 中修改。

OneScience 官方资源

引用与许可证

  • Yang, L., Meng, X., and Karniadakis, G. E. B-PINNs: Bayesian physics-informed neural networks for forward and inverse PDE problems with noisy data. Journal of Computational Physics, 425, 109913, 2021.
  • 本模型包采用 Apache-2.0 许可证发布,并保留原始论文署名。
Downloads last month
11
Inference Providers NEW
This model isn't deployed by any Inference Provider. 🙋 Ask for provider support