Failed to Import transformers.models
Hello!I need some help to fix my “RunTimeError” message.The code used:from transformers import TFAutoModelcheckpoint=“distilbert-base-uncased-finetuned-sst-2-english”model=TFAutoModel.from_pretrained(checkpoint)And the long error messageRuntimeError: Failed to import transformers.models.distilbert.modeling_tf_distilbert because of the following error (look up to see its traceback):No module named ‘keras.saving.hdf5_format’I cant see where I have done something wrong, it seems more there is something wrong with the model?
2023-06-15T07:55:13Z
Henrkkn:No module named ‘keras.saving.hdf5_format’@HenrkknHave you tried updating TensorFlow?pip install -U tensorflow==2.10
2023-06-15T09:35:14Z
After installed the Tensorflow as mentioned, I now receive a new RunTime Error:"RuntimeError: Failed to import transformers.models.distilbert.modeling_tf_distilbert because of the following error (look up to see its traceback):Duplicate registrations for type ‘experimentalOptimizer’ "
2023-09-15T03:32:51Z
Rolling back to 2.10 results out with google protobuf disconnect error.
2024-03-19T18:55:59Z
@chem1I tried this:from transformers import TFAutoModelcheckpoint = ‘distilbert-base-uncased-finetuned-sst-2-english’model = TFAutoModel.from_pretrained(checkpoint)I am getting this:RuntimeError: Failed to import transformers.models.distilbert.modeling_tf_distilbert because of the following error (look up to see its traceback):module ‘tensorflow._api.v2.compat.v2.internal’ has no attribute ‘register_load_context_function’I am using latest version of everything. More specifically, transformers = 4.38.2, tensorflow = 2.16, keras = 3.1.1, protobuf = 5.26.0
2024-03-20T00:25:40Z
Maybe the issue is because of keras 3 which is the default since tf 2.16. suggest trying out with lower tf version.