2

when I run some codes(DDPG - Deep Deterministic Policy Gradient), this error occurred: ValueError: callbacks must be a callable method that returns a subclass of DefaultCallbacks, got <class 'ray.rllib.agents.callbacks.DefaultCallbacks'>

my code is here:

import json

def load_policy():
    log_dir = "/root/ray_results/DDPG_SimpleSupplyChain_2020-07-15_02-37-48j2fjk67_" # this path needs to be set manually
    checkpoint_id = "200"
    with open(f"{log_dir}/params.json", "r") as read_file:
        config = json.load(read_file)
    trainer = ddpg.DDPGTrainer(config=config, env=SimpleSupplyChain)
    trainer.restore(f"{log_dir}/checkpoint_{checkpoint_id}/checkpoint-{checkpoint_id}")
    return trainer.get_policy()

policy = load_policy()

log_dir is location of trained DDPG's parameters.

I want to use trained parameters, so use "config = json.load(read_file)" code.

then, when I make DDPGTrainer, use this "config", but some errors occurred.

enter image description here

How can I solve this error?

Peter Kim
  • 65
  • 4

1 Answers1

0

I suspect your params.json has a string representation of the callbacks class. The config dict should hold a real Python object for the callback, not a string representation. You could try loading the pickled version of the config, like in rollout.py in the RLlib codebase, rather than loading the JSON representation of it.

Andrew Rosenfeld
  • 1,711
  • 1
  • 12
  • 9