def load_model(self, file_path): """ This function load already saved model and sets cuda parameters. :param file_path: File path of a model to loaded. :type file_path: string """ model_dict = torch.load(file_path) model = RNNClassifier( model_dict["input_size"], model_dict["hidden_size"], model_dict["output_size"], model_dict["n_layers"], ) model.load_state_dict(model_dict["state_dict"]) super()._load_model(model)
def load_checkpoint(self, file_path): """ This function load already saved model checkpoint and sets cuda parameters. :param file_path: File path of a model checkpoint to be loaded. :type file_path: string """ checkpoint = torch.load(file_path) model = RNNClassifier( checkpoint["input_size"], checkpoint["hidden_size"], checkpoint["output_size"], checkpoint["n_layers"], ) model.load_state_dict(checkpoint["state_dict"]) super().leverage_model(model)