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

[Proposal] Support Stable Baselines? #343

Closed
achouliaras opened this issue Apr 4, 2023 · 7 comments
Closed

[Proposal] Support Stable Baselines? #343

achouliaras opened this issue Apr 4, 2023 · 7 comments

Comments

@achouliaras
Copy link

Currently, It seems that Minigrid can't work with Stable Baselines3. The state space is in a different format and the env checker produces an error that the environments don't follow the Gym API closely.

It would be nice to provide support for Stable Baselines as they can make Minigrid accessible to even more people.

@achouliaras achouliaras changed the title [Proposal] Support with Stable Baselines [Proposal] Support Stable Baselines? Apr 4, 2023
@pseudo-rnd-thoughts
Copy link
Member

Currently Minigrid uses Gymnasium rather than Gym, are you using stable baselines 2.0.0alpha1? This adds supports for gymnasium by default. This is probably the cause of the env checker error.

@BolunDai0216 I realised that in our readme we include a note about training an agent https://github.com/Farama-Foundation/Minigrid#training-an-agent however this will no longer work as the previous environment uses the gym-minigrid.
I don't know how much time you have but it would be great to add scripts in cleanrl if costa is happy for training basic agents. Plus we can release pre-trained agents for all of the environments as part of the paper you are writing.

@jbloomAus
Copy link
Contributor

jbloomAus commented Apr 6, 2023

I feel the real work here is in stable baselines using gymnasium rather than gym. Do they plan to transition? (edit: Can't see anything on their roadmap. If enough people want them to use gym rather than gymnasium, it might be worth showing it can be done).

@pseudo-rnd-thoughts
Copy link
Member

@VineetTambe
Copy link

I am trying to run stable baselines3 with minigrid but I keep on running into errors regrading the structure of the observation space.
Was anyone able to get it to run?
If so could you point me to some example code?
I am trying to run it with PPO and CnnPolicy or MultiInputPolicy

@BolunDai0216
Copy link
Collaborator

BolunDai0216 commented Jun 13, 2023

@VineetTambe To use SB3 with Minigrid, you would need to create a custom CNN feature extractor see here for an example. Then, you just need to update the policy_kwargs dictionary with the custom feature extractor (see here, this is a MultiInputPolicy, for a CnnPolicy see these two links for the feature extractor and the PPO instance) and pass it to the PPO instance (see here). For more details, you can take a look at the SB3 documentation.

@VineetTambe
Copy link

Thanks @BolunDai0216! I will try it out!

@BolunDai0216
Copy link
Collaborator

I will close this issue since there are no additional comments, please feel free to reopen it if anyone has any related questions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants