Skip to content
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

Loading state_dict fails (model trained on linux and copied to windows) #372

Open
christianjosef27 opened this issue Dec 13, 2023 · 1 comment
Labels
bug Something isn't working

Comments

@christianjosef27
Copy link

Version
pyabsa==2.3.1
torch==1.13.0
transformers==4.29.0

Describe the bug
I used to load my custom state_dict from my windows system and the loading procedure worked.
However, I am training now on a linux server for resource reasons. I trained a sample model and copied the whole folder containing the model files to my windows system (.args, config, .state_dict, .tokenizer).
Now I tried to load that model in the same way as always but I get errors: (refer to Screenshot for details).

RuntimeError: Error(s) in loading state_dict for FAST_LCF_ATEPC:
Missing key(s) in state_dict: "bert4global.embeddings.position_ids".

if not hasattr(ATEPCModelList, self.model.class.name):
raise KeyError(
"The checkpoint you are loading is not from any ATEPC model."
)

Code To Reproduce
aspect_extractor = ATEPC.AspectExtractor('fast_lcf_atepc_custom_dataset_cdw_apcacc_75.0_apcf1_74.31_atef1_40.45',
auto_device=True, # False means load model on CPU
cal_perplexity=True,
)

Expected behavior
I expect the program to load my custom checkpoint/saved_state_dict.

Screenshots
image

@christianjosef27 christianjosef27 added the bug Something isn't working label Dec 13, 2023
@christianjosef27
Copy link
Author

I now have an idea why it does not work. I had a different version of tranformers on linux where i trained (4.35.2), in contrast in windows i have transformers==4.29 which might be the problem when loading the state_dict.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant