X-Git-Url: https://fleuret.org/cgi-bin/gitweb/gitweb.cgi?a=blobdiff_plain;f=tasks.py;h=56c2b0fd3f8f5b54eb80116ed96aa20581044279;hb=62ad2378c60cdf322c0111279bd45fbef8365fc2;hp=829eb240fe3be6e21cdd1b503dbce510af24034e;hpb=e39282eef52a7f5ab6654b999009127569b1b599;p=picoclvr.git diff --git a/tasks.py b/tasks.py index 829eb24..56c2b0f 100755 --- a/tasks.py +++ b/tasks.py @@ -1874,6 +1874,7 @@ class Escape(Task): height, width, T, + nb_walls, logger=None, device=torch.device("cpu"), ): @@ -1885,7 +1886,7 @@ class Escape(Task): self.width = width states, actions, rewards = escape.generate_episodes( - nb_train_samples + nb_test_samples, height, width, T + nb_train_samples + nb_test_samples, height, width, T, nb_walls ) seq = escape.episodes2seq(states, actions, rewards, lookahead_delta=T) # seq = seq[:, seq.size(1) // 3 : 2 * seq.size(1) // 3] @@ -1912,7 +1913,7 @@ class Escape(Task): def thinking_autoregression( self, n_epoch, model, result_dir, logger, deterministic_synthesis, nmax=1000 ): - result = self.test_input[:100].clone() + result = self.test_input[:250].clone() t = torch.arange(result.size(1), device=result.device)[None, :] state_len = self.height * self.width @@ -1936,9 +1937,9 @@ class Escape(Task): for u in tqdm.tqdm( range(it_len, result.size(1) - it_len + 1, it_len), desc="thinking" ): - # Put the lookahead reward to -1 for the current iteration, - # sample the next state - s = -1 + # Put the lookahead reward to either 0 or -1 for the + # current iteration, sample the next state + s = -1 # (torch.rand(result.size(0), device = result.device) < 0.2).long() result[:, u - 1] = s + 1 + escape.first_lookahead_rewards_code ar_mask = (t >= u).long() * (t < u + state_len).long() ar(result, ar_mask) @@ -1954,7 +1955,7 @@ class Escape(Task): for v in range(0, u, it_len): # Extract the rewards r = result[:, range(v + state_len + 1 + it_len, u + it_len - 1, it_len)] - r = r - escape.first_lookahead_rewards_code - 1 + r = r - escape.first_rewards_code - 1 a = r.min(dim=1).values b = r.max(dim=1).values s = (a < 0).long() * a + (a >= 0).long() * b