Update.
authorFrançois Fleuret <francois@fleuret.org>
Sat, 8 Jul 2023 10:15:56 +0000 (12:15 +0200)
committerFrançois Fleuret <francois@fleuret.org>
Sat, 8 Jul 2023 10:15:56 +0000 (12:15 +0200)
expr.py
tasks.py

diff --git a/expr.py b/expr.py
index 818360b..e539fcb 100755 (executable)
--- a/expr.py
+++ b/expr.py
@@ -24,7 +24,7 @@ def random_expr(variables, budget):
         else:
             return str(torch.randint(10, (1,)).item())
     else:
-        op = torch.randint(4, (1,)).item()
+        op = torch.randint(3, (1,)).item()
         if op == 0:
             e = random_expr(variables, budget - 2)
             if ("+" in e or "-" in e or "*" in e) and (e[0] != "(" or e[-1] != ")"):
@@ -38,8 +38,6 @@ def random_expr(variables, budget):
             if op == 1:
                 return e1 + "+" + e2
             elif op == 2:
-                return e1 + "+" + e2
-            elif op == 3:
                 return e1 + "*" + e2
 
 
index b277b96..463d94c 100755 (executable)
--- a/tasks.py
+++ b/tasks.py
@@ -937,11 +937,12 @@ class Expr(Task):
                     input = self.tensorize(sequences)
 
             result = input.clone()
-            ar_mask = (result == self.space).long().cumsum(dim=1).clamp(max=1)
+            s = (result == self.space).long()
+            ar_mask = (s.cumsum(dim=1) - s).clamp(min=0, max=1)
             result = (1 - ar_mask) * result + ar_mask * self.filler
 
-            for n in range(result.size(0)):
-            # logger(f"test_before {self.seq2str(result[n])}")
+            for n in range(result.size(0)):
+                logger(f"test_before {self.seq2str(result[n])}")
 
             masked_inplace_autoregression(
                 model,