hill-a / stable-baselines

A fork of OpenAI Baselines, implementations of reinforcement learning algorithms
http://stable-baselines.readthedocs.io/
MIT License
4.14k stars 723 forks source link

[Question] "Curriculum" learning-like training in stablebaselines3 #1126

Closed PatrickSampaioUSP closed 3 years ago

PatrickSampaioUSP commented 3 years ago

Greetings,

I'm using stablebaselines3 to train a very complex custom environment, that would benefit a lot from curriculum learning logic, I would like to change the environment type based on trained timesteps or the mean reward. The way I imagine is that i could only change the environment id and the new environment used in the training would be the new one, that obviously receives the same parameters as the other in the init. However, I read the documentation and the callbacks code and I do not know how I would implement this in stablebaselines3, can anyone give my some light?

Thanks a lot!

araffin commented 3 years ago

Hello, Callbacks and calls to environment methods (cf. VecEnv doc) is the way to go. With the callback you can monitor the agent performance and also have access to the environment, something like:


if performance > threshold:
    self.level += 1
    # change the level, will be effective at the next reset
    self.env.env_method("change_level", self.level)

Related: https://github.com/hill-a/stable-baselines/issues/617

PS: you posted the issue in SB2 repo...

PatrickSampaioUSP commented 3 years ago

Hi,

I implemented a test using this idea, worked very well, thanks you. Sorry for posting in the wrong repository. Do you know any open-source snippet that implemented a similar idea?

araffin commented 3 years ago

Do you know any open-source snippet that implemented a similar idea?

I don't but you can always do a search on github ;)

Closing this as the original question was answered.