def process_state(self, state): x = torch.tensor(data=state, dtype=torch.float, device=device) # Change color channel position from (210, 160, 3) to (1, 210, 160) x = x.permute(2, 0, 1) # From color to gray x = rgb_to_grayscale(x) # Resize from (1, 210, 160) to (1, 80, 80) x = Resize([80, 80])(x) # Reduce size 1 dimension x = x.squeeze(0) return x
def process_state(self, state): x = torch.tensor(data=state, dtype=torch.float, device=self.device) # Change color channel position from (210, 160, 3) to (1, 210, 160) x = x.permute(2, 0, 1) # From color to gray x = rgb_to_grayscale(x) # Resize from (1, 210, 160) to (1, 84, 84) x = Resize([RESIZE, RESIZE])(x) # Reduce size 1 dimension x = x.squeeze(0) # Normalize input 0 to i x = x.div(255) return x.detach().cpu().numpy()