IntelLabs / coach

Reinforcement Learning Coach by Intel AI Lab enables easy experimentation with state of the art Reinforcement Learning algorithms
https://intellabs.github.io/coach/
Apache License 2.0
2.32k stars 460 forks source link

How to retrieve the best working model for application? #435

Open jingrui-who opened 4 years ago

jingrui-who commented 4 years ago

Hi, i am new to coach. I was following the tutorial for using coach as a library. I was able to reach coach.run() and successfully train the model and view the results in the dashboard.

How do i now load the best model that it has trained to test it out manually? Is there a command like coach.load(model)?

galnov commented 4 years ago

Hi and welcome! :-) See the last code block in the Quick Start Guide tutorial. It shows an example of checkpoint loading and evaluation.

jingrui-who commented 4 years ago

Does this load the best model or just load the latest model? Some times when i train, the latest evaluation model seems to perform worst then the previous ones.

galnov commented 4 years ago

It loads the model in the latest file stored in the checkpoint directory. Checkpoint file names contain the number of training steps, which can help you choose which model to load if you'd like to evaluate a model other than the latest.

jingrui-who commented 4 years ago

Hi, sorry for the trouble again. I am still unsure of how to load and use a model

Currently, i am using the following code to use the step model to see the decision at each state

env_params = GymVectorEnvironment(level='MachineSimple-v0') env = GymEnvironment(**env_params.dict, visualization_parameters=VisualizationParameters()) response = env.reset_internalstate() for in range(10): action_info = coach.graph_manager.get_agent().choose_action(response.next_state) print("State:{}, Action:{}".format(response.next_state,action_info.action)) response = env.step(action_info.action) print("Reward:{}".format(response.reward))

However, this requires me to train a model and use it immediately. Is there a place to store and load the model? I was expecting something similar like model.fit()/model.load() and model.predict()

jingrui-who commented 4 years ago

The last code block in the Quick Start Guide tutorial seems to only load check point and evaluate it. However, i am need to use the .step() method to output a decision for my use case. is there a way to go about doing this?

philwinder commented 4 years ago

For future searchers and @e0003315, take a look at #374. The comment has a good example of doing this.