-
Notifications
You must be signed in to change notification settings - Fork 30k
Description
🐛 Bug
Model I am using (Bert, XLNet....): ALBERT
Language I am using the model on (English, Chinese....): English
The problem arise when using:
- the official example scripts: (give details)
- my own modified scripts: (give details)
import tensorflow as tf
from transformers import *
#Download AlbertMaskedLM model
model = TFAlbertForMaskedLM.from_pretrained('albert-large-v2')
The tasks I am working on is:
- an official GLUE/SQUaD task: (give the name)
- my own task or dataset: (give details) Initial validation
To Reproduce
Steps to reproduce the behavior:
import tensorflow as tf
from transformers import *
#Download AlbertMaskedLM model
model = TFAlbertForMaskedLM.from_pretrained('albert-large-v2')
1.
2.
3.
The code throws an error as follows :
100%|██████████| 484/484 [00:00<00:00, 271069.99B/s]
100%|██████████| 87059544/87059544 [00:03<00:00, 28448930.07B/s]
ValueError Traceback (most recent call last)
in ()
----> 1 model = TFAlbertForMaskedLM.from_pretrained('albert-large-v2')
3 frames
/usr/local/lib/python3.6/dist-packages/transformers/modeling_tf_utils.py in from_pretrained(cls, pretrained_model_name_or_path, *model_args, **kwargs)
287 # 'by_name' allow us to do transfer learning by skipping/adding layers
288 # see https://github.com/tensorflow/tensorflow/blob/00fad90125b18b80fe054de1055770cfb8fe4ba3/tensorflow/python/keras/engine/network.py#L1339-L1357
--> 289 model.load_weights(resolved_archive_file, by_name=True)
290
291 ret = model(model.dummy_inputs, training=False) # Make sure restore ops are run
/usr/local/lib/python3.6/dist-packages/tensorflow_core/python/keras/engine/training.py in load_weights(self, filepath, by_name)
179 raise ValueError('Load weights is not yet supported with TPUStrategy '
180 'with steps_per_run greater than 1.')
--> 181 return super(Model, self).load_weights(filepath, by_name)
182
183 @trackable.no_automatic_dependency_tracking
/usr/local/lib/python3.6/dist-packages/tensorflow_core/python/keras/engine/network.py in load_weights(self, filepath, by_name)
1173 f = f['model_weights']
1174 if by_name:
-> 1175 saving.load_weights_from_hdf5_group_by_name(f, self.layers)
1176 else:
1177 saving.load_weights_from_hdf5_group(f, self.layers)
/usr/local/lib/python3.6/dist-packages/tensorflow_core/python/keras/saving/hdf5_format.py in load_weights_from_hdf5_group_by_name(f, layers)
749 '") expects ' + str(len(symbolic_weights)) +
750 ' weight(s), but the saved weights' + ' have ' +
--> 751 str(len(weight_values)) + ' element(s).')
752 # Set values.
753 for i in range(len(weight_values)):
ValueError: Layer #1 (named "predictions") expects 11 weight(s), but the saved weights have 10 element(s).
Expected behavior
TFAlbertMaskedLM model can not be loaded from pre-trained
Environment
- OS: Linux (Colab)
- Python version: 3.6
- PyTorch version: Tensorflow 2.0
- PyTorch Transformers version (or branch):
- Using GPU ? Yes
- Distributed of parallel setup ?
- Any other relevant information: