From 667ef70b1f185c7bbd66d7782fbde39fff093ba9 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Fran=C3=A7ois=20Fleuret?= Date: Wed, 5 Jul 2023 08:47:03 +0200 Subject: [PATCH] Update. --- main.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/main.py b/main.py index e1f619c..15e6d99 100755 --- a/main.py +++ b/main.py @@ -1116,6 +1116,9 @@ class TaskExpr(Task): nb_total = input.size(0) nb_correct = (input == result).long().min(1).values.sum() + ####################################################################### + # Comput predicted vs. true variable values + values_input = expr.extract_results([self.seq2str(s) for s in input]) max_input = max([max(x.values()) for x in values_input]) values_result = expr.extract_results([self.seq2str(s) for s in result]) @@ -1123,9 +1126,9 @@ class TaskExpr(Task): [-1 if len(x) == 0 else max(x.values()) for x in values_result] ) - nb_missing, nb_predicted = torch.zeros(max_input + 1), torch.zeros( - max_input + 1, max_result + 1 - ) + nb_missing = torch.zeros(max_input + 1) + nb_predicted = torch.zeros(max_input + 1, max_result + 1) + for i, r in zip(values_input, values_result): for n, vi in i.items(): vr = r.get(n) @@ -1133,6 +1136,7 @@ class TaskExpr(Task): nb_missing[vi] += 1 else: nb_predicted[vi, vr] += 1 + ###################################################################### return nb_total, nb_correct -- 2.39.5