2

当我运行一些代码(DDPG - Deep Deterministic Policy Gradient)时,发生了这个错误: ValueError: callbacksmust be a callable method that return a subclass of DefaultCallbacks, got <class 'ray.rllib.agents.callbacks.DefaultCallbacks'>

我的代码在这里:

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 是经过训练的 DDPG 参数的位置。

我想使用经过训练的参数,所以使用“config = json.load(read_file)”代码。

然后,当我制作 DDPGTrainer 时,使用这个“配置”,但发生了一些错误。

在此处输入图像描述

我该如何解决这个错误?

4

1 回答 1

0

我怀疑你params.json有回调类的字符串表示。config dict 应该为回调保存一个真正的 Python 对象,而不是字符串表示。您可以尝试加载配置的腌制版本,例如在rollout.pyRLlib 代码库中,而不是加载它的 JSON 表示。

于 2020-08-03T16:31:30.463 回答