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] != ")"):
if op == 1:
return e1 + "+" + e2
elif op == 2:
- return e1 + "+" + e2
- elif op == 3:
return e1 + "*" + e2
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,