RuntimeError: Error(s) in loading state_dict for BertModel:
## ❓ Questions & Help

<!-- A clear and concise description of the question. -->
Hello, I need to use "py torch_model.bin" in a model. I used your "convert_bert_original_tf_checkpoint_to_pytorch.py" to generate bin file, but I used "model_bert.load_state_dict (torch.load (init_checkpoint, map_location='cpu') to load it in my code, except for the following mistakes:

Traceback (most recent call last):
File "train.py", line 579, in <module>
Model, model_bert, tokenizer, bert_config = get_models (args, BERT_PT_PATH)
File "train.py", line 157, in get_models
Args.no_pretraining)
File "train.py", line 125, in get_bert
Model_bert. load_state_dict (torch. load (init_checkpoint, map_location='cpu'))
File "/ home/ubuntu/anaconda3/lib/python 3.7/site-packages/torch/nn/modules/module.py", line 777, in load_state_dict
Self. class. Name, "n T. join (error_msgs)"
Runtime Error: Error (s) in loading state_dict for BertModel:
Missing key (s) in state_dict: "embeddings. word_embeddings. weight", "embeddings. position_embeddings. weight".
thanks
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
<|||||>try:
device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
model_path = None
model = my_model.load_state_dict(torch.load(model_path, map_location=device))