返回介绍

MADDPG

发布于 2024-06-23 17:58:49 字数 4818 浏览 0 评论 0 收藏 0

class MADDPG(model, agent_index=None, act_space=None, gamma=None, tau=None, actor_lr=None, critic_lr=None)[源代码]

基类:Algorithm

Q(obs_n, act_n, use_target_model=False)[源代码]

use the value model to predict Q values

参数:
  • obs_n (list of paddle tensor) – all agents’ observation, len(agent’s num) + shape([B] + shape of obs_n)

  • act_n (list of paddle tensor) – all agents’ action, len(agent’s num) + shape([B] + shape of act_n)

  • use_target_model (bool) – use target_model or not

返回:

Q value of this agent, shape([B])

返回类型:

Q (paddle tensor)

__init__(model, agent_index=None, act_space=None, gamma=None, tau=None, actor_lr=None, critic_lr=None)[源代码]

MADDPG algorithm

参数:
  • model (parl.Model) – forward network of actor and critic. The function get_actor_params() of model should be implemented.

  • agent_index (int) – index of agent, in multiagent env

  • act_space (list) – action_space, gym space

  • gamma (float) – discounted factor for reward computation.

  • tau (float) – decay coefficient when updating the weights of self.target_model with self.model

  • critic_lr (float) – learning rate of the critic model

  • actor_lr (float) – learning rate of the actor model

learn(obs_n, act_n, target_q)[源代码]

update actor and critic model with MADDPG algorithm

predict(obs)[源代码]

use the policy model to predict actions

参数:

obs (paddle tensor) – observation, shape([B] + shape of obs_n[agent_index])

返回:

action, shape([B] + shape of act_n[agent_index]),

noted that in the discrete case we take the argmax along the last axis as action

返回类型:

act (paddle tensor)

sample(obs, use_target_model=False)[源代码]

use the policy model to sample actions

参数:
  • obs (paddle tensor) – observation, shape([B] + shape of obs_n[agent_index])

  • use_target_model (bool) – use target_model or not

返回:

action, shape([B] + shape of act_n[agent_index]),

noted that in the discrete case we take the argmax along the last axis as action

返回类型:

act (paddle tensor)

sync_target(decay=None)[源代码]

update the target network with the training network

参数:

decay (float) – the decaying factor while updating the target network with the training network. 0 represents the assignment. None represents updating the target network slowly that depends on the hyperparameter tau.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
    我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
    原文