Serialization#

metatensor.torch.save(path: str, tensor: TensorMap)[source]#

Save the given TensorMap to a file at path.

TensorMap are serialized using numpy’s .npz format, i.e. a ZIP file without compression (storage method is STORED), where each file is stored as a .npy array. See the C API documentation for more information on the format.

Parameters:
  • path (str) – path of the file where to save the data

  • tensor (TensorMap) – tensor to save

metatensor.torch.load(path: str) TensorMap[source]#

Load a previously saved TensorMap from the given path.

TensorMap are serialized using numpy’s .npz format, i.e. a ZIP file without compression (storage method is STORED), where each file is stored as a .npy array. See the C API documentation for more information on the format.

Parameters:

path (str) – path of the file to load

Return type:

TensorMap