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 functiontorch.save()
. For further details see the documentation for the functiontorch.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 classemicroml.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”
. Ifdevice_name
is set toNone
and a GPU device is available, then a GPU device is to be used. Otherwise, the CPU is used.
- Returns:
- ml_model
emicroml.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
.
- ml_model