The saved trained albert-base-v2 model does not work properly
Author: 1gst
Pull request: no
Labels: name: bug

### System Info

2022-07-19 15:17:57.094050: W tensorflow/stream_executor/platform/default/dso_loader.cc:64] Could not load dynamic library 'cudart64_110.dll'; dlerror: cudart64_110.dll not found
2022-07-19 15:17:57.094178: I tensorflow/stream_executor/cuda/cudart_stub.cc:29] Ignore above cudart dlerror if you do not have a GPU set up on your machine.
WARNING:tensorflow:From C:\Users\19715\anaconda3\lib\site-packages\transformers\commands\env.py:52: is_gpu_available (from tensorflow.python.framework.test_util) is deprecated and will be removed in a future version.
Instructions for updating:
Use `tf.config.list_physical_devices('GPU')` instead.
2022-07-19 15:18:02.167646: I tensorflow/core/platform/cpu_feature_guard.cc:193] This TensorFlow binary is optimized with oneAPI Deep Neural Network Library (oneDNN) to use the following CPU instructions in performance-critical operations:  AVX AVX2
To enable them in other operations, rebuild TensorFlow with the appropriate compiler flags.
2022-07-19 15:18:02.185125: W tensorflow/stream_executor/platform/default/dso_loader.cc:64] Could not load dynamic library 'cudart64_110.dll'; dlerror: cudart64_110.dll not found
2022-07-19 15:18:02.187022: W tensorflow/stream_executor/platform/default/dso_loader.cc:64] Could not load dynamic library 'cublas64_11.dll'; dlerror: cublas64_11.dll not found
2022-07-19 15:18:02.188373: W tensorflow/stream_executor/platform/default/dso_loader.cc:64] Could not load dynamic library 'cublasLt64_11.dll'; dlerror: cublasLt64_11.dll not found
2022-07-19 15:18:02.189480: W tensorflow/stream_executor/platform/default/dso_loader.cc:64] Could not load dynamic library 'cusolver64_11.dll'; dlerror: cusolver64_11.dll not found
2022-07-19 15:18:02.190403: W tensorflow/stream_executor/platform/default/dso_loader.cc:64] Could not load dynamic library 'cusparse64_11.dll'; dlerror: cusparse64_11.dll not found
2022-07-19 15:18:02.191308: W tensorflow/stream_executor/platform/default/dso_loader.cc:64] Could not load dynamic library 'cudnn64_8.dll'; dlerror: cudnn64_8.dll not found
2022-07-19 15:18:02.191460: W tensorflow/core/common_runtime/gpu/gpu_device.cc:1850] Cannot dlopen some GPU libraries. Please make sure the missing libraries mentioned above are installed properly if you would like to use GPU. Follow the guide at https://www.tensorflow.org/install/gpu for how to download and setup the required libraries for your platform.
Skipping registering GPU devices...

Copy-and-paste the text below in your GitHub issue and FILL OUT the two last points.

- `transformers` version: 4.20.1
- Platform: Windows-10-10.0.22000-SP0
- Python version: 3.9.7
- Huggingface_hub version: 0.6.0
- PyTorch version (GPU?): 1.10.2+cu102 (True)
- Tensorflow version (GPU?): 2.9.0 (False)
- Flax version (CPU?/GPU?/TPU?): not installed (NA)
- Jax version: not installed
- JaxLib version: not installed
- Using GPU in script?: <fill in>
- Using distributed or parallel set-up in script?: <fill in>

### Who can help?

@vanpelt @arfon @pvl @xeb @LysandreJik

### Information

- [ ] The official example scripts
- [x] My own modified scripts

### Tasks

- [ ] An officially supported task in the `examples` folder (such as GLUE/SQuAD, ...)
- [x] My own task or dataset (give details below)

### Reproduction

The complete code of the project can be found in the following link 
https://github.com/1gst/CCAC2022/tree/master
introduction:
 1.models folder is the base model, best_model folder is the model saved after training, the net.py under the models are defined for themselves the network model
2.main function of the tasker.train(best_ model=False, use_fgm=False), best_model control whether to load the best model saved, True is to load the best model, otherwise load base model 
3.tasker.print_model() is to print the model parameters, inside this function you can modify the file name, and the path to load the model, self.best_config_path and self.best_model_ Path is the path of the optimal model, self.config_path and self.model_path the path of the base model 
4.To change the model, you need to change the model parameter of the __init__() self.init_path in the Tasker Class (model="albert-base-v2") 

Problem: 
The problem I have is, In the process of using the albert-base-v2 model, I load the albert-base-v2 base model for training, after the training, use the trainer.save_model () to save the optimal model in the training process (saved in the best_model), the saved model can be predicted normally, the saved model I loaded again for training, the model will not be trained, the f1 value will always be 0, and the prediction will be invalid after interrupting the training. And the saved model each time it prints its parameters are different, the same code, if you use the roberta model will not happen, I think it may be a problem with the model saving, or a problem with the model loading, but I have modified, always not, please help me.

### Expected behavior

The expectation is to use the albert-base-v2 model for training, the end of the training to save the best model, and then load the model for training, training will not be invalid, but also able to predict normally, and each time the printed out parameters should be the same, loading the model will not warn that the internal encoder and other parameter weights inside the albert-base-v2 model are not initialized

Comments:
This issue has been automatically marked as stale because it has not had recent activity. If you think this still needs to be addressed please comment on this thread.

Please note that issues that do not follow the [contributing guidelines](https://github.com/huggingface/transformers/blob/main/CONTRIBUTING.md) are likely to be ignored.