Created
May 24, 2017 12:34
-
-
Save shgidi/08d131f2f2b46ec32ca5165a9ff093cc to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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