返回介绍

parl.Algorithm

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

class Algorithm(model=None)[源代码]
alias: parl.Algorithm alias: parl.core.fluid.algorithm.Algorithm Algorithm defines the way how to update the parameters of

the Model. This is where we define loss functions and the optimizer of the neural network. An Algorithm has at least a model.

PARL has implemented various algorithms(DQN/DDPG/PPO/A3C/IMPALA) that

can be reused quickly, which can be accessed with parl.algorithms.

Example:

import parl

model = Model()
dqn = parl.algorithms.DQN(model, lr=1e-3)
变量:
  • model (parl.Model) – a neural network that represents a policy

  • function. (or a Q-value) –

Pulic Functions:
  • get_weights: return a Python dictionary containing parameters

of the current model. - set_weights: copy parameters from get_weights() to the model. - sample: return a noisy action to perform exploration according to the policy. - predict: return an action given current observation. - learn: define the loss function and create an optimizer to minized the loss.

__init__(model=None)[源代码]
参数:

model (parl.Model) – a neural network that represents a policy or a Q-value function.

get_weights()[源代码]

Get weights of self.model.

返回:

a Python dict containing the parameters of self.model.

返回类型:

weights (dict)

learn(*args, **kwargs)[源代码]

Define the loss function and create an optimizer to minize the loss.

predict(*args, **kwargs)[源代码]

Refine the predicting process, e.g,. use the policy model to predict actions.

sample(*args, **kwargs)[源代码]

Define the sampling process. This function returns an action with noise to perform exploration.

set_weights(params)[源代码]

Set weights from get_weights to the model.

参数:

weights (dict) – a Python dict containing the parameters of self.model.

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

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

发布评论

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