How to load a SavedModel in a new Colab notebook?

Viewed 1386

I am using Google Colab. In a first notebook, I saved my model using: model.save('my_model.h5'). In the same notebook, I can see that the model is stored. Input: ls -d $PWD/* Output: /content/my_model.h5

In the same notebook, I can restore the saved model by using: model = tf.keras.models.load_model('my_model.h5')

But if I want to load the same model in a new notebook, I got an error message. Input:

from keras.models import load_model
new_model = tf.keras.models.load_model('/content/my_model.h5')

Error message:

OSError: SavedModel file does not exist at: /content/my_model.h5/{saved_model.pbtxt|saved_model.pb}

Thanks for your help,

Boris

1 Answers

Each notebook is on a different machine. You need to save it on google drive, using drive.mount("drive"). Then you can share the model across different notebooks.

Related