2.1.1.1.1.3. emicroml.modelling.cbed.distortion.estimation.load_ml_model_from_file

load_ml_model_from_file(ml_model_state_dict_filename, device_name=None)[source]

Load a machine learning model from a file.

The current function loads/reconstructs machine learning (ML) models, represented by the class emicroml.modelling.cbed.distortion.estimation.MLModel, from files storing dictionary representations of said ML models.

Dictionary representations of ML models can be generated via the method emicroml.modelling.cbed.distortion.estimation.MLModel.state_dict(). Subsequently, these dictionaries can be saved to files via the function torch.save(). For further details see the documentation for the function torch.load().

Moreover, dictionary representations of ML models can be generated then saved to files via the method emicroml.modelling.cbed.distortion.estimation.MLModelTrainer.train_ml_model() of the class emicroml.modelling.cbed.distortion.estimation.MLModelTrainer. For further details see the documentation for said method.

Parameters:
ml_model_state_dict_filenamestr

The relative or absolute path to the file storing the dictionary representation of the ML model to load/reconstruct.

device_namestr | None, optional

This parameter specifies the device in which to store the ML model. If device_name is a string, then it is the name of the device to be used, e.g. ”cuda” or ”cpu”. If device_name is set to None and a GPU device is available, then a GPU device is to be used. Otherwise, the CPU is used.

Returns:
ml_modelemicroml.modelling.cbed.distortion.estimation.MLModel

The ML model represented by the dictionary stored in the file at the file path ml_model_state_dict_filename.