def predict(self, Ximg, yimg): if self.verbose: print('[AttentionTrend] Predicting') model = keras.attention_models.load_model(self.output_directory + 'best_model.h5') model_metrics, conf_mat, y_true, y_pred = predict_model_deep_learning(model, Ximg, yimg, self.output_directory) save_logs(self.output_directory, self.hist, y_pred, y_true, self.duration) keras.backend.clear_session() if self.verbose: print('[AttentionTrend] Prediction done!') return model_metrics, conf_mat
def predict(self, Ximg, yimg): if self.verbose: print('[' + self.classifier_name + '] Predicting') model = keras.models.load_model( self.output_directory + 'best_model.h5', custom_objects={ 'MultiHeadAttention': MultiHeadAttention, 'SeqSelfAttention': SeqSelfAttention, # 'PreProcessingLayer': PreProcessingLayer }) model_metrics, conf_mat, y_true, y_pred = predict_model_deep_learning( model, Ximg, yimg, self.output_directory) save_logs(self.output_directory, self.hist, y_pred, y_true, self.duration) keras.backend.clear_session() if self.verbose: print('[' + self.classifier_name + '] Prediction done!') return model_metrics, conf_mat
copy.deepcopy(server_part), epoch) client_part.load_state_dict(extractor_w) server_part.load_state_dict(classifer_w) if args.cifar100: test_acc1, test_acc5, test_loss = test_inference4split4cifar100( args, client_part, server_part, test_dataset) print("|---- Test Accuracy1: {:.2f}%, Test Accuracy5: {:.2f}%". format(100 * test_acc1, 100 * test_acc5)) log_obj = { 'test_acc1': "{:.2f}%".format(100 * test_acc1), 'test_acc5': "{:.2f}%".format(100 * test_acc5), 'loss': test_loss, 'epoch': epoch } else: test_acc, test_loss = test_inference4split(args, client_part, server_part, test_dataset) print("|---- Test Accuracy: {:.2f}%".format(100 * test_acc)) log_obj = { 'test_acc': "{:.2f}%".format(100 * test_acc), 'loss': test_loss, 'epoch': epoch } logs.append(log_obj) if args.cifar100: save_cifar100_logs(logs, TAG, args) else: save_logs(logs, TAG, args)