facebookresearch / mbrl-lib

Library for Model Based RL
MIT License
952 stars 154 forks source link

fix epoch/episode iteration bug in mbpo.py #160

Closed matthiaskiller closed 1 year ago

matthiaskiller commented 2 years ago

Types of changes

Motivation and Context / Related issue

in the for loop that is incrementing the steps of the current epoch, the steps_epoch iteration variable is not being reset after we observe a termination (done=True). This will mean the next epoch will start from the steps_epoch+1 in which the previous epoch ended. And the next epoch will be shorter than the actual epoch length (i.e. epoch_length - steps_epoch)

 for steps_epoch in range(cfg.overrides.epoch_length):
            if steps_epoch == 0 or done:
                obs, done = env.reset(), False

See #159

How Has This Been Tested (if it applies)

Checklist

luisenp commented 2 years ago

CI is failing due to a trailing whitespace in the line. To automatically check for this and any other errors, you can install pre-commit in your conda env and run pre-commit install; this will set up hooks that will run lint/mypy for any commits. Probably unnecessary for just a single line, but maybe for future PRs :)