update from v3.0.0 to v3.4.0 got an error
Author: zyh3826
Pull request: no
Labels: name: wontfix

## Environment info
<!-- You can run the command `transformers-cli env` and copy-and-paste its output below.
     Don't forget to fill out the missing fields in that output! -->


- `transformers` version: v3.4.0
- Platform: redhat
- Python version: 3.8.3 64bit
- PyTorch version (GPU?): 1.5.1
- Tensorflow version (GPU?):
- Using GPU in script?: yes
- Using distributed or parallel set-up in script?: no

### Who can help
<!-- Your issue will be replied to more quickly if you can figure out the right person to tag with @
 If you know how to use git blame, that is the easiest way, otherwise, here is a rough guide of **who to tag**.
 Please tag fewer than 3 people.
 
 albert, bert, GPT2, XLM: @LysandreJik 
 tokenizers: @mfuntowicz
 Trainer: @sgugger
 Speed and Memory Benchmarks: @patrickvonplaten
 Model Cards: @julien-c
 Translation: @sshleifer
 Summarization: @sshleifer
 TextGeneration: @TevenLeScao 
 examples/distillation: @VictorSanh
 nlp datasets: [different repo](https://github.com/huggingface/nlp)
 rust tokenizers: [different repo](https://github.com/huggingface/tokenizers)
 Text Generation: @patrickvonplaten @TevenLeScao
 blenderbot: @mariamabarham
 Bart: @sshleifer
 Marian: @sshleifer
 T5: @patrickvonplaten
 Longformer/Reformer: @patrickvonplaten
 TransfoXL/XLNet: @TevenLeScao
 RAG: @patrickvonplaten, @lhoestq
 FSTM: @stas00
 examples/seq2seq: @sshleifer
 examples/bert-loses-patience: @JetRunner
 tensorflow: @jplu
 examples/token-classification: @stefan-it
 documentation: @sgugger
 -->

## Information

Model I am using (Bert, XLNet ...):
Bert
The problem arises when using:
* [ ] the official example scripts: (give details below)
* [ ] my own modified scripts: (give details below)

The tasks I am working on is:
* [ ] an official GLUE/SQUaD task: (give the name)
* [ ] my own task or dataset: (give details below)

## To reproduce

Steps to reproduce the behavior:

yesterday i used transformers v3.0.0 trained my model and save it use 
`torch.save(model.state_dict(), config.save_path)`, 
and today i update transformers to v3.4.0, when i use 
`torch.load` 
i got this error 
![image](https://user-images.githubusercontent.com/31238754/98341317-a2be1600-2049-11eb-9672-749896b9c2a4.png)
could anybody help me!!! thx

<!-- If you have code snippets, error messages, stack traces please provide them here as well.
     Important! Use code tags to correctly format your code. See https://help.github.com/en/github/writing-on-github/creating-and-highlighting-code-blocks#syntax-highlighting
     Do not use screenshots, as they are hard to read and (more importantly) don't allow others to copy-and-paste your code.-->

## Expected behavior

<!-- A clear and concise description of what you would expect to happen. -->


Comments:
Hi! Yes, you should use the `from_pretrained` method to ensure compatibility within versions. Have you tried using that method instead? It should point to a directory containing your model file named as `pytorch_model.bin` and the configuration file of the model named as `config.json`.

> Hi! Yes, you should use the `from_pretrained` method to ensure compatibility within versions. Have you tried using that method instead? It should point to a directory containing your model file named as `pytorch_model.bin` and the configuration file of the model named as `config.json`.

Hi LysandreJik, I think you may misunderstand my problem. At the beginning of this project, I used `from_pretrained`, and when the training ended I use the `torch.save` saving the model to a .pth file(Under transformers v3.0.0). But under transformers v3.4.0, I init the model use `model = BertModel.from_pretrained(BertConfig.from_pretrained(configpath))`, then `model.load_state_dict(torch.load(modelpath)` and get this error. But under transformers v3.0.0, it's ok.

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.