keras model saving

Your model is working ... it looks good - and you want to move to the prediction/use phase

But how to save and re-use it

Saving

This is an example stub

# serialize model to JSON
model_json = model.to_json()
with open("ml102_model.json", "w") as json_file:
    json_file.write(model_json)
# serialize weights to HDF5
model.save_weights("ml102_weights.h5")
print("Saved model to disk")

Loading

You now develop a new piece of code that uses the Model and the Weights, this is an example stub

import numpy as np
from keras.preprocessing import image
from keras.models import model_from_json
# load json and create

json_file = open('model.json', 'r')
loaded_model_json = json_file.read()
json_file.close()
classifier = model_from_json(loaded_model_json)
# load weights into new model
classifier.load_weights("model.h5")
print("Loaded model from disk")