From 4540ede418ea744e50e0ff0b3a90785015da962b Mon Sep 17 00:00:00 2001 From: =?utf8?q?Fran=C3=A7ois=20Fleuret?= Date: Thu, 20 Jul 2023 10:06:06 +0200 Subject: [PATCH] Update. --- tasks.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tasks.py b/tasks.py index 0fac0a7..a97ec2e 100755 --- a/tasks.py +++ b/tasks.py @@ -1179,9 +1179,9 @@ class RPL(Task): # -------------------------------------------------------------------- def compute_nb_errors_output(input, nb_to_log=0): result = input.clone() - k = torch.arange(result.size(1), device=result.device)[None,:] - last_output_idx = ((result == self.t_output) * k).max(dim=1,keep_dim=True) - first_prog_idx = ((result == self.t_prog) * k).min(dim=1,keep_dim=True) + k = torch.arange(result.size(1), device=result.device)[None, :] + last_output_idx = ((result == self.t_output) * k).max(dim=1, keep_dim=True) + first_prog_idx = ((result == self.t_prog) * k).min(dim=1, keep_dim=True) ar_mask = (k > last_output_idx).long() * (k < first_prog_idx) result = (1 - ar_mask) * result + ar_mask * self.t_nul @@ -1198,7 +1198,7 @@ class RPL(Task): for x, y in zip(input, result): seq = [self.id2token[i.item()] for i in y] sum_nb_total += 1 - sum_nb_errors += 0 if (x-y).abs().max() == 0 else 1 + sum_nb_errors += 0 if (x - y).abs().max() == 0 else 1 if nb_to_log > 0: gt_seq = [self.id2token[i.item()] for i in x] _, _, gt_prog, _ = rpl.compute_nb_errors(gt_seq) -- 2.39.5