Stable-baselines: Normalize only parts of the observation space

Created on 14 May 2020  路  3Comments  路  Source: hill-a/stable-baselines

I have a custom environment where the first of the observation space are large floats and the second are binary values. This is how I defined the observation space:

part1_low = np.zeros(5)
part1_high = np.full(shape=(5,), fill_value=200)
# part 2 is binary
part2_low = np.zeros(5)
part2_high = np.ones(5)
self.observation_space = gym.spaces.Box(low=np.concatenate([part1_low, part2_low]), high=np.concatenate([part1_high, part2_high]))

I use VecNormalize to normalize the observations and it works great. However, it always normalizes all observations in the observation space. Is there any way to restrict normalization to the first part? That way, the 2nd part with the binary values would stay untouched. I believe that would make learning easier.

I'm using Python 3.6 and stable_baselines 2.10.0 on Windows 10.

custom gym env question

All 3 comments

Is there any way to restrict normalization to the first part?

Why don't you write a custom VecNormalize that derives from the base one?
Sounds like the easiest solution.

True, should be doable. Does it sound like reasonable idea to exclude binary parts of the observation space from normalization?

Does it sound like reasonable idea to exclude binary parts of the observation space from normalization?

yes as values are only 0 or 1, they are already normalized. Closing this issue then ;).

Was this page helpful?
0 / 5 - 0 ratings