【问题标题】:Error: `callbacks` must be a callable method that returns a subclass of DefaultCallbacks, got <class 'ray.rllib.agents.callbacks.DefaultCallbacks'>错误:`callbacks` 必须是返回 DefaultCallbacks 子类的可调用方法,得到 <class 'ray.rllib.agents.callbacks.DefaultCallbacks'>
【发布时间】:2020-08-04 00:31:30
【问题描述】:

当我运行一些代码(DDPG - Deep Deterministic Policy Gradient)时,发生了这个错误: ValueError: callbacks must be a callable method that return a subclass of DefaultCallbacks, got

我的代码在这里:

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 时,使用这个“配置”,但出现了一些错误。

我该如何解决这个错误?

【问题讨论】:

    标签: python reinforcement-learning ray rllib


    【解决方案1】:

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

    【讨论】:

      猜你喜欢
      • 2016-12-06
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-05-21
      • 2017-04-22
      • 2018-03-08
      • 2015-05-16
      相关资源
      最近更新 更多