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

load_bert_ issue #62

Closed
mathiasGM opened this issue Aug 27, 2020 · 3 comments
Closed

load_bert_ issue #62

mathiasGM opened this issue Aug 27, 2020 · 3 comments

Comments

@mathiasGM
Copy link

mathiasGM commented Aug 27, 2020

Hi,

I am trying to use the 'bert_ner_model' and 'bert_tone_model' using the "load_bert_tone_ner" and "load_bert_tone_model" methods.

I get the following errors when loading the models:

NER:


RuntimeError: Error(s) in loading state_dict for BertForTokenClassification:
size mismatch for classifier.weight: copying a param with shape torch.Size([9, 768]) from checkpoint, the shape in current model is torch.Size([2, 768]).
size mismatch for classifier.bias: copying a param with shape torch.Size([9]) from checkpoint, the shape in current model is torch.Size([2]).

Tone:

RuntimeError: Error(s) in loading state_dict for BertForSequenceClassification:
size mismatch for classifier.weight: copying a param with shape torch.Size([3, 768]) from checkpoint, the shape in current model is torch.Size([2, 768]).
size mismatch for classifier.bias: copying a param with shape torch.Size([3]) from checkpoint, the shape in current model is torch.Size([2]).

Any ideas on how to fix this?

Final note:
Thanks for your work on Danish NLP! You are really advancing the field with this repo.

@AmaliePauli
Copy link
Contributor

Hi mathiasGM,
What is your environment? The code is tested with danlp==0.0.9, and transformers==2.3.0 - perhaps try to install from source. Let me know if this help, or else please list your environment.
Thanks, we are glad that you like our work.
Amalie

@Lunde89
Copy link

Lunde89 commented Aug 31, 2020

Downgrading Transformers to 2.3.0 worked for me. I'd assume you're running into the same issue.

@mathiasGM
Copy link
Author

@AmaliePauli, @Lunde89: Downgrading to Transformers == 2.3.0 solved it!
Thank you very much!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants