araffin / rl-baselines-zoo

A collection of 100+ pre-trained RL agents using Stable Baselines, training and hyperparameter optimization included.
https://stable-baselines.readthedocs.io/
MIT License
1.12k stars 206 forks source link

How to load a pretrained model with hyperparams into a python variable? [Question] #80

Closed philippwulff closed 4 years ago

philippwulff commented 4 years ago

I would like to load a pretrained model from the rl-baselines-zoo to a python variable.

I cloned the repo to a google colab notebook and then tried to load the model the way, one would normally load openAI gym envs:

path = 'rl-baselines-zoo/trained_agents/BipedalWalker-v3.pkl'
model = PPO2.load('path')

However this model is very bad in respect of the returned mean reward (I assume because I did not import hyperparameters?).

  1. Why are the pretrained models not saved in the usual .zip files which are created when calling model.save(path)?
  2. How do I load a pretrained model from the rl-b-z into a python python variable, so that I can call all the functions of the model?

Regarding the second question I tried using code bits from enjoy.py to construct a model loader, but I am struggling here and wonder if there is a better solution.

araffin commented 4 years ago

However this model is very bad in respect of the returned mean reward (I assume because I did not import hyperparameters?). How do I load a pretrained model from the rl-b-z into a python python variable, so that I can call all the functions of the model?

Yes, please read the code of enjoy.py for that. You are missing the normalization stats for that one.

Why are the pretrained models not saved in the usual .zip files which are created when calling model.save(path)?

It comes from on old version of SB...

philippwulff commented 4 years ago

Thanks for the quick reply. I will use code from enjoy.py to load the model with hyperparams then.