My RL project has all positive continuous rewards for every step and the goal is to have the maximum cumulative reward (episodic reward). The problem is that the rewards are too close and all between 5 and 6, therefore achieving the optimum episodic reward will be harder.

What scaling methods are recommended? (like min-max scaling or reward ** 3)

How can I emphasize the episodic reward?


I’ll try to find where I found it, but normalizing the rewards has always worked for me. Assuming you have a list of the discounted returns for each action, you subtract the whole list by its average value then divide it by its standard deviation. In Python with NumPy, that would look like:

returns -= np.mean(returns)
returns /= np.std(returns)

This puts the returns in a small and consistent range that keeps learning similar with different rewards.

  • $\begingroup$ I don't understand this, how can we get mean and str from the reward that hasn't revealed itself?? we don't have a returns vector. $\endgroup$ – fardis nadimi Apr 29 at 11:17
  • $\begingroup$ I tried appending reward to a list and taking mean and std but loss functions after a couple of iterations were giving non... $\endgroup$ – fardis nadimi Apr 29 at 21:13
  • $\begingroup$ @Fardis Could you please write a bit about how your code works? I want to make sure we are talking about scaling the same data. $\endgroup$ – S2673 Apr 30 at 0:35
  • $\begingroup$ My code is a DDPG and simply we receive an action and for that action, the environment's reward function will produce a reward(it's my own environment). So for step 1, we have 1 reward sample. therefore taking the mean and std of this reward will be misleading. $\endgroup$ – fardis nadimi Apr 30 at 20:15
  • $\begingroup$ @Fardis Thanks for explaining. My solution was meant for when the network is updated using multiple samples at the same time. First, have you made sure your code works by testing in a different environment? If it does then there are two ways I can think of to use my scaling suggestion for your method. My understanding is that DDPG will have a list with rewards stored and even if you only update with one reward at a time, you could subtract it by the mean and divide it by the variance of all of the rewards that have been collected. Another way is to change your reward function to output values $\endgroup$ – S2673 Apr 30 at 21:20

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.