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
英文地址,請注明出處:http://en.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;然后進行相同周長選擇行選擇齒與齒中間的面&…