【问题标题】:Given a trained environment, how do I evaluate the policy at a specific state?给定一个训练有素的环境,我如何评估特定状态的策略?
【发布时间】:2020-03-27 08:01:24
【问题描述】:

我已经在自定义环境中训练了 Ray-RLlib PPOTrainer。如何评估特定州的政策?

完整示例:

from ray.rllib.agents.ppo import PPOTrainer
from cust_env.envs import CustEnv
from ray.tune.logger import pretty_print

ray.init()
config = ppo.DEFAULT_CONFIG.copy()
config["num_workers"] = 2
config["eager"] = False
config["output"] = 'tmp/debug/'
trainer = PPOTrainer(config=config, env=TravelEnv)

# Can optionally call trainer.restore(path) to load a checkpoint.

for i in range(101):

   result = trainer.train()

   if i % 10 == 0:
       print(pretty_print(result))

有没有一种方法,如下所示,我可以在给定状态下返回最佳操作?

policy = trainer.get_policy()
optimal_action_at_state_S = policy.get_optimal_action(S)

函数policy.compute_actions( ) 似乎从随机策略返回一个随机样本,而不是一个最优动​​作。

【问题讨论】:

  • 如果您编辑了答案以包含一个最小的代码示例来重现您想要的行为,包括导入,您更有可能得到一个全面的答案。

标签: python reinforcement-learning ray


【解决方案1】:

据我通过 Ray-dev Google 小组联系到的 Ray 开发人员说,目前完成此任务的唯一方法是使用自定义动作分布,其中方差设置为零。不过,他确实注意到,很快就会添加改进的界面。

【讨论】:

    【解决方案2】:

    也许只是为了补充,因为我碰到了这个线程:选项现在可用 https://docs.ray.io/en/latest/_modules/ray/rllib/policy/policy.html 例如compute_actions -> 设置 explore=False 以获得确定性操作

    【讨论】:

      猜你喜欢
      • 2019-08-16
      • 2019-11-19
      • 1970-01-01
      • 1970-01-01
      • 2013-07-04
      • 1970-01-01
      • 2021-07-01
      • 2012-08-27
      • 1970-01-01
      相关资源
      最近更新 更多