pytorch-forecasting icon indicating copy to clipboard operation
pytorch-forecasting copied to clipboard

Cannot load save model

Open ferdinandl007 opened this issue 2 years ago • 1 comments

  • 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

model2.zip


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.

ferdinandl007 avatar Jul 01 '22 03:07 ferdinandl007

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

icedumpy avatar Jul 04 '22 11:07 icedumpy