M3GNet 开源项目使用教程
1. 项目的目录结构及介绍
M3GNet 项目的目录结构如下:
m3gnet/
├── pyproject.toml
├── requirements-ci.txt
├── requirements.txt
├── setup.cfg
├── setup.py
├── tasks.py
├── README.md
├── CODE_OF_CONDUCT.md
├── LICENSE
├── m3gnet/
│ ├── __init__.py
│ ├── models/
│ │ ├── __init__.py
│ │ ├── m3gnet.py
│ │ └── ...
│ ├── trainers/
│ │ ├── __init__.py
│ │ ├── potential_trainer.py
│ │ └── ...
│ ├── utils/
│ │ ├── __init__.py
│ │ ├── data_utils.py
│ │ └── ...
│ └── ...
└── tests/
├── __init__.py
├── test_m3gnet.py
└── ...
目录结构介绍
pyproject.toml
: 项目配置文件,用于定义项目的构建系统和依赖。requirements-ci.txt
和requirements.txt
: 项目依赖文件,分别用于CI环境和常规环境。setup.cfg
和setup.py
: 用于项目的打包和分发配置。tasks.py
: 项目任务脚本,可能包含一些自动化任务。README.md
: 项目介绍和使用说明。CODE_OF_CONDUCT.md
: 项目的行为准则。LICENSE
: 项目的开源许可证。m3gnet/
: 项目的主要代码目录,包含模型、训练器、工具等模块。tests/
: 项目的测试代码目录。
2. 项目的启动文件介绍
M3GNet 项目的启动文件主要是 m3gnet/models/m3gnet.py
和 m3gnet/trainers/potential_trainer.py
。
m3gnet.py
m3gnet.py
文件定义了 M3GNet 模型的核心架构,包括模型的初始化、前向传播等。
potential_trainer.py
potential_trainer.py
文件定义了模型的训练器,负责模型的训练过程,包括数据加载、优化器配置、训练循环等。
3. 项目的配置文件介绍
M3GNet 项目的主要配置文件包括 pyproject.toml
和 setup.cfg
。
pyproject.toml
pyproject.toml
文件用于定义项目的构建系统和依赖。例如:
[build-system]
requires = ["setuptools>=42", "wheel"]
build-backend = "setuptools.build_meta"
[project]
name = "m3gnet"
version = "0.1.0"
description = "Materials Graph Neural Network"
authors = [
{ name="Materials Virtual Lab", email="info@materialsvirtuallab.org" }
]
dependencies = [
"tensorflow>=2.0",
"pymatgen",
"ase",
"cython"
]
setup.cfg
setup.cfg
文件用于配置项目的打包和分发选项。例如:
[metadata]
name = m3gnet
version = 0.1.0
description = Materials Graph Neural Network
author = Materials Virtual Lab
author_email = info@materialsvirtuallab.org
license = BSD-3-Clause
[options]
packages = find:
install_requires =
tensorflow>=2.0
pymatgen
ase
cython
[options.package_data]
* = *.py, *.txt, *.md
通过以上配置文件,可以方便地进行项目的安装和分发。