model_json = model.to_json()withopen("model.json", "w")as json_file: json_file.write(model_json)# serialize weights to HDF5model.save_weights("model.h5")print("Saved model to disk")
Load model
# load json and create modeljson_file =open('model.json', 'r')loaded_model_json = json_file.read()json_file.close()loaded_model =model_from_json(loaded_model_json)# load weights into new modelloaded_model.load_weights("model.h5")print("Loaded model from disk")