taneemishere's picture
added flagged functionaly, removed printing model summary
5ee6650
raw
history blame contribute delete
969 Bytes
__author__ = 'Taneem Jan, taneemishere.github.io'
from keras.models import model_from_json
class AModel:
def __init__(self, input_shape, output_size, output_path):
self.model = None
self.input_shape = input_shape
self.output_size = output_size
self.output_path = output_path
self.name = ""
def save(self):
model_json = self.model.to_json()
with open("{}/{}.json".format(self.output_path, self.name), "w") as json_file:
json_file.write(model_json)
self.model.save_weights("{}/{}.h5".format(self.output_path, self.name))
def load(self, name=""):
output_name = self.name if name == "" else name
with open("{}/{}.json".format(self.output_path, output_name), "r") as json_file:
loaded_model_json = json_file.read()
self.model = model_from_json(loaded_model_json)
self.model.load_weights("{}/{}.h5".format(self.output_path, output_name))