model_json = model.to_json() with open(file_name + ".json", "w") as json_file: json_file.write(model_json) model.save_weights(file_name + '.h5')