def make_environment(env_name: str, seed: int = None) -> gym.Env: """ Initialise gym environment Args: env_name: environment name or tag seed: value to seed the environment RNG for reproducibility Returns: gym environment """ env = make_environment(env_name) if seed: env.seed(seed) return env
def setUp(self) -> None: self.state = torch.rand(32, 4, 84, 84) self.next_state = torch.rand(32, 4, 84, 84) self.action = torch.ones([32]) self.reward = torch.ones([32]) self.done = torch.zeros([32]).long() self.batch = (self.state, self.action, self.reward, self.done, self.next_state) self.env = make_environment("PongNoFrameskip-v4") self.obs_shape = self.env.observation_space.shape self.n_actions = self.env.action_space.n self.net = CNN(self.obs_shape, self.n_actions) self.target_net = CNN(self.obs_shape, self.n_actions)