stable-baselines icon indicating copy to clipboard operation
stable-baselines copied to clipboard

[Question] Is the objective to maximize general rewards or discounted rewards?

Open soloist96 opened this issue 7 years ago • 4 comments

This may be a general question for RL algorithms. Are they trying to optimize the episode rewards without discount or the discounted reward? When I use tensorboard to visualize the results, I found that the episode reward (without discount) goes up gradually but the discounted rewards can drop a bit. Thank you!

soloist96 avatar Aug 06 '19 16:08 soloist96

You can optimize for either-or, depending on the situation, but you more commonly see optimizing the discounted returns (including this repository). See e.g. Spinning Up RL tutorial for more info.

Miffyli avatar Aug 07 '19 20:08 Miffyli

@Miffyli Thank you for the reply. Yes, my understanding is that we are optimizing the discounted returns. However, when I try to run the PPO2 with discount factor 0.99, my episode reward goes to 60 in the end while my discounted reward is only 20. There're only 20 steps in the environment, meaning if I discount all the rewards, the least I should get 60*0.99^20 ~ 49 for the discounted reward. Could you explain the inconsistency I get from the results? Thank you.

soloist96 avatar Aug 09 '19 20:08 soloist96

If you start tracing back from PPO2 code where tensorboard logs these, you will end up to part where returns are calculated via GAE computations. I do not know if this should end up to standard returns, but it could causing this discrepancy (would be fun to dig deeper, but currently taking weekend off from bigger headaches).

Miffyli avatar Aug 09 '19 20:08 Miffyli

as @miffyli wrote, you can optimize for one or the other (setting gamma to one). In practice, most algorithms use the discounted return. SAC have a slightly different objective: it tries to maximize the entropy in addition to the discounted return.

araffin avatar Aug 23 '19 08:08 araffin