question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

RunTimeError: Error(s) in loading state_dict for RobertaForSequenceClassification

See original GitHub issue

I get the following error after trying to run

pip install -r requirements.txt
python -m detector.server detector-base.pt

Error:

RuntimeError: Error(s) in loading state_dict for RobertaForSequenceClassification:
        Missing key(s) in state_dict: "roberta.embeddings.position_ids".
        Unexpected key(s) in state_dict: "roberta.pooler.dense.weight", "roberta.pooler.dense.bias"

I’m not sure if there was a change between the google version of the Roberta weights or the azure version of the weights.

Thanks for the help!

Issue Analytics

  • State:open
  • Created 3 years ago
  • Comments:7

github_iconTop GitHub Comments

2reactions
greenunknowncommented, Feb 20, 2021

Thank you @jongwook ! Changing, in the requirements.txt, the transformers>=2.0.0 to transformers==2.9.1 resolved the issue.

0reactions
casheocommented, Dec 20, 2022

Same thing today image

With transformer 2.9.1.

Read more comments on GitHub >

github_iconTop Results From Across the Web

python 3.x - Error(s) in loading state_dict for ... - Stack Overflow
I am writing my code for binary classification:​​ bin RuntimeError: Error(s) in loading state_dict for RobertaForSequenceClassification: size ...
Read more >
[Example code]-Error(s) in loading state_dict for ...
I am writing my code for binary classification:​​ bin RuntimeError: Error(s) in loading state_dict for RobertaForSequenceClassification: size mismatch for ...
Read more >
Problem in loading an old sentence classification roberta ...
Hello, I created a roberta sentence classifier model last year using the transformer version 3.0.2. Currently, I am trying to upgrade the ...
Read more >
Unexpected key(s) in state_dict: “roberta.pooler.dense.weight“....
在加载已经训练好的模型时,出现问题如下:RuntimeError: Error(s) in loading state_dict for RobertaForSequenceClassification: Unexpected key(s) ...
Read more >
Renaming model checkpoints can give an error - Reddit
format( RuntimeError: Error(s) in loading state_dict for LatentDiffusion: size mismatch for model.diffusion_model.input_blocks.0.0.weight: ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found