PINA开源程序用于高级建模的 Physics-Informed 神经网络

​一、软件介绍

文末提供程序和源码下载

PINA 是一个开源 Python 库,旨在简化和加速科学机器学习 (SciML) 解决方案的开发。PINA 基于 PyTorch、PyTorch Lightning 和 PyTorch Geometry 构建,提供了一个直观的框架,用于使用神经网络、物理信息神经网络 (PINN)、神经运算符等定义、试验和解决复杂问题

  • Modular Architecture: Designed with modularity in mind and relying on powerful yet composable abstractions, PINA allows users to easily plug, replace, or extend components, making experimentation and customization straightforward.
    模块化架构:PINA 在设计时考虑了模块化,并依赖于强大但可组合的抽象,允许用户轻松插入、替换或扩展组件,使实验和定制变得简单明了。

  • Scalable Performance: With native support for multi-device training, PINA handles large datasets efficiently, offering performance close to hand-crafted implementations with minimal overhead.
    可扩展的性能:凭借对多设备训练的原生支持,PINA 可以高效处理大型数据集,以最小的开销提供接近手工构建的性能。

  • Highly Flexible: Whether you're looking for full automation or granular control, PINA adapts to your workflow. High-level abstractions simplify model definition, while expert users can dive deep to fine-tune every aspect of the training and inference process.
    高度灵活:无论您是在寻找完全自动化还是精细控制,PINA 都能适应您的工作流程。高级抽象简化了模型定义,而专家用户可以深入研究以微调训练和推理过程的各个方面。

二、Installation 安装

Installing a stable PINA release
安装稳定的 PINA 版本

Install using pip: 使用 pip 安装:

pip install "pina-mathlab"

Install from source: 从源码安装:

git clone https://github.com/mathLab/PINA
cd PINA
git checkout master
pip install .

Install with extra packages:
使用额外的软件包进行安装:

To install extra dependencies required to run tests or tutorials directories, please use the following command:
要安装运行 tests 或 tutorials 目录所需的额外依赖项,请使用以下命令:

pip install "pina-mathlab[extras]" 

Available extras include:
可用的额外服务包括:

  • dev for development purpuses, use this if you want to Contribute.
    dev 对于开发目的,如果您想要 贡献,请使用此项。
  • test for running test locally.
    test 用于在本地运行 TEST。
  • doc for building documentation locally.
    doc 用于本地构建文档。
  • tutorial for running Tutorials.
    tutorial 用于运行 Tutorials。

三、Quick Tour for New Users新用户快速导览

Solving a differential problem in PINA follows the four steps pipeline:
在 PINA 中求解差分问题遵循四个步骤 pipeline:

  1. Define the problem to be solved with its constraints using the Problem API.
    使用 Problem API 定义要解决的问题及其约束。

  2. Design your model using PyTorch, or for graph-based problems, leverage PyTorch Geometric to build Graph Neural Networks. You can also import models directly from the Model API.
    使用 PyTorch 设计模型,或者对于基于图形的问题,利用 PyTorch Geometric 构建图形神经网络。您还可以直接从 Model API 导入模型。

  3. Select or build a Solver for the Problem, e.g., supervised solvers, or physics-informed (e.g., PINN) solvers. PINA Solvers are modular and can be used as-is or customized.
    为问题选择或构建求解器,例如,监督式求解器或物理信息(例如 PINN)求解器。PINA 求解器是模块化的,可以按原样使用或自定义使用。

  4. Train the model using the Trainer API class, built on PyTorch Lightning, which supports efficient, scalable training with advanced features.
    使用基于 PyTorch Lightning 构建的 Trainer API 类训练模型,该类支持具有高级功能的高效、可扩展训练。

Do you want to learn more about it? Look at our Tutorials.
您想了解更多相关信息吗?查看我们的教程。

四、Solve Data Driven Problems解决数据驱动的问题

Data driven modelling aims to learn a function that given some input data gives an output (e.g. regression, classification, ...). In PINA you can easily do this by:
数据驱动建模旨在学习给定一些输入数据给出输出的函数(例如回归、分类等)。在 PINA 中,您可以通过以下方式轻松做到这一点:

from pina import Trainer
from pina.model import FeedForward
from pina.solver import SupervisedSolver
from pina.problem.zoo import SupervisedProbleminput_tensor  = torch.rand((10, 1))
output_tensor = input_tensor.pow(3)# Step 1. Define problem
problem = SupervisedProblem(input_tensor, target_tensor)
# Step 2. Design model (you can use your favourite torch.nn.Module in here)
model   = FeedForward(input_dimensions=1, output_dimensions=1, layers=[64, 64])
# Step 3. Define Solver
solver  = SupervisedSolver(problem, model)
# Step 4. Train
trainer = Trainer(solver, max_epochs=1000, accelerator='gpu')
trainer.train()

Solve Physics Informed Problems
解决 Physics Informed 问题

Physics-informed modeling aims to learn functions that not only fit data, but also satisfy known physical laws, such as differential equations or boundary conditions. For example, the following differential problem:
基于物理场的建模旨在学习不仅拟合数据,而且满足已知物理定律(例如微分方程或边界条件)的函数。例如,以下 differential 问题:

{����(�)=�(�)�∈(0,1)�(�=0)=1

in PINA, can be easily implemented by:
在 PINA 中,可以通过以下方式轻松实现:

from pina import Trainer, Condition
from pina.problem import SpatialProblem
from pina.operator import grad
from pina.solver import PINN
from pina.model import FeedForward
from pina.domain import CartesianDomain
from pina.equation import Equation, FixedValuedef ode_equation(input_, output_):u_x = grad(output_, input_, components=["u"], d=["x"])u = output_.extract(["u"])return u_x - u# build the problem
class SimpleODE(SpatialProblem):output_variables = ["u"]spatial_domain = CartesianDomain({"x": [0, 1]})domains = {"x0": CartesianDomain({"x": 0.0}),"D": CartesianDomain({"x": [0, 1]}),}conditions = {"bound_cond": Condition(domain="x0", equation=FixedValue(1.0)),"phys_cond": Condition(domain="D", equation=Equation(ode_equation)),}# Step 1. Define problem
problem = SimpleODE()
# Step 2. Design model (you can use your favourite torch.nn.Module in here)
model   = FeedForward(input_dimensions=1, output_dimensions=1, layers=[64, 64])
# Step 3. Define Solver
solver  = PINN(problem, model)
# Step 4. Train
trainer = Trainer(solver, max_epochs=1000, accelerator='gpu')
trainer.train()

五、Application Programming Interface
应用程序编程接口

Here's a quick look at PINA's main module. For a better experience and full details, check out the documentation.
以下是 PINA 的主模块的快速浏览。要获得更好的体验和完整的详细信息,请查看文档。

五、软件下载

迅雷云盘

本文信息来源于GitHub作者地址:https://github.com/mathLab/PINA

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。
如若转载,请注明出处:http://www.pswp.cn/bicheng/85741.shtml
繁体地址,请注明出处:http://hk.pswp.cn/bicheng/85741.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

一种对外IP/MAC地址收敛的软硬件系统

----------原创不易,欢迎点赞收藏。广交嵌入式开发的朋友,讨论技术和产品------------- 今天发一篇五年前的文章,不调单板。对以太网和交换片的较多理解,对系统级的优化。 大部分的网络设备,都由多种单板组成&#x…

【flink】 flink 读取debezium-json数据获取数据操作类型op/rowkind方法

flink 读取debezium-json数据获取数据操作类型op/rowkind方法。 op类型有c(create),u(update),d(delete) 参考官网案例:此处的"op": "u",就是操作类型。 {"before&qu…

某手游cocos2dlua反编译

一、获取加载的luac文件 通过frida hook libccos2dlua.so 的luaL_loadbuffer函数对luac进行dump js代码如下,得到dump后的lua文件 // 要加载的目标库名 var targetLibrary "libcocos2dlua.so"; var dlopen Module.findExportByName(null, "dlope…

`toRaw` 与 `markRaw`:Vue3 响应式系统的细粒度控制

🤍 前端开发工程师、技术日更博主、已过CET6 🍨 阿珊和她的猫_CSDN博客专家、23年度博客之星前端领域TOP1 🕠 牛客高级专题作者、打造专栏《前端面试必备》 、《2024面试高频手撕题》、《前端求职突破计划》 🍚 蓝桥云课签约作者、…

Python文件迁移之Shutil库详解

Shutil是一个Python内置的用来高效处理文件和目录迁移任务的库。Shutil不仅支持基本的文件复制、移动和删除操作,还具备处理大文件、批量迁移目录、以及跨平台兼容性等特性。通过使用Shutil,我们可以更加轻松地实现文件系统的管理和维护,本文…

【服务器R环境架构】基于 micromamba下载 R 库包

目录 准备工作:下载并安装R环境下载并安装R环境方式1:下载 .tar.bz2 压缩包进行解压执行(官方推荐)方式2: 创建并激活R环境 下载R库包安装CRAN包在 micromamba 中安装 GitHub 包(如 BPST) 参考 …

基于 Apache POI 实现的 Word 操作工具类

基于 Apache POI 实现的 Word 操作工具类 这个工具类是让 AI 写的,已覆盖常用功能。 如不满足场景的可以让 AI 继续加功能。 已包含的功能: 文本相关: 添加文本、 设置字体颜色、 设置字体大小、 设置对齐方式、 设置字符间距、 设置字体加粗…

时间序列预测、分类 | 图神经网络开源代码分享(上)

本期结合《时间序列图神经网络(GNN4TS)综述》,整理了关于图神经网络在时间序列预测、分类等任务上的开源代码和学习资料以供大家学习、研究。 参考论文:《A Survey on Graph Neural Networks for Time Series: Forecasting, Classification, Imputation,…

Vue 添加水印(防篡改: 删除水印元素节点、修改水印元素的样式)

MutationObserver_API: 观察某一个元素的变化// index.vue<template><div class="container"><Watermark text="版权所有" style="background: #28c848"><!-- 可给图片、视频、div...添加水印 --><div class=&quo…

如何处理开发不认可测试发现的问题

解决方案 第一步&#xff1a;收集确凿证据 确保有完整的复现结果准备详细的记录材料&#xff1a; 截屏录屏操作步骤记录 带着这些证据与开发人员进行沟通 第二步&#xff1a;多角度验证 如果与开发人员沟通无果&#xff1a; 竞品分析&#xff1a;查看市场上同类产品如何…

linux生产环境下根据关键字搜索指定日志文件命令

grep -C 100 "error" server.log 用于在 server.log 文件中查找包含 “error” 的行&#xff0c;并同时显示该行前后100行的上下文。这是排查日志问题的常用技巧&#xff0c;解释一下&#xff1a; 命令参数详解 grep&#xff1a;文本搜索工具&#xff0c;用于在文件…

用vue和echarts怎么写一个甘特图,并且是分段式瀑布流

vue echarts 甘特图功能 index.vue <template><div ref"echart" id"echart" class"echart"></div> </template><script setup>import { nextTick, onMounted, ref } from "vue";import * as echarts f…

Pandas使用教程:从入门到实战的数据分析利器

一、Pandas基础入门 1.1 什么是Pandas Pandas是Python生态中核心的数据分析库&#xff0c;提供高效的数据结构&#xff08;Series/DataFrame&#xff09;和数据分析工具。其名称源于"Panel Data"&#xff08;面板数据&#xff09;和"Python Data Analysis"…

NuttX Socket 源码学习

概述 NuttX 的 socket 实现是一个精心设计的网络编程接口&#xff0c;提供了标准的 BSD socket API。该实现采用分层架构设计&#xff0c;支持多种网络协议族&#xff08;如 TCP/IP、UDP、Unix域套接字等&#xff09;&#xff0c;具有良好的可扩展性和模块化特性。 整体架构设…

基于YOLO的语义分割实战(以猪的分割为例)

数据集准备 数据集配置文件 其实语义分割和目标检测类似&#xff0c;包括数据集制备、存放格式基本一致像这样放好即可。 然后需要编写一个data.yaml文件&#xff0c;对应的是数据的配置文件。 train: C:\图标\dan\语义分割pig\dataset\train\images #绝对路径即可 val: C:\…

钉钉智能会议室集成指纹密码锁,临时开门密码自动下发

在当今快节奏的工作环境中&#xff0c;会议室的高效管理和使用成为了企业提升工作效率的关键一环。湖南某知名企业近期成功升级了原有使用的钉钉智能会议室系统&#xff0c;并配套使用了启辰智慧联网指纹密码锁&#xff0c;实现了会议室管理的智能化升级&#xff0c;提升了会议…

C++讲解—类(1)

类 在 C 中&#xff0c;类是一个关键概念&#xff0c;凭借其封装和继承的特性&#xff0c;能够助力程序员之间实现高效的分工协作&#xff0c;共同完成复杂的大型项目。我们先从最简单的概念入手&#xff0c;再进行更深层次的了解和应用。 1. 类的定义 类是用户自定义的一种…

什么是Hadoop Yarn

Hadoop YARN&#xff1a;分布式集群资源管理系统详解 1. 什么是YARN&#xff1f; YARN&#xff08;Yet Another Resource Negotiator&#xff09;是 Apache Hadoop 生态系统中的资源管理和作业调度系统&#xff0c;最初在 Hadoop 2.0 中引入&#xff0c;取代了 Hadoop 1.0 的…

项目开发中途遇到困难的解决方案

1. 正视困难&#xff0c;避免逃避 开发遇阻时&#xff0c;退缩会带来双重损失&#xff1a;既成为"失败者逃兵"&#xff0c;又损害职业信心1。 行动建议&#xff1a; 立即向团队透明化问题&#xff08;如进度延迟、技术瓶颈&#xff09;&#xff0c;避免问题滚雪球…

Blender硬表面建模篇收集学习建模过程中的Demo

c 齿轮 创建一个圆柱体&#xff0c;选择侧面的所有&#xff0c;然后进行隔断选择&#xff0c;两次挤出面&#xff0c;一次缩放面&#xff0c;通过圆柱面三次插入面缩放挤出得到齿轮中心&#xff0c;选中齿轮的锯齿中间&#xff0c;然后进行相同周长选择行选择齿与齿中间的面&…