pytorch / pytorch/rl

[BUG] VecNorm.to_observation_norm broken for multiple keys

Open
#2,036 1 comment 1 reaction 1 assignee View on GitHub

@vmoens is already working on this.

Since Mar 22, 2024.

bug
Dominant language
Python
Stars
3.6k
Forks
487
Avg merge
1d 1h
Merged PRs (30d)
207

Description

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)

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.