Cannot load a saved (fine-tuned) model?
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 filestf_model.h5andconfig.json. However, when I tried to load the model by simply runningmymodel = TFAutoModelForSequenceClassification.from_pretrained("C:\\Users\\mydir")I get the errorOSError: 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!
2021-08-18T13:25:11Z
Strange bug. I re-generated the saved models and then loading worked fine. Perhaps some corruption at saving time?