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

Model loading and saving #426

Closed FrancescoTerrosi closed 4 years ago

FrancescoTerrosi commented 4 years ago

Hullo,

I've been playing for a couple of days with this framework and I don't get how to save the model (.h5) and then test it without training. Do I have to code something or i am missing something? :)

Cheers

shadiendrawis commented 4 years ago

Hello,

We currently don't use h5 to save models, you can use the --checkpoint_save_secs (-s) flag to tell Coach to save your model every x number of seconds. This will use the checkpoint saving mechanism relevant to the framework you are using (tensorflow/mxnet). The checkpoints will be saved in the directory called checkpoints in the experiment folder.

In order to test the model without training, you need to run coach with --checkpoint_restore_dir (-crd) with a path to the checkpoints directory that you saved previously, and --evaluate so that Coach only evaluates the model and doesn't perform any training steps.

Let me know if that works for you!

Shadi

FrancescoTerrosi commented 4 years ago

Thank you for your answer, to begin with.

It's nice to know that there is a saving/loading mechanism already implemented. Unfortunately I need a mechanism more episode-based rather than seconds-based. I might just go straight into the codebase and implement it, it should not create any weird behaviour I think, right? (unless you are doing something very exotic in it :) )

Cheers, Francesco

shadiendrawis commented 4 years ago

If you are running the training loop manually using the GraphManager object (as shown in Tutorial 0) you could do what you need by defining the checkout_save_dir field in the TaskParameters and then call graph_manager.save_checkpoint() whenever you want to save a checkpoint.

Shadi

FrancescoTerrosi commented 4 years ago

Nice and simple, thank you very much