print("-----=-=-=- checkpoint_loaded=-=-=--------------") try: history = model.fit(X_train, y_train, batch_size=batch_size, epochs=epochs, callbacks=[checkpoint, callbacks], validation_data=(X_valid, y_valid), verbose=1) except Exception as e: runtimeInvalidInfo = { 'calculationType': 'exception', 'info': str(format(e)) } response = http_client.modelTrain(str(runtimeInvalidInfo)) print("un expected error").format(e) # 指标返回 call_res = call_back_metrics(X_train, X_valid, X_test, y_train, y_valid, y_test, model, local_img_path) # 回调,向服务端发送评估指标 try: response = http_client.modelTrain(str(call_res)) except Exception as e: print("un expected error").format(e) # http_client.call("sayHelloWorld",call_res) model.save(os.path.join(save_dir, model_name) + '.h5', overwrite=True)
# Fit the model if os.path.exists(filepath): print('now loadding the weights file ', filepath) model.load_weights(filepath) # 若成功加载前面保存的参数,输出下列信息 print("-----=-=-=- checkpoint_loaded=-=-=--------------") history = model.fit( X_train, y_train, batch_size=batch_size, epochs=epochs, # callbacks=callbacks, callbacks=[cb], validation_data=(X_valid, y_valid), verbose=1) # 指标返回 call_res = call_back_metrics(X_train, X_valid, X_test, y_train, y_valid, y_test, model) # 回调,向服务端发送评估指标 response = http_client.modelTrain(str(call_res)) # http_client.call("sayHelloWorld",call_res) model.save(os.path.join(save_dir, model_name) + '.h5', overwrite=True) print('\r\nmodel has been saved in ', os.path.join(save_dir, model_name) + '.h5')