-
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.
- Loading branch information
1 parent
9df6409
commit 47d0474
Showing
10 changed files
with
1,282 additions
and
31 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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 SoapBPNN | ||
from .train import train |
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
1,201 changes: 1,201 additions & 0 deletions
1,201
src/metatensor_models/soap_bpnn/tests/data/qm9_reduced_100.xyz
Large diffs are not rendered by default.
Oops, something went wrong.
3 changes: 1 addition & 2 deletions
3
...or_models/soap-bpnn/tests/data/readme.txt → ...or_models/soap_bpnn/tests/data/readme.txt
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 |
---|---|---|
@@ -1,2 +1 @@ | ||
These 100 structures are the first 100 structures in the QM9 dataset. | ||
They are used to test the model. | ||
These 100 structures are the first 100 structures in the QM9 dataset; they are used to test the SOAP-BPNN model. |
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,26 @@ | ||
import torch | ||
import ase.io | ||
import rascaline.torch | ||
import copy | ||
|
||
import yaml | ||
|
||
|
||
from metatensor_models.soap_bpnn import SoapBPNN | ||
|
||
|
||
def test_rotational_invariance(): | ||
"""Tests that the model is rotationally invariant.""" | ||
|
||
all_species = [1, 6, 7, 8, 9] | ||
hypers = yaml.safe_load(open("../default.yml", "r")) | ||
soap_bpnn = SoapBPNN(all_species, hypers).to(torch.float64) | ||
|
||
structure = ase.io.read("data/qm9_reduced_100.xyz") | ||
original_structure = copy.deepcopy(structure) | ||
structure.rotate(48, "y") | ||
|
||
original_output = soap_bpnn([rascaline.torch.systems_to_torch(original_structure)]) | ||
rotated_output = soap_bpnn([rascaline.torch.systems_to_torch(structure)]) | ||
|
||
assert torch.allclose(original_output["energy"].block().values, rotated_output["energy"].block().values) |
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 @@ | ||
import torch | ||
torch.random.manual_seed(0) | ||
import ase.io | ||
import rascaline.torch | ||
import copy | ||
|
||
import yaml | ||
|
||
from metatensor_models.soap_bpnn import SoapBPNN | ||
|
||
|
||
def test_regression_init(): | ||
"""Perform a regression test on the model at initialization""" | ||
|
||
all_species = [1, 6, 7, 8, 9] | ||
hypers = yaml.safe_load(open("../default.yml", "r")) | ||
soap_bpnn = SoapBPNN(all_species, hypers).to(torch.float64) | ||
|
||
structures = ase.io.read("data/qm9_reduced_100.xyz", ":5") | ||
|
||
output = soap_bpnn([rascaline.torch.systems_to_torch(structure) for structure in structures]) | ||
expected_output = torch.tensor( | ||
[[ 0.051073328644], | ||
[ 0.226986056644], | ||
[-0.069471667587], | ||
[-0.218890301061], | ||
[-0.043132789197]], | ||
dtype=torch.float64 | ||
) | ||
|
||
assert torch.allclose(output["energy"].block().values, expected_output) | ||
|
||
|
||
def test_regression_train(): | ||
"""Perform a regression test on the model when trained for 2 epoch trained on a small dataset""" | ||
# TODO: Implement this test |
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