-
Notifications
You must be signed in to change notification settings - Fork 34
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
RuntimeError: Error(s) in loading state_dict for BertForSequenceClassification #57
Comments
Hi Lunde89, |
Hi Amalie, I might have mis-typed in the original comment. Sorry about that. At least, i'm using 0.0.9 now - and it produces the same error. |
Alright, what about the transformes version? You also need this package for it to run. It is tested with transformers==2.3.0. ? |
Hi Amalie, I figured out the issue The problem is that the version you get from PyPi isn't the same as the one on this repository. After i installed from source, everything works like a charm! 👍 |
Just to +1 this comment I have had the exact same problem. Seems like an update of the PyPi is needed. A simple fix:
Notice that: (update) from danlp.models import load_bert_tone_model
classifier = load_bert_tone_model()
classifier.predict('Jeg tror alligvel, det bliver godt') # works
classifier.predict_proba('Analysen viser, at økonomien bliver forfærdelig dårlig')
Looking into the class using
notably not way to extract probability. |
Hi all, I am now facing the same issue. I have ensured all my versions are as in the comment above. |
So @kirajen please try updating to the latest version. You can do this using:
|
Full error message:
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]).
Trying to run the following code:
from danlp.models import load_bert_tone_model
classifier = load_bert_tone_model()
Using:
Torch 1.6+cpu
Python 3.7.4
daNLP 0.0.4
The text was updated successfully, but these errors were encountered: