| --- |
| 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. |
|
|