-
Notifications
You must be signed in to change notification settings - Fork 295
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
TypeError: Module.load_state_dict() got an unexpected keyword argument 'assign' #986
Comments
Hi, do you have a piece of standalone code that I can run to reproduce this error? That would help me debug. From the limited information it seems maybe the checkpoint you are loading is of the wrong datatype, or possibly it's a version issue with your Pytorch installation (i.e. the checkpoint was saved with a different version than Nixtla is using). But this is a bit guessing :) |
from neuralforecast.auto import AutoTSMixer, AutoTSMixerx from datasetsforecast.long_horizon import LongHorizon Change this to your own data to try the modelY_df, X_df, _ = LongHorizon.load(directory='./', group='ETTm2') X_df contains the exogenous features, which we add to Y_dfX_df['ds'] = pd.to_datetime(X_df['ds']) We make validation and test splitsn_time = len(Y_df.ds.unique())
] Y_hat_df = nf.cross_validation(df=Y_df, Y_hat_df = Y_hat_df.reset_index() for model in models: |
Thanks - I have zero issues executing that code. So my response is similar to #987, i.e. Can you give more details about the machine config (OS, Python) you are using? How are you running this script? If I'd have to guess it's a package conflict issue - so I would create a new virtual environment, install neuralforecast in that environment, and try rerunning the script. |
@LeonTing1010 hi the environment-cpu.yml write the pytorch should >=2.0.0 but in 2.0.0 and 2.0.1 the code in https://github.com/pytorch/pytorch/blame/v2.0.0/torch/nn/modules/module.py#L1969 |
What happened + What you expected to happen
╭─────────────────────────────── Traceback (most recent call last) ────────────────────────────────╮
│ /Users/leo/web3/LLM/langchain/mlts/nf_iTransformer.py:47 in │
│ │
│ 44 # model_index=None, │
│ 45 # overwrite=True, │
│ 46 # save_dataset=True) │
│ ❱ 47 nf = NeuralForecast.load(path='./checkpoints/test_run/') │
│ 48 Y_hat_df = nf.predict().reset_index() │
│ 49 Y_hat_df = Y_hat_df[Y_hat_df['unique_id'] == '300543.SZ'] │
│ 50 Y_train_df = Y_train_df[Y_train_df['unique_id'] == '300543.SZ'] │
│ │
│ /Users/leo/web3/LLM/langchain/neuralforecast/neuralforecast/core.py:1333 in load │
│ │
│ 1330 │ │ for model in models_ckpt: │
│ 1331 │ │ │ model_name = "".join(model.split("")[:-1]) │
│ 1332 │ │ │ model_class_name = alias_to_model.get(model_name, model_name) │
│ ❱ 1333 │ │ │ loaded_model = MODEL_FILENAME_DICT[model_class_name].load( │
│ 1334 │ │ │ │ f"{path}/{model}", **kwargs │
│ 1335 │ │ │ ) │
│ 1336 │ │ │ loaded_model.alias = model_name │
│ │
│ /Users/leo/web3/LLM/langchain/neuralforecast/neuralforecast/common/_base_model.py:351 in load │
│ │
│ 348 │ │ │ content = torch.load(f, **kwargs) │
│ 349 │ │ with _disable_torch_init(): │
│ 350 │ │ │ model = cls(**content["hyper_parameters"]) │
│ ❱ 351 │ │ model.load_state_dict(content["state_dict"], strict=True, assign=True) │
│ 352 │ │ return model │
│ 353 │
╰──────────────────────────────────────────────────────────────────────────────────────────────────╯
TypeError: Module.load_state_dict() got an unexpected keyword argument 'assign'
Versions / Dependencies
Name: neuralforecast
Version: 1.7.1
Summary: Time series forecasting suite using deep learning models
Home-page: https://github.com/Nixtla/neuralforecast/
Author: Nixtla
Author-email: business@nixtla.io
License: Apache Software License 2.0
Reproduction script
nf = NeuralForecast.load(path='./checkpoints/test_run/')
Issue Severity
None
The text was updated successfully, but these errors were encountered: