Reference: https://machinelearningmastery.com/save-load-keras-deep-learning-models/
from tensorflow.keras.models import model_from_json
model_json = model.to_json()
with open("model.json", "w") as json_file: json_file.write(model_json)
model.save_weights("model.h5")
print("Saved model to disk")
Once you have saved your model in the current folder, you can load it in any location by specifying the path to the directory where you saved it.
json_file = open('model.json', 'r')
loaded_model_json = json_file.read()
json_file.close()
loaded_model = model_from_json(loaded_model_json)
loaded_model.load_weights("model.h5")
print("Loaded model from disk")
loaded_model.compile(loss='binary_crossentropy', optimizer='rmsprop', metrics=['accuracy'])
score = loaded_model.evaluate(X, Y, verbose=0)
print("%s: %.2f%%" % (loaded_model.metrics_names[1], score[1]*100))