0

After saving a Keras model, where is it saved? Is it saved locally? The below code is saving a model.

from keras.models import load_model

model.save('my_model.h5')  # creates a HDF5 file 'my_model.h5
model = load_model('my_model.h5')

After saving the model can I use the load model again in another jupyter ipynb file?

Innat
  • 16,113
  • 6
  • 53
  • 101
Antony Joy
  • 301
  • 3
  • 15

1 Answers1

1

When we do model.save, it will save model architecture and weight at the same time. It will save as .h5 locally and we can load it in another environment (local notebook, kaggle notebook, colab, GCP, etc). Using load_model will load fully model (arch + weight).

Please, read the official blog, you will find plenty of examples. https://www.tensorflow.org/guide/keras/save_and_serialize

Innat
  • 16,113
  • 6
  • 53
  • 101
  • 1
    Glad that help. But please do some starting research first of your query. -) Your question would be more robust if you were asking about different approaches to save the `tf` model. Hope the above official blog post may solve many of your queries. Please after reading the blog, feel free to ask if you don't understand any stuff or encounter any issues. – Innat Mar 19 '21 at 13:26
  • @ M.innat.... would you be kind enough to look through a particular question...I am sitting for a day with model...https://stackoverflow.com/questions/66720811/how-to-build-a-cnn-model-for-mnist-fashion-and-test-it-with-a-another-set-of-ima – Antony Joy Mar 20 '21 at 12:10
  • That question, isn't it solved?. You marked some answers! – Innat Mar 20 '21 at 12:14
  • I created the model, but it is not showing a true answer... I needed it to predict it as trouser, whereas it showed sandals number 5 – Antony Joy Mar 20 '21 at 12:27
  • Please be kind enough to look into it :) – Antony Joy Mar 20 '21 at 12:37