Skip to content

Instantly share code, notes, and snippets.

@shgidi
Created May 24, 2017 12:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save shgidi/08d131f2f2b46ec32ca5165a9ff093cc to your computer and use it in GitHub Desktop.
Save shgidi/08d131f2f2b46ec32ca5165a9ff093cc to your computer and use it in GitHub Desktop.
from keras.models import model_from_json
def save_keras_model(model,path):
model_json = model.to_json()
with open(path+"json", "w") as json_file:
json_file.write(model_json)
model.save_weights(path+'.hdf5')
def load_keras_model(path):
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(path+'hdf5')
return loaded_model
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment