question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[Feature Request] SB3 compatible version of Gym's FrameStack wrapper

See original GitHub issue

🚀 Feature

A version of Gym’s FrameStack wrapper that returns the stacked observations as (channel*n_stack, height, width).

Motivation

The VecFrameStack in SB3 returns stacked observations as (channel*n_stack, height, width), while the non-vectorized version in Gym returns the observations as (n_stack, height, width, channel). Using the non-vectorized version with e.g. the NatureCnn feature extractor is not possible (fails assert in https://github.com/DLR-RM/stable-baselines3/blob/master/stable_baselines3/common/torch_layers.py#L67).

Pitch

Either

  • add a non-vectorized FrameStack wrapper (as has been done with Monitor), or
  • add a compatibility layer to Gym’s FrameStack that assembles the the observations correctly.

### Checklist

  • I have checked that there is no similar issue in the repo (required)

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:8 (7 by maintainers)

github_iconTop GitHub Comments

2reactions
araffincommented, Mar 4, 2022

I just want to normalize the rewards.

You can skip obs normalization in that case by passing norm_obs=False (you may need SB3 master version), or as suggested in #693 invert the wrappers (that would be equivalent to doing frame stack on each single env and then normalizing)

2reactions
Miffylicommented, Mar 3, 2022

Reasonable request, but in what situation would you want to apply FrameStack as an individual wrapper per env? On a quick thought this is useful if you want to add some wrappers after FrameStack to do some mods, but these could also be done in a vectorized fashion.

SB3 is built solely around “vectorized” envs as you can always turn single env into a vectorized env of size one, which simplifies the code. If the wrapper is not used in/for SB3 specifically, there is little reason to add it here tbh.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Gym Wrappers - Stable Baselines3 Contrib docs!
Additional Gym Wrappers to enhance Gym environments. ... class sb3_contrib.common.wrappers. ... GoalEnv ) 1D observation spaces are supported for now.
Read more >
Stable Baselines Documentation - Read the Docs
Stable Baselines is a set of improved implementations of Reinforcement Learning (RL) algorithms based on OpenAI Baselines. Warning: This ...
Read more >
Kirsten Crane (@k_n_crane) / Twitter
... one of our most requested feature, is now on SB3 Contrib master branch =)! It was benchmarked against PPO with frame-stack on...
Read more >
stable-baselines Changelog - pyup.io
Fixed a bug in ``HindsightExperienceReplayWrapper``, where the openai-gym signature for ... Added ``version.txt`` to manage version number in an easier way
Read more >
The ICLR Blog Track ·
CartPole-v1 from Gym was his chosen simulation environment, and before long, Jon made PPO work with CartPole-v1 .
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found