# Generating the description of the model in json
model_json = model.to_json()
# Writing model description to the file
json_file = open("mnist_model.json", "w")
json_file.write(model_json)
json_file.close()
# Storing trained weights
model.save_weights("mnist_model.h5")
from keras.models import model_from_json
# Load architecture of the model from the json
json_file = open("mnist_model.json", "r")
loaded_model_json = json_file.read()
json_file.close()
# Create the model from json description
loaded_model = model_from_json(loaded_model_json)
# Load pretrained weights
loaded_model.load_weights("mnist_model.h5")
# Compiling the model before using
loaded_model.compile(loss="categorical_crossentropy", optimizer="SGD", metrics=["accuracy"])
https://support.hdfgroup.org/products/java/hdfview/