def train_one_epoch(self):
    '\n        One episode of training; it samples an action, observe next screen and optimize the model once\n        :return:\n        '
    episode_duration = 0
    prev_frame = self.cartpole.get_screen(self.env)
    curr_frame = self.cartpole.get_screen(self.env)
    curr_state = (curr_frame - prev_frame)
    while 1:
        episode_duration += 1
        action = self.select_action(curr_state)
        (_, reward, done, _) = self.env.step(action.item())
        if self.cuda:
            reward = torch.Tensor([reward]).to(self.device)
        else:
            reward = torch.Tensor([reward]).to(self.device)
        prev_frame = curr_frame
        curr_frame = self.cartpole.get_screen(self.env)
        if done:
            next_state = None
        else:
            next_state = (curr_frame - prev_frame)
        self.memory.push_transition(curr_state, action, next_state, reward)
        curr_state = next_state
        curr_loss = self.optimize_policy_model()
        if (curr_loss is not None):
            if self.cuda:
                curr_loss = curr_loss.cpu()
            self.summary_writer.add_scalar('Temporal_Difference_Loss', curr_loss.detach().numpy(), self.current_iteration)
        if done:
            break
    self.summary_writer.add_scalar('Training_Episode_Duration', episode_duration, self.current_episode)
One episode of training; it samples an action, observe next screen and optimize the model once
:return:
def train_one_epoch(self):
    '\n        One episode of training; it samples an action, observe next screen and optimize the model once\n        :return:\n        '
    episode_duration = 0
    prev_frame = self.cartpole.get_screen(self.env)
    curr_frame = self.cartpole.get_screen(self.env)
    curr_state = (curr_frame - prev_frame)
    while 1:
        episode_duration += 1
        action = self.select_action(curr_state)
        (_, reward, done, _) = self.env.step(action.item())
        if self.cuda:
            reward = torch.Tensor([reward]).to(self.device)
        else:
            reward = torch.Tensor([reward]).to(self.device)
        prev_frame = curr_frame
        curr_frame = self.cartpole.get_screen(self.env)
        if done:
            next_state = None
        else:
            next_state = (curr_frame - prev_frame)
        self.memory.push_transition(curr_state, action, next_state, reward)
        curr_state = next_state
        curr_loss = self.optimize_policy_model()
        if (curr_loss is not None):
            if self.cuda:
                curr_loss = curr_loss.cpu()
            self.summary_writer.add_scalar('Temporal_Difference_Loss', curr_loss.detach().numpy(), self.current_iteration)
        if done:
            break
    self.summary_writer.add_scalar('Training_Episode_Duration', episode_duration, self.current_episode)