When to Add reward
@awjuliani Thanks for a good repo https://github.com/Unity-Technologies/ml-agents/blob/d6dad11c773a8598540a8896d0d48b2489b222ae/UnitySDK/Assets/ML-Agents/Examples/Walker/Scripts/WalkerAgent.cs#L143
in this code reward is added at every step but Action and observation is done at N decision step. so is this better (more acurate)than adding reward at every decision step?
The reward is only sent during the decision step. The rewards added between decisions is added up. Since we reward the Walker for its orientation speed, we cannot just add a reward at the decision step (intermediate steps count as well). I hope this helps.
@vincentpierre Thanks, I understand that case. If the reward accumulate before decision then the amount of reward exceeds 1(recommended to set as maximum value) right?doesn't this cause issues?
And if I add reward only at decision step the reward is obviously less than add every step but does this still work fine?
The limit of 1 is not a hard limit. We advise people to keep the rewards to small values. I do not think the Walker's rewards go above 1, if they do, probably not by much. Very large rewards are know to cause issues (10 or 100 would probably break something). The problem with only adding at the decision step is that the agent could be incentivized to only maximize the reward at the decision step. For instance, slow down when the reward is not added and accelerate when the reward is about the be calculated. I do not know what would happen, I think you could try it and see if it fits your case.
@vincentpierre Thanks. Then Does ppo net work consider step size of action not only at decision step that accumulates reward and states?
PPO only receives a signal when a decision is requested, not at every step. The reward ppo receives at each decision is the sum of the rewards that were added at each step between decisions.
decision request
step - AddReward(0.2f)
step - AddReward(0.2f)
step - AddReward(0.2f)
decision request -> PPO receives 0.6 reward
step - AddReward(0.2f)
step - AddReward(0.2f)
step - AddReward(0.2f)
decision request -> PPO receives 0.6 reward
...
@vincentpierre Got it. Thanks a lot
One question depending the reward adding. I added a reward of -0.001 as exploration incentive. But somehow this seems to be not accepted as a reward, because if you write the CumultativeReward into a text field it doesn't change with such a low reward. With hundredths it's working but not with a thousandths, is this correct?
The reward is using floating points, rewards of a thousandths should work. It might be truncation in the to string method (try to multiply by 1000 and see if this number is changing) You could also be overwriting your reward with a SetReward call.
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.