-
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
09c58cd
commit 01bcf05
Showing
5 changed files
with
73 additions
and
23 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
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,34 @@ | ||
import torch | ||
|
||
from typing import Dict, List | ||
|
||
|
||
def save_model(arch_name: str, model: torch.nn.Module, hypers: Dict, all_species: List[int], path: str) -> None: | ||
"""Saves a model to a file, along with all the metadata needed to load it. | ||
Parameters | ||
---------- | ||
arch_name (str): The name of the architecture. | ||
model (torch.nn.Module): The model to save. | ||
hypers (Dict): The hyperparameters used to train the model. | ||
path (str): The path to the file. | ||
""" | ||
torch.save({"name": arch_name, "model": model.state_dict(), "hypers": hypers, "all_species": all_species}, path) | ||
|
||
|
||
def load_model(path: str) -> torch.nn.Module: | ||
"""Loads a model from a file. | ||
Parameters | ||
---------- | ||
path (str): The path to the file. | ||
Returns | ||
------- | ||
torch.nn.Module: The loaded model. | ||
""" | ||
# TODO, possibly with hydra utilities? | ||
pass |
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 @@ | ||
from metatensor.models import soap_bpnn | ||
|
||
|
||
def test_save_load_model(): | ||
"""Test that saving and loading a model works.""" | ||
pass |