File size: 4,854 Bytes
28d9c3b | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 | ---
frameworks:
- pytorch
language:
- en
license: apache-2.0
tags:
- OneScience
- BPINNs
- Bayesian-physics-informed-neural-networks
- partial-differential-equations
- Laplace
tasks:
- pde-solving
---
<p align="center">
<strong>
<span style="font-size: 30px;">BPINNs</span>
</strong>
</p>
# 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:
```text
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](https://web-2069360198568017922-iaaj.ksai.scnet.cn:58043/home)
## 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
```bash
modelscope download --model OneScience/BPINNs --local_dir ./BPINNs
cd BPINNs
```
### Set Up the Runtime Environment
**DCU Environment**
```bash
# 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**
```bash
# 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
```bash
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
```bash
python scripts/refine.py
```
By default, refinement produces `weight/bpinn_laplace1d_refined.pt`.
### Inference, Evaluation, and Visualization
```bash
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
| Platform | OneScience Repository | Skills Repository |
| --- | --- | --- |
| Gitee | https://gitee.com/onescience-ai/onescience | https://gitee.com/onescience-ai/oneskills |
| GitHub | https://github.com/onescience-ai/OneScience | https://github.com/onescience-ai/oneskills |
# 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.
|