Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] VecNorm.to_observation_norm broken for multiple keys #2036

Open
3 tasks done
maxweissenbacher opened this issue Mar 22, 2024 · 1 comment
Open
3 tasks done

[BUG] VecNorm.to_observation_norm broken for multiple keys #2036

maxweissenbacher opened this issue Mar 22, 2024 · 1 comment
Assignees
Labels
bug Something isn't working

Comments

@maxweissenbacher
Copy link
Contributor

maxweissenbacher commented Mar 22, 2024

Describe the bug

The VecNorm transform produces a bug when calling the to_observation_norm method with multiple keys

To Reproduce

gym_env = GymEnv("MountainCarContinuous-v0", device='cpu')
transformed_env = TransformedEnv(gym_env, VecNorm(in_keys=["observation", "reward"]))
transformed_env.rollout(100)
transformed_env.transform[0].to_observation_norm()

Expected behavior

Should return ObservationNorm but gives following error:

...
out += ObservationNorm
TypeError: 'type' object is not iterable

Reason and Possible fixes

Using the VecNorm transform with only one key works - so to do it for multiple keys one can just use it repeatedly with single keys.

Checklist

  • I have checked that there is no similar issue in the repo (required)
  • I have read the documentation (required)
  • I have provided a minimal working example to reproduce the bug (required)
@maxweissenbacher maxweissenbacher added the bug Something isn't working label Mar 22, 2024
@maxweissenbacher
Copy link
Contributor Author

Another bug here:

When using the VecNorm transform with only one in_key, but a key that isn't a pure string, to_observation_norm also fails. There is an easy fix for this: the to_observation_norm method is missing a call to key = self._key_str(key). I will create a pull request to add this if that's okay with you.

An example of this situation might occur for instance in the multiagent setting, where the observations might be stored under the key ("agents", "observation").

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants