pytorch-forecasting
pytorch-forecasting copied to clipboard
Cannot load save model
- PyTorch-Forecasting version: 0.10.2
- PyTorch version: 1.12.0
- Python version: 3.9.13
- Operating System: macOS 12.4
Expected behavior
Loading the model with no problems, This works when training and model on my MacBook, however feels when training a model on a dedicated server and then trying to load the train model file on my Mac.
I executed code ... in order to ... and expected to get result ... device = torch.device('cpu') best_tft = TemporalFusionTransformer.load_from_checkpoint(best_model_path,map_location=device)
I expected the loaded model. However I get this error message
Actual behavior
File ~/Documents/MSc/Portfolio optimisation/.venv/lib/python3.9/site-packages/torch/nn/modules/module.py:1207, in Module.getattr(self, name) 1205 if name in modules: 1206 return modules[name] -> 1207 raise AttributeError("'{}' object has no attribute '{}'".format( 1208 type(self).name, name))
AttributeError: 'QuantileLoss' object has no attribute '_load_state_dict_post_hooks' However, result was .... I think it has to do with ... because of ...
Code to reproduce the problem
Paste the command(s) you ran and the output. Including a link to a colab notebook will speed up issue resolution. If there was a crash, please include the traceback here. The code used to initialize the TimeSeriesDataSet and model should be also included.
I think you have to uninstall pytorch version 1.12.0 and then reinstall pytorch version 1.11.0
I got the same error when I use this environment PyTorch-Forecasting version: 0.10.2 PyTorch version: 1.12.0 Python version: 3.9.13
It was solved when I downgrade torch to PyTorch-Forecasting version: 0.10.2 PyTorch version: 1.11.0 Python version: 3.9.13