Skip to content

Is it possible to resume training with a saved model? #117

@oortlieb

Description

@oortlieb

I'm training a model in an environment where episodes are fairly slow -- each one takes around 5 seconds of real time. I'm currently saving models out with the save.Best() callback.

Is there a way to load the saved model and continue training it? I'm trying to load it back in via the agents.load function, but the behavior of the agent makes it seem like training is starting over from scratch. Here's the code I'm using to try to load the model:

if __name__ == "__main__":
    register_with_gym(gym_env_name='MyEnvV0', entry_point=MyEnvV0)

    checkpoint_dir = None
    if len(sys.argv) > 1:
        checkpoint_dir = sys.argv[1]

    agent = None
    if checkpoint_dir is not None:
        agent = agents.load(checkpoint_dir)
    else:
        agents.seed = 0
        agent = PpoAgent(
            'MyEnvV0'
        )

    print(agent)

    agent.train([save.Best("./models"), plot.State(), plot.Loss(), plot.Rewards(), plot.Actions(), log.Iteration()],
        learning_rate = 0.0001,
        num_iterations = 1000000,
        max_steps_per_episode=1000
    )

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions