# Keras
def load_model():
model = keras.models.load_model(modelLoader.path)
modelLoader.update_model(model) # update model
# Pytorch
def load_model():
model = Model()
model.load_state_dict(torch.load(modelLoader.path))
device = torch.device("cuda:0" if torch.cuda.is_available() else "cpu")
model.to(device)
model.eval()
modelLoader.update_model(model) # update model
# Common
def predict(data):
model = modelLoader.get_model() # get model
config = modelLoader.get_config() # get config
...
# Common
def on_train_completed(metric, config, new_model_path):
...
modelLoader.save_model() # Save model
modelLoader.save_config(config) # Save config
...
def on_train_completed(metric, config, new_model_path):
if metric > pipelineHelper.last_metric: # if new metirc better last
pipelineHelper.update_metric(metric) # update now metric
print(pipelineHelper.metric) # show all metric e.g. [0.1, 0.2]
print(pipelineHelper.last_metric) # show last metric e.g. 0.2