Question

I know this may sound nooby, but how do I save a Deep Q-Learning agent's progress? I mean when I close at i.e. episode 500 when my agent is trained and I restart (in my case a pygame) my agent is going to load its data and it will continue with its progress ( does not start again very stupid :) ). How can it be done?

If you need more details/clarification, feel free to ask! :)

Thanks for any answer! I really do appreciate it!

Was it helpful?

Solution

To save a model's state, it is enough to save the model's parameters. If you are using Torch, then you can save it as follows torch.save(model.state_dict(), path_to_save).

When you want to resume training with a saved model, you would have to first create the model instance, and then you can use model.load_state_dict(torch.load(path_of_saved_model)) to update the new instance with the parameter values of the saved model.

You can find more reference here: https://pytorch.org/tutorials/beginner/saving_loading_models.html

There will be something similar for Tensorflow or any other framework that you use.

You can also have an evaluation function that evaluates how good your model is after a certain number of iterations, and save the one which performs the best.

Hope that helps!

Licensed under: CC-BY-SA with attribution
Not affiliated with datascience.stackexchange
scroll top