2

I have a problem loading a pre-trained model written as an .h5 file in my TensorFlow-GPU environment. (LINK to the model associated as its weights)

To begin, I loaded this very model by means of keras.models.load_model(). An error popped up as illustrated in the following figure. enter image description here

Then I used tensorflow.keras.models.load_model() instead. Still, I had the same problem, failing to load this model to my program. enter image description here

Environment:

  • TensorFlow-GPU: version 2.3.1
  • Keras: version 2.4.3
  • Python: version 3.8.5
  • IDE: Visual Studio 2019

Any idea would be appreciated. Thanks a lot!

  • remove line 7 and try again. Don't mix old keras with new keras. And still, it occurs try this in another environment eg colab/kaggle. If still exist, I think then there is something wrong with your h5 file. – Innat Nov 29 '20 at 04:30
  • I removed "import keras" and used tf.keras.models.load_model() to load it instead. But still, the same error showed up. – Friedrich_Cheng94 Nov 29 '20 at 05:18
  • Is it possibly because I ran this code using a GPU instead of a CPU? – Friedrich_Cheng94 Nov 29 '20 at 05:31
  • Hi, @M.Innat. I resolved the problem by re-creating another virtual environment (tensorflow-gpu 2.3.0). And still, I used keras.models.load_model(). To my surprise, it finally loaded this pre-trained model successfully. Thank you for the comment! – Friedrich_Cheng94 Nov 29 '20 at 05:58

0 Answers0