projects
/
picoclvr.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (from parent 1:
f38523d
)
Update.
author
François Fleuret
<francois@fleuret.org>
Thu, 20 Jul 2023 08:06:06 +0000
(10:06 +0200)
committer
François Fleuret
<francois@fleuret.org>
Thu, 20 Jul 2023 08:06:06 +0000
(10:06 +0200)
tasks.py
patch
|
blob
|
history
diff --git
a/tasks.py
b/tasks.py
index
0fac0a7
..
a97ec2e
100755
(executable)
--- 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()
# --------------------------------------------------------------------
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
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
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)
if nb_to_log > 0:
gt_seq = [self.id2token[i.item()] for i in x]
_, _, gt_prog, _ = rpl.compute_nb_errors(gt_seq)