robfiras / loco-mujoco

Imitation learning benchmark focusing on complex locomotion tasks using MuJoCo.
MIT License
475 stars 38 forks source link

How to resume last training #9

Closed craipy-hub closed 5 months ago

craipy-hub commented 5 months ago

I am using the example to train the "Atlas.walk",but i dont know how to resume the training. I can only start training from scratch every time, which is very inefficient

robfiras commented 5 months ago

Hi! you can save agents with

path = "your_path"
agent.save(path, full=True)

The full save is needed to store also the expert dataset, which is needed if you want to resume training. For inference only, that wouldn't be needed. Note that the BestAgentSaver already saves the best agents in the interval n_epochs_save specified in the launcher file.

You can load an agent with:

from mushroom_rl.core import Agent
path = "your_path"
agent  = Agent.load(path)

I also just found a bug during saving in the imitation learning repo (ls-iq), please pull the latest changes before trying it out. The only thing that is currently not working after loading an agent is the tensorboard logger (it is causing a pickle error during saving). So you have to log information on your own.

Let me know if there is anything else!

Best, Firas