"rpl": {
"nb_epochs": 40,
"batch_size": 25,
- "nb_train_samples": 1000000,
+ "nb_train_samples": 100000,
"nb_test_samples": 10000,
},
"world": {
######################################################################
-def generate(nb_values=3, max_input=9, prog_len=6, nb_runs=5):
- prog_len = 1 + torch.randint(prog_len - 1, (1,)).item()
+def generate(nb_starting_values=3, max_input=9, prog_len=6, nb_runs=5):
+ prog_len = (1 + torch.randint(2 * prog_len, (1,))).clamp(max=prog_len).item()
prog = [rpl_ops[k] for k in torch.randint(len(rpl_ops), (prog_len,))]
result = []
for _ in range(nb_runs):
- stack = [x.item() for x in torch.randint(max_input + 1, (nb_values,))]
+ stack = [x.item() for x in torch.randint(max_input + 1, (nb_starting_values,))]
result_stack = rpl_exec(prog, stack)
result = result + ["<input>"] + stack + ["<output>"] + result_stack
nb_train_samples,
nb_test_samples,
batch_size,
+ nb_starting_values=3,
+ max_input=9,
+ prog_len=6,
+ nb_runs=5,
device=torch.device("cpu"),
):
super().__init__()
self.device = device
train_sequences = [
- rpl.generate()
+ rpl.generate(
+ nb_starting_values=nb_starting_values,
+ max_input=max_input,
+ prog_len=prog_len,
+ nb_runs=nb_runs,
+ )
for _ in tqdm.tqdm(range(nb_train_samples), desc="train-data")
]
+
test_sequences = [
- rpl.generate() for _ in tqdm.tqdm(range(nb_test_samples), desc="test-data")
+ rpl.generate(
+ nb_starting_values=nb_starting_values,
+ max_input=max_input,
+ prog_len=prog_len,
+ nb_runs=nb_runs,
+ )
+ for _ in tqdm.tqdm(range(nb_test_samples), desc="test-data")
]
symbols = list(
_, _, gt_prog, _ = rpl.compute_nb_errors(gt_seq)
gt_prog = " ".join([str(x) for x in gt_prog])
prog = " ".join([str(x) for x in prog])
- logger(f"GROUND-TRUTH PROG [{gt_prog}] PREDICTED PROG [{prog}]")
+ logger(f"PROG [{gt_prog}] PREDICTED [{prog}]")
for start_stack, target_stack, result_stack, correct in stacks:
comment = " CORRECT" if correct else ""
start_stack = " ".join([str(x) for x in start_stack])
target_stack = " ".join([str(x) for x in target_stack])
result_stack = " ".join([str(x) for x in result_stack])
logger(
- f" [{start_stack}] -> [{result_stack}] TARGET [{target_stack}]{comment}"
+ f" [{start_stack}] -> [{target_stack}] PREDICTED [{result_stack}]{comment}"
)
nb_to_log -= 1