IO¶
Functions to be used for handling the serialization of models
- metatensor.models.utils.io.check_suffix(filename: str | Path, suffix: str) str | Path [source]¶
Check the suffix of a file name and adds if it not existing.
If
filename
does not end withsuffix
thesuffix
is added and a warning will be issued.
- metatensor.models.utils.io.save(model: Module, path: str | Path) None [source]¶
Saves a model to a checkpoint file.
Along with the model all the metadata needed to load it is saved as well. Checkpointed models will be saved with a
.ckpt
file ending. Ifpath
does not end with this file extensions.ckpt
will be added and a warning emitted.
- metatensor.models.utils.io.load(path: str | Path) Module | RecursiveScriptModule [source]¶
Loads a checkpoint or an exported model from a file.
- metatensor.models.utils.io.export(model: Module, path: str | Path) None [source]¶
Export a trained model to allow it to make predictions.
This includes predictions within molecular simulation engines. Exported models will be saved with a
.pt
file ending. Ifpath
does not end with this file extensions.pt
will be added and a warning emitted.