concept discount reward in category deep learning

appears as: discounted rewards, discounted rewards
Deep Reinforcement Learning in Action

This is an excerpt from Manning's book Deep Reinforcement Learning in Action.

  • A state-value is the expected sum of discounted rewards for a state given we follow some policy. If a state has a high state-value, that means that starting from this state will likely lead to high rewards.
  • Actions temporally more distant from the received reward should be weighted less than actions closer. If we win a game of Gridworld, the sequence of discounted rewards from the start to the terminal state might look something like [0.970, 0.980, 0.99, 1.0]. The last action led to the winning state of +1, and it is not discounted at all. The previous action is assigned a scaled reward by multiplying the terminal reward with the γt–1 discount factor, which we’ve set to 0.99.

    Listing 4.6. Computing the discounted rewards
    def discount_rewards(rewards, gamma=0.99):
        lenr = len(rewards)
        disc_return = torch.pow(gamma,torch.arange(lenr).float()) * rewards   #1
        disc_return /= disc_return.max()                                      #2
        return disc_return

    Here we define a special function to compute the discounted rewards given an array of rewards that would look like [50,49,48,47,...] if the episode lasted 50 time steps. It essentially turns this linear sequence of rewards into an exponentially decaying sequence of rewards (e.g., [50.0000, 48.5100, 47.0448, 45.6041, ...]), and then it divides by the maximum value to bound the values in the interval [0,1].

  • The return is the sum of discounted rewards in an episode of the environment.