Skip to content
This repository has been archived by the owner on Dec 11, 2022. It is now read-only.

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

Open
jingrui-who opened this issue Jan 16, 2020 · 6 comments
Open

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

jingrui-who opened this issue Jan 16, 2020 · 6 comments

Comments

@jingrui-who
Copy link

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
Copy link
Member

galnov commented Jan 16, 2020

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
Copy link
Author

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
Copy link
Member

galnov commented Jan 20, 2020

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
Copy link
Author

jingrui-who commented Jan 27, 2020

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_internal_state()
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
Copy link
Author

jingrui-who commented Jan 27, 2020

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
Copy link

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

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

No branches or pull requests

3 participants