项目简介
本项目聚焦于复现论文DeepHPMs,借助深度学习从散乱且含噪声的时空观测数据中发现非线性偏微分方程(PDEs)。项目最初在PaddlePaddle框架实现相关功能,后迁移至MindSpore框架。MindSpore框架具有易开发、高效执行和全场景覆盖等特性,能助力开发者从复杂数据中逆推非线性动力学方程,在流体力学、量子物理等多领域有应用潜力。
项目的主要特性和功能
- 方程发现与预测:可从复杂数据中揭露和预测非线性偏微分方程,对高维数据拟合PDE公式。
- 双网络架构:采用两个深度神经网络,一个逼近未知解,避免数值微分不稳定;另一个代表非线性动力学,提炼数据演变机制。
- 多方程支持:适用于Burgers、KdV、Kuramoto - Sivashinsky、非线性Schrödinger和Navier - Stokes等多种方程。
- 跨框架实现:具备PaddlePaddle和MindSpore两个框架的实现版本,并提供了算子映射关系,方便不同框架间的迁移。
- 训练与评估:提供完整的训练过程和评估方法,能准确学习潜在动力学并预测系统未来状态,还可对模型性能进行评估。
安装使用步骤
数据集准备
- 从数据集下载链接下载针对Burgers方程的模拟数据,数据包含
burgers.mat
和burgers_sine.mat
。 - 将下载的数据集移到路径
./model/deep_hpms/data
。
MindSpore环境配置
- 服务器基础配置:
- 系统:Ubuntu18.04
- CUDA:11.1
- 显卡:2080ti
- 创建虚拟环境并切换:
Bash conda create -n mindspore python=3.7 conda activate mindspore
- 安装依赖包:
Bash asttokens==2.4.1 astunparse==1.6.3 certifi @ file:///croot/certifi_1671487769961/work/certifi cftime==1.6.2 cycler==0.11.0 filelock==3.12.2 fonttools==4.38.0 joblib==1.3.2 kiwisolver==1.4.5 matplotlib==3.5.3 mindspore @ https://ms-release.obs.cn-north-4.myhuaweicloud.com/2.2.14/MindSpore/unified/x86_64/mindspore-2.2.14-cp37-cp37m-linux_x86_64.whl mpi4py @ file:///croot/mpi4py_1671223370575/work netCDF4==1.6.4 numpy==1.21.6 Ofpp==0.1 packaging==24.0 pandas==1.1.5 Pillow==9.5.0 protobuf==4.24.4 psutil==5.9.8 pyaml==23.5.8 pyDOE==0.3.8 pyparsing==3.1.2 python-dateutil==2.9.0.post0 pytz==2024.1 PyYAML==6.0.1 sciai @ https://ms-release.obs.cn-north-4.myhuaweicloud.com/2.2.0/MindScience/sciai/gpu/x86_64/cuda-11.1/sciai-0.1.0-cp37-cp37m-linux_x86_64.whl scikit-learn==1.0.2 scikit-optimize==0.9.0 scipy==1.7.3 seaborn==0.12.2 six==1.16.0 threadpoolctl==3.1.0 tikzplotlib==0.10.1 typing_extensions==4.7.1 webcolors==1.13
- MindSpore_gpu安装:
Bash pip install https://ms-release.obs.cn-north-4.myhuaweicloud.com/2.2.14/MindSpore/unified/x86_64/mindspore-2.2.14-cp38-cp38-linux_x86_64.whl --trusted-host ms-release.obs.cn-north-4.myhuaweicloud.com -i https://pypi.tuna.tsinghua.edu.cn/simple
- 验证MindSpore安装:
Bash python -c "import mindspore;mindspore.set_context(device_target='CPU');mindspore.run_check()"
- sciai_g安装:
Bash pip install https://ms-release.obs.cn-north-4.myhuaweicloud.com/2.2.0/MindScience/sciai/gpu/x86_64/cuda-11.1/sciai-0.1.0-cp37-cp37m-linux_x86_64.whl -i https://pypi.tuna.tsinghua.edu.cn/simple
模型训练
在2080ti上采用GPU进行训练:
Bash
python train.py \
--problem burgers_different \
--u_layers 2 50 50 50 50 1 \
--pde_layers 3 100 100 1 \
--layers 2 50 50 50 50 1 \
--save_ckpt true \
--load_ckpt false \
--save_ckpt_path ./checkpoints \
--load_ckpt_path ./checkpoints/burgers_diff_final.ckpt \
--save_fig true \
--figures_path ./figures \
--load_data_idn_path ./data/burgers_sine.mat \
--load_data_sol_path ./data/burgers.mat \
--log_path ./logs \
--lr 1e-3 \
--train_epoch 30001 \
--train_epoch_lbfgs 100 \
--print_interval 100 \
--lb_idn 0.0 -8.0 \
--ub_idn 10.0 8.0 \
--lb_sol 0.0 -8.0 \
--ub_sol 10.0 8.0 \
--download_data deep_hpms \
--force_download false \
--data_type float32 \
--amp_level O3 \
--device_id 0 \
--mode 0
模型评估
在GPU上进行评估,日志文件保存在./logs
,结果图片保存在figures_path
(默认位于./figures
):
Bash
python eval.py
下载地址
点击下载 【提取码: 4003】【解压密码: www.makuang.net】