How to validate any incoming observations against the observation space?

Hi,

Does anyone know if there is an easy way to validate any incoming observations against the observation space?

That is, if any values inside the current observations are outside the bounds of the defined observation space to raise an error or whatever?

1 Like

RLlib already does this by default during training (however, it will only do it on a small sample of the data to avoid too much performance overhead of validation).
Otherwise, you can - in your environment - do the check manually with self.observation_space.contains(obs).

Thanks a bunch, this function is actually a life saver!

I’m able to figure out the root cause of another (months long issue) that I can now close due to a dumb mistake. I’m hoping you can somehow merge these into one thread to unify it: Randomly get empty queue when requesting action using PPO policy client + server · Issue #15753 · ray-project/ray · GitHub