Hello there,
I am facing a rather annoying issue. I fine-tuned a Bert model for classification and saved the resulting model to disk. However, I am unable to subsequently load the model.
This is essentially what I do:
tokenizer = AutoTokenizer.from_pretrained('C:\\Users\\bert-sentiment')
#tokenize text...
model = TFAutoModelForSequenceClassification.from_pretrained('C:\\Users\\bert-sentiment',
num_labels =3,
ignore_mismatched_sizes = True)
#fine tune model...
model.fit()
model.save_pretrained('C:\\Users\\mydir')
mydir contains two files tf_model.h5
and config.json
. However, when I tried to load the model by simply running
mymodel = TFAutoModelForSequenceClassification.from_pretrained("C:\\Users\\mydir")
I get the error
OSError: Unable to load weights from h5 file. If you tried to load a TF 2.0 model from a PyTorch checkpoint, please set from_pt=True.
do you know what the issue could be?
Thanks!