torchmd-net開源程序是訓練神經網絡潛力

?一、軟件介紹

文末提供程序和源碼下載

TorchMD-NET 提供最先進的神經網絡電位 (NNP) 和訓練它們的機制。如果有多個 NNP,它可提供高效、快速的實現,并且它集成在 GPU 加速的分子動力學代碼中,如 ACEMD、OpenMM 和 TorchMD。TorchMD-NET 將其 NNP 公開為 PyTorch 模塊。

二、Available architectures?可用的架構

  • Equivariant Transformer (ET)
  • 等變變壓器 (ET)
  • Transformer (T) 變壓器 (T)
  • Graph Neural Network (GN)
  • 圖神經網絡 (GN)
  • TensorNet 張量網

三、Installation?安裝

TorchMD-Net 可用作 pip 可安裝輪,也可用于 conda-forge

TorchMD-Net provides builds for CPU-only, CUDA 11.8 and CUDA 12.4. CPU versions are only provided as reference, as the performance will be extremely limited. Depending on which variant you wish to install, you can install it with one of the following commands:
TorchMD-Net 提供純 CPU、CUDA 11.8 和 CUDA 12.4 的構建。CPU 版本僅供參考,因為性能將非常有限。根據您要安裝的變體,您可以使用以下命令之一進行安裝:

# The following will install the CUDA 12.4 version by default
pip install torchmd-net 
# The following will install the CUDA 11.8 version
pip install torchmd-net --extra-index-url https://download.pytorch.org/whl/cu118 --extra-index-url https://us-central1-python.pkg.dev/pypi-packages-455608/cu118/simple
# The following will install the CUDA 12.4 version
pip install torchmd-net --extra-index-url https://download.pytorch.org/whl/cu124 --extra-index-url https://us-central1-python.pkg.dev/pypi-packages-455608/cu124/simple
# The following will install the CPU only version (not recommended)
pip install torchmd-net --extra-index-url https://download.pytorch.org/whl/cpu --extra-index-url https://us-central1-python.pkg.dev/pypi-packages-455608/cpu/simple   

Alternatively it can be installed with conda or mamba with one of the following commands. We recommend using?Miniforge?instead of anaconda.
或者,可以使用以下命令之一使用 conda 或 mamba 進行安裝。我們建議使用 Miniforge 而不是 anaconda。

mamba install torchmd-net cuda-version=11.8
mamba install torchmd-net cuda-version=12.4

Install from source?從源碼安裝

TorchMD-Net is installed using pip, but you will need to install some dependencies before. Check?this documentation page.
TorchMD-Net 是使用 pip 安裝的,但您需要先安裝一些依賴項。查看此文檔頁面。

四、Usage?用法

指定訓練參數可以通過配置 yaml 文件或直接通過命令行參數完成。可以在 examples/ 中找到某些模型和數據集的架構和訓練規范的幾個示例。請注意,如果 yaml 文件和命令行中都存在參數,則命令行版本優先。可以通過設置?CUDA_VISIBLE_DEVICES?環境變量來選擇 GPU。否則,該參數?--ngpus?可用于選擇要訓練的 GPU 數量(默認值 -1 使用所有可用的 GPU 或 中指定的?CUDA_VISIBLE_DEVICES?GPU)。請記住,nvidia-smi 報告的 GPU ID 可能與?CUDA_VISIBLE_DEVICES?使用的 GPU ID 不同。
For example, to train the Equivariant Transformer on the QM9 dataset with the architectural and training hyperparameters described in the paper, one can run:
例如,要使用論文中描述的架構和訓練超參數在 QM9 數據集上訓練等變變換器,可以運行:

mkdir output
CUDA_VISIBLE_DEVICES=0 torchmd-train --conf torchmd-net/examples/ET-QM9.yaml --log-dir output/

Run?torchmd-train --help?to see all available options and their descriptions.
Run (運行?torchmd-train --help?) 可查看所有可用選項及其描述。

Creating a new dataset?創建新數據集

If you want to train on custom data, first have a look at?torchmdnet.datasets.Custom, which provides functionalities for loading a NumPy dataset consisting of atom types and coordinates, as well as energies, forces or both as the labels. Alternatively, you can implement a custom class according to the torch-geometric way of implementing a dataset. That is, derive the?Dataset?or?InMemoryDataset?class and implement the necessary functions (more info?here). The dataset must return torch-geometric?Data?objects, containing at least the keys?z?(atom types) and?pos?(atomic coordinates), as well as?y?(label),?neg_dy?(negative derivative of the label w.r.t atom coordinates) or both.
如果您想使用自定義數據進行訓練,請首先查看?torchmdnet.datasets.Custom?,它提供了加載由原子類型和坐標以及能量和/或力組成的 NumPy 數據集的功能。或者,您可以根據實現數據集的 torch-geometric 方式實現自定義類。也就是說,派生?Dataset?or?InMemoryDataset?類并實現必要的函數(更多信息在這里)。數據集必須返回 torch-geometric?Data?對象,至少包含鍵?z?(原子類型) 和?pos?(原子坐標) 以及?y?(標簽)?neg_dy?(標簽 w.r.t 原子坐標的負導數) 或兩者。

Custom prior models?自定義先前模型

In addition to implementing a custom dataset class, it is also possible to add a custom prior model to the model. This can be done by implementing a new prior model class in?torchmdnet.priors?and adding the argument?--prior-model <PriorModelName>. As an example, have a look at?torchmdnet.priors.Atomref.
除了實現自定義數據集類之外,還可以向模型添加自定義先驗模型。這可以通過在 中?torchmdnet.priors?實現一個新的先前模型類并添加參數?--prior-model <PriorModelName>?來完成。例如,請查看?torchmdnet.priors.Atomref?。

Multi-Node Training?多節點訓練

In order to train models on multiple nodes some environment variables have to be set, which provide all necessary information to PyTorch Lightning. In the following we provide an example bash script to start training on two machines with two GPUs each. The script has to be started once on each node. Once?torchmd-train?is started on all nodes, a network connection between the nodes will be established using NCCL.
為了在多個節點上訓練模型,必須設置一些環境變量,這些變量為 PyTorch Lightning 提供所有必要的信息。在下文中,我們提供了一個示例 bash 腳本,用于在兩臺每臺機器上開始訓練,每臺機器有兩個 GPU。該腳本必須在每個節點上啟動一次。在所有節點上啟動后?torchmd-train?,將使用 NCCL 在節點之間建立網絡連接。

In addition to the environment variables the argument?--num-nodes?has to be specified with the number of nodes involved during training.
除了環境變量之外,?--num-nodes?還必須指定參數以及訓練期間涉及的節點數。

export NODE_RANK=0
export MASTER_ADDR=hostname1
export MASTER_PORT=12910mkdir -p output
CUDA_VISIBLE_DEVICES=0,1 torchmd-train --conf torchmd-net/examples/ET-QM9.yaml.yaml --num-nodes 2 --log-dir output/
  • NODE_RANK?: Integer indicating the node index. Must be?0?for the main node and incremented by one for each additional node.
    NODE_RANK?:表示節點索引的整數。必須用于?0?主節點,并且每增加一個節點,其增量為 1。
  • MASTER_ADDR?: Hostname or IP address of the main node. The same for all involved nodes.
    MASTER_ADDR?:主節點的主機名或 IP 地址。所有相關節點都是一樣的。
  • MASTER_PORT?: A free network port for communication between nodes. PyTorch Lightning suggests port?12910?as a default.
    MASTER_PORT?:用于節點之間通信的空閑網絡端口。PyTorch Lightning 建議將 port?12910?作為默認值。

Known Limitations?已知限制

  • Due to the way PyTorch Lightning calculates the number of required DDP processes, all nodes must use the same number of GPUs. Otherwise training will not start or crash.
    由于 PyTorch Lightning 計算所需 DDP 進程數量的方式,所有節點都必須使用相同數量的 GPU。否則,訓練將無法開始或崩潰。
  • We observe a 50x decrease in performance when mixing nodes with different GPU architectures (tested with RTX 2080 Ti and RTX 3090).
    我們觀察到,當混合使用具有不同 GPU 架構的節點時,性能下降了 50 倍(使用 RTX 2080 Ti 和 RTX 3090 測試)。
  • Some CUDA systems might hang during a multi-GPU parallel training. Try?export NCCL_P2P_DISABLE=1, which disables direct peer to peer GPU communication.
    某些 CUDA 系統可能會在多 GPU 并行訓練期間掛起。Try?export NCCL_P2P_DISABLE=1?,這將禁用直接的對等 GPU 通信。

Cite?引用

If you use TorchMD-NET in your research, please cite the following papers:
如果您在研究中使用 TorchMD-NET,請引用以下論文:

Main reference?主要參考
<span style="background-color:var(--bgColor-muted, var(--color-canvas-subtle))"><span style="color:#1f2328"><span style="color:var(--fgColor-default, var(--color-fg-default))"><span style="background-color:var(--bgColor-muted, var(--color-canvas-subtle))"><code>@misc{pelaez2024torchmdnet,
title={TorchMD-Net 2.0: Fast Neural Network Potentials for Molecular Simulations}, 
author={Raul P. Pelaez and Guillem Simeon and Raimondas Galvelis and Antonio Mirarchi and Peter Eastman and Stefan Doerr and Philipp Th?lke and Thomas E. Markland and Gianni De Fabritiis},
year={2024},
eprint={2402.17660},
archivePrefix={arXiv},
primaryClass={cs.LG}
}
</code></span></span></span></span>
TensorNet?張量網
<span style="background-color:var(--bgColor-muted, var(--color-canvas-subtle))"><span style="color:#1f2328"><span style="color:var(--fgColor-default, var(--color-fg-default))"><span style="background-color:var(--bgColor-muted, var(--color-canvas-subtle))"><code>@inproceedings{simeon2023tensornet,
title={TensorNet: Cartesian Tensor Representations for Efficient Learning of Molecular Potentials},
author={Guillem Simeon and Gianni De Fabritiis},
booktitle={Thirty-seventh Conference on Neural Information Processing Systems},
year={2023},
url={https://openreview.net/forum?id=BEHlPdBZ2e}
}
</code></span></span></span></span>
Equivariant Transformer
<span style="background-color:var(--bgColor-muted, var(--color-canvas-subtle))"><span style="color:#1f2328"><span style="color:var(--fgColor-default, var(--color-fg-default))"><span style="background-color:var(--bgColor-muted, var(--color-canvas-subtle))"><code>@inproceedings{
tholke2021equivariant,
title={Equivariant Transformers for Neural Network based Molecular Potentials},
author={Philipp Th{\"o}lke and Gianni De Fabritiis},
booktitle={International Conference on Learning Representations},
year={2022},
url={https://openreview.net/forum?id=zNHzqZ9wrRB}
}
</code></span></span></span></span>
Graph Network?Graph 網絡
<span style="background-color:var(--bgColor-muted, var(--color-canvas-subtle))"><span style="color:#1f2328"><span style="color:var(--fgColor-default, var(--color-fg-default))"><span style="background-color:var(--bgColor-muted, var(--color-canvas-subtle))"><code>@article{Majewski2023,title = {Machine learning coarse-grained potentials of protein thermodynamics},volume = {14},ISSN = {2041-1723},url = {http://dx.doi.org/10.1038/s41467-023-41343-1},DOI = {10.1038/s41467-023-41343-1},number = {1},journal = {Nature Communications},publisher = {Springer Science and Business Media LLC},author = {Majewski,  Maciej and Pérez,  Adrià and Th\"{o}lke,  Philipp and Doerr,  Stefan and Charron,  Nicholas E. and Giorgino,  Toni and Husic,  Brooke E. and Clementi,  Cecilia and Noé,  Frank and De Fabritiis,  Gianni},year = {2023},month = sep 
}
</code></span></span></span></span>

Developer guide?開發人員指南

Implementing a new architecture
實施新架構

To implement a new architecture, you need to follow these steps:
要實施新架構,您需要執行以下步驟:
1.?Create a new class in?torchmdnet.models?that inherits from?torch.nn.Model. Follow TorchMD_ET as a template. This is a minimum implementation of a model:
1. 在 中?torchmdnet.models?創建一個繼承自?torch.nn.Model?的新類。以 TorchMD_ET 為模板。這是模型的最低實現:

class MyModule(nn.Module):def __init__(self, parameter1, parameter2):super(MyModule, self).__init__()# Define your model hereself.layer1 = nn.Linear(10, 10)...# Initialize your model parameters hereself.reset_parameters()def reset_parameters(self):# Initialize your model parameters herenn.init.xavier_uniform_(self.layer1.weight)...def forward(self,z: Tensor, # Atomic numbers, shape (n_atoms, 1)pos: Tensor, # Atomic positions, shape (n_atoms, 3)batch: Tensor, # Batch vector, shape (n_atoms, 1). All atoms in the same molecule have the same value and are contiguous.q: Optional[Tensor] = None, # Atomic charges, shape (n_atoms, 1)s: Optional[Tensor] = None, # Atomic spins, shape (n_atoms, 1)) -> Tuple[Tensor, Tensor, Tensor, Tensor, Tensor]:# Define your forward pass herescalar_features = ...vector_features = ...# Return the scalar and vector features, as well as the atomic numbers, positions and batch vectorreturn scalar_features, vector_features, z, pos, batch

2.?Add the model to the?__all__?list in?torchmdnet.models.__init__.py. This will make the tests pick your model up.
2. 將模型添加到 中的?__all__?torchmdnet.models.__init__.py?列表中。這將使測試選取您的模型。
3.?Tell models.model.create_model how to initialize your module by adding a new entry, for instance:
3. 通過添加新條目來告訴models.model.create_model如何初始化您的模塊,例如:

    elif args["model"] == "mymodule":from torchmdnet.models.torchmd_mymodule import MyModuleis_equivariant = False # Set to True if your model is equivariantrepresentation_model = MyModule(parameter1=args["parameter1"],parameter2=args["parameter2"],**shared_args, # Arguments typically shared by all models)

4.?Add any new parameters required to initialize your module to scripts.train.get_args. For instance:
4. 添加將模塊初始化為 scripts.train.get_args 所需的任何新參數。例如:

  parser.add_argument('--parameter1', type=int, default=32, help='Parameter1 required by MyModule')...

5.?Add an example configuration file to?torchmd-net/examples?that uses your model.
5. 添加一個使用您的模型?torchmd-net/examples?的示例配置文件。
6.?Make tests use your configuration file by adding a case to tests.utils.load_example_args. For instance:
6. 通過向 tests.utils.load_example_args 添加 case 來使測試使用您的配置文件。例如:

if model_name == "mymodule":config_file = join(dirname(dirname(__file__)), "examples", "MyModule-QM9.yaml")

At this point, if your module is missing some feature the tests will let you know, and you can add it. If you add a new feature to the package, please add a test for it.
此時,如果您的模塊缺少某些功能,測試會通知您,您可以添加它。如果您向包中添加了新功能,請為其添加測試。

Code style?代碼樣式

We use?black. Please run?black?on your modified files before committing.
我們使用黑色。請在提交之前運行?black?您修改的文件。

Testing?測試

To run the tests, install the package and run?pytest?in the root directory of the repository. Tests are a good source of knowledge on how to use the different components of the package.
要運行測試,請安裝軟件包并在存儲庫的根目錄中運行?pytest?。測試是有關如何使用包的不同組件的良好知識來源。

五、軟件下載

夸克網盤分享

本文信息來源于GitHub作者地址:https://github.com/torchmd/torchmd-net

?

本文來自互聯網用戶投稿,該文觀點僅代表作者本人,不代表本站立場。本站僅提供信息存儲空間服務,不擁有所有權,不承擔相關法律責任。
如若轉載,請注明出處:http://www.pswp.cn/diannao/88058.shtml
繁體地址,請注明出處:http://hk.pswp.cn/diannao/88058.shtml
英文地址,請注明出處:http://en.pswp.cn/diannao/88058.shtml

如若內容造成侵權/違法違規/事實不符,請聯系多彩編程網進行投訴反饋email:809451989@qq.com,一經查實,立即刪除!

相關文章

在Docker上安裝Mongo及Redis-NOSQL數據庫

應用環境 Ubuntu 20.04.6 LTS (GNU/Linux 5.15.0-139-generic x86_64) Docker version 28.1.1, build 4eba377 文章目錄 一、部署Mongo1. 拉取容器鏡像2. 生成Run腳本2.1 準備條件2.2 參數解讀2.3 實例腳本 3. 實例操作3.1 Mongo bash控制臺3.2 庫表操作 4. MongoDB Compass (G…

Java 編程之責任鏈模式

一、什么是責任鏈模式&#xff1f; 責任鏈模式&#xff08;Chain of Responsibility Pattern&#xff09; 是一種行為型設計模式&#xff0c;它讓多個對象都有機會處理請求&#xff0c;從而避免請求的發送者和接收者之間的耦合關系。將這些對象連成一條鏈&#xff0c;沿著這條…

1、做中學 | 一年級上期 Golang簡介和安裝環境

一、什么是golang Golang&#xff0c;通常簡稱 Go&#xff0c;是由 Google 公司的 Robert Griesemer、Rob Pike 和 Ken Thompson 于 2007 年創建的一種開源編程語言&#xff0c;并在 2009 年正式對外公布。 已經有了很多編程語言&#xff0c;為什么還要創建一種新的編程語言&…

Linux--迷宮探秘:從路徑解析到存儲哲學

上一篇博客我們說完了文件系統在硬件層面的意義&#xff0c;今天我們來說說文件系統在軟件層是怎么管理的。 Linux--深入EXT2文件系統&#xff1a;數據是如何被組織、存儲與訪問的&#xff1f;-CSDN博客 &#x1f30c; 引言&#xff1a;文件系統的宇宙觀 "在Linux的宇宙中…

淘寶商品數據實時獲取方案|API 接口開發與安全接入

在電商數據獲取領域&#xff0c;除了官方 API&#xff0c;第三方數據 API 接入也是高效獲取淘寶商品數據的重要途徑。第三方數據 API 憑借豐富的功能、靈活的服務&#xff0c;為企業和開發者提供了多樣化的數據解決方案。本文將聚焦第三方數據 API 接入&#xff0c;詳細介紹其優…

什么是防抖和節流?它們有什么區別?

文章目錄 一、防抖&#xff08;Debounce&#xff09;1.1 什么是防抖&#xff1f;1.2 防抖的實現 二、節流&#xff08;Throttle&#xff09;2.1 什么是節流&#xff1f;2.2 節流的實現方式 三、防抖與節流的對比四、總結 在前端開發中&#xff0c;我們經常會遇到一些高頻觸發的…

Springboot集成阿里云OSS上傳

Springboot集成阿里云OSS上傳 API 接口描述 DEMO提供的四個API接口&#xff0c;支持不同方式的文件和 JSON 數據上傳&#xff1a; 1. 普通文件上傳接口 上傳任意類型的文件 2. JSON 字符串上傳接口 上傳 JSON 字符串 3. 單個 JSON 壓縮上傳接口 上傳并壓縮 JSON 字符串…

刪除大表數據注意事項

數據庫是否會因刪除操作卡死&#xff0c;沒有固定的 “安全刪除條數”&#xff0c;而是受數據庫配置、表結構、操作方式、當前負載等多種因素影響。以下是關鍵影響因素及實踐建議&#xff1a; 一、導致數據庫卡死的核心因素 硬件與數據庫配置 CPU / 內存瓶頸&#xff1a;刪除…

Redis 是單線程模型?|得物技術

一、背景 使用過Redis的同學肯定都了解過一個說法&#xff0c;說Redis是單線程模型&#xff0c;那么實際情況是怎樣的呢&#xff1f; 其實&#xff0c;我們常說Redis是單線程模型&#xff0c;是指Redis采用單線程的事件驅動模型&#xff0c;只有并且只會在一個主線程中執行Re…

[特殊字符] AIGC工具深度實戰:GPT與通義靈碼如何徹底重構企業開發流程

&#x1f50d; 第一模塊&#xff1a;理念顛覆——為什么AIGC不是“玩具”而是“效能倍增器”&#xff1f; ▍企業開發的核心痛點圖譜&#xff08;2025版&#xff09; ??研發效能瓶頸??&#xff1a;需求膨脹與交付時限矛盾持續尖銳&#xff0c;傳統敏捷方法論已觸天花板?…

(LeetCode 面試經典 150 題) 169. 多數元素(哈希表 || 二分查找)

題目&#xff1a;169. 多數元素 方法一&#xff1a;二分法&#xff0c;最壞的時間復雜度0(nlogn)&#xff0c;但平均0(n)即可。空間復雜度為0(1)。 C版本&#xff1a; int nnums.size();int l0,rn-1;while(l<r){int mid(lr)/2;int ans0;for(auto x:nums){if(xnums[mid]) a…

(17)java+ selenium->自動化測試-元素定位大法之By css上

1.簡介 CSS定位方式和xpath定位方式基本相同,只是CSS定位表達式有其自己的格式。CSS定位方式擁有比xpath定位速度快,且比CSS穩定的特性。下面詳細介紹CSS定位方式的使用方法。相對CSS來說,具有語法簡單,定位速度快等優點。 2.CSS定位優勢 CSS定位是平常使用過程中非常重要…

【軟考高級系統架構論文】企業集成平臺的技術與應用

論文真題 企業集成平臺是一個支持復雜信息環境下信息系統開發、集成和協同運行的軟件支撐環境。它基于各種企業經營業務的信息特征,在異構分布環境(操作系統、網絡、數據庫)下為應用提供一致的信息訪問和交互手段,對其上運行的應用進行管理,為應用提供服務,并支持企業信息…

i.MX8MP LVDS 顯示子系統全解析:設備樹配置與 DRM 架構詳解

&#x1f525; 推薦&#xff1a;《Yocto項目實戰教程&#xff1a;高效定制嵌入式Linux系統》 京東正版促銷&#xff0c;歡迎支持原創&#xff01; 鏈接&#xff1a;https://item.jd.com/15020438.html i.MX8MP LVDS 顯示子系統全解析&#xff1a;設備樹配置與 DRM 架構詳解 在…

keep-alive實現原理及Vue2/Vue3對比分析

一、keep-alive基本概念 keep-alive是Vue的內置組件&#xff0c;用于緩存組件實例&#xff0c;避免重復渲染。它具有以下特點&#xff1a; 抽象組件&#xff1a;自身不會渲染DOM&#xff0c;也不會出現在父組件鏈中包裹動態組件&#xff1a;緩存不活動的組件實例&#xff0c;…

安卓jetpack compose學習筆記-Navigation基礎學習

目錄 一、Navigation 二、BottomNavigation Compose是一個偏向靜態刷新的UI組件&#xff0c;如果不想要自己管理頁面切換的復雜狀態&#xff0c;可以以使用Navigation組件。 頁面間的切換可以NavHost&#xff0c;使用底部頁面切換欄&#xff0c;可以使用腳手架的bottomBarNav…

基于大數據技術的在UGC數據分析與路線推薦的研究

博主介紹&#xff1a;java高級開發&#xff0c;從事互聯網行業六年&#xff0c;熟悉各種主流語言&#xff0c;精通java、python、php、爬蟲、web開發&#xff0c;已經做了六年的畢業設計程序開發&#xff0c;開發過上千套畢業設計程序&#xff0c;沒有什么華麗的語言&#xff0…

flask通過表單自動產生get請求的參數、form表單實現POST請求的自動提交

通過表單自動產生get請求的參數 相關代碼如下&#xff1a; import flaskapp flask.Flask(__name__)app.route(/) def login():html <!DOCTYPE html><html lang"en"><head><meta charset"UTF-8"><title>flask表單實現get…

《情感反詐模擬器》2025學習版

1.2 專業內容支持 67篇情感詐騙案例研究14萬字心理學分析資料783條專業配音對白 二、安裝與運行 2.1 系統要求 最低配置&#xff1a; 顯卡&#xff1a;GTX 1060CPU&#xff1a;i5-8400存儲&#xff1a;25GB空間 2.2 運行步驟 解壓游戲文件&#xff08;21.7GB&#xff09;…

預訓練 vs. 微調:大模型落地的核心兩步,究竟有何不同?

在人工智能領域&#xff0c;尤其是自然語言處理&#xff08;NLP&#xff09;和計算機視覺&#xff08;CV&#xff09;&#xff0c;大型模型如GPT系列、BERT、Stable Diffusion等取得了令人矚目的成就。支撐這些模型廣泛應用的關鍵技術流程&#xff0c;通常包含兩個核心階段&…