-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement the Alchemical Model from
torch_alchemical
repo (#66)
--------- Co-authored-by: frostedoyster <[email protected]>
- Loading branch information
1 parent
d1c1522
commit 06ca9b4
Showing
30 changed files
with
1,445 additions
and
212 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
name: Alchemical Model tests | ||
|
||
on: | ||
push: | ||
branches: [main] | ||
pull_request: | ||
# Check all PR | ||
|
||
jobs: | ||
tests: | ||
runs-on: ${{ matrix.os }} | ||
strategy: | ||
matrix: | ||
include: | ||
- os: ubuntu-22.04 | ||
python-version: "3.11" | ||
|
||
steps: | ||
- uses: actions/checkout@v3 | ||
|
||
- name: Set up Python ${{ matrix.python-version }} | ||
uses: actions/setup-python@v4 | ||
with: | ||
python-version: ${{ matrix.python-version }} | ||
- run: pip install tox | ||
|
||
- name: run Alchemical Model tests | ||
run: tox -e alchemical-model-tests | ||
env: | ||
# Use the CPU only version of torch when building/running the code | ||
PIP_EXTRA_INDEX_URL: https://download.pytorch.org/whl/cpu | ||
|
||
- name: Upload codecoverage | ||
uses: codecov/codecov-action@v3 | ||
with: | ||
files: ./tests/coverage.xml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
.. _architecture-alchemical-model: | ||
|
||
Alchemical Model | ||
================ | ||
|
||
This is an implementation of Alchemical Model: a Behler-Parrinello neural network | ||
:footcite:p:`behler_generalized_2007` with Smooth overlab of atomic positions (SOAP) | ||
features :footcite:p:`bartok_representing_2013` and Alchemical Compression of the | ||
composition space :footcite:p:`willatt_feature_2018, lopanitsyna_modeling_2023, | ||
mazitov_surface_2024`. This model is extremely useful for simulating systems with | ||
large amount of chemical elements. | ||
|
||
|
||
Installation | ||
------------ | ||
|
||
To install the package, you can run the following command in the root | ||
directory of the repository: | ||
|
||
.. code-block:: bash | ||
pip install .[alchemical-model] | ||
This will install the package with the Alchemical Model dependencies. | ||
|
||
|
||
Hyperparameters | ||
--------------- | ||
|
||
The hyperparameters (and relative default values) for the Alchemical Model model are: | ||
|
||
.. literalinclude:: ../../../src/metatensor/models/cli/conf/architecture/experimental.alchemical_model.yaml | ||
:language: yaml | ||
|
||
Any of these hyperparameters can be overridden with the training parameter file. | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
Normalization | ||
============= | ||
|
||
Utilities to normalize the target values used for training. | ||
|
||
.. automodule:: metatensor.models.utils.normalize | ||
:members: | ||
:undoc-members: | ||
:show-inheritance: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
Basic usage of the Alchemical Model CLI | ||
======================================== |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
../../tests/resources/alchemical_reduced_10.xyz |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
structures: "alchemical_reduced_10.xyz" # file where the positions are stored | ||
targets: | ||
energy: | ||
key: "energy" # name of the target value | ||
forces: false | ||
stress: false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
# architecture used to train the model | ||
architecture: | ||
name: experimental.alchemical_model | ||
training: | ||
num_epochs: 10 | ||
|
||
# Mandatory section defining the parameters for structure and target data of the | ||
# training set | ||
training_set: | ||
structures: "alchemical_reduced_10.xyz" # file where the positions are stored | ||
targets: | ||
energy: | ||
key: "energy" # name of the target value | ||
forces: false | ||
stress: false | ||
|
||
test_set: 0.1 # 10 % of the training_set are randomly split and taken for test set | ||
validation_set: 0.1 # 10 % of the training_set are randomly split and for validation |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
23 changes: 23 additions & 0 deletions
23
src/metatensor/models/cli/conf/architecture/experimental.alchemical_model.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
# default hyperparameters for the Alchemical Model | ||
name: alchemical_model | ||
|
||
model: | ||
soap: | ||
num_pseudo_species: 4 | ||
cutoff_radius: 5.0 | ||
basis_cutoff: 400 # controls how large the radial-angular basis is | ||
radial_basis_type: 'physical' # 'physical' or 'le' | ||
basis_scale: 3.0 # controls the initial scale of the physical basis (in Angstroms, does not affect the le basis) | ||
trainable_basis: true # whether the radial basis is trainable (i.e. contains a small NN) | ||
|
||
bpnn: | ||
num_hidden_layers: 2 | ||
num_neurons_per_layer: 32 | ||
activation_function: SiLU # only SiLU is supported for the moment | ||
|
||
training: | ||
batch_size: 8 | ||
num_epochs: 100 | ||
learning_rate: 0.001 | ||
log_interval: 10 | ||
checkpoint_interval: 25 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 2 additions & 0 deletions
2
src/metatensor/models/experimental/alchemical_model/__init__.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
from .model import Model, DEFAULT_HYPERS # noqa: F401 | ||
from .train import train # noqa: F401 |
Oops, something went wrong.