Spinning Up

OpenAI推出强化学习项目Spinning Up 为通用人工智能铺路

我们的软件包旨在为那些对深度强化学习感兴趣,且希望学习并使用,但不清楚如何将算法转化为代码的人,提供一个中间步骤。我们试图让这成为我们这一项目的起点。”

Spinning Up项目是OpenAI大型教育服务中的一部分。2019年2月,该机构将举办一个Spinning Up讲习班,另一个讲习班将与加州大学伯克利分校的Center for Human-Compatible AI(CHAI)共同主办。

我们的软件包旨在成为那些深受RL激动的人们的缺失中间步骤,并希望学习如何使用它或做出贡献,但是没有清楚地知道要学习什么或如何将算法转化为代码。我们试图让这个作为一个有用的启动点。

已实现的代码

(放在Spinning Up package):

Vanilla Policy Gradient (VPG)
Trust Region Policy Optimization (TRPO)
Proximal Policy Optimization (PPO)
Deep Deterministic Policy Gradient (DDPG)
Twin Delayed DDPG (TD3)
Soft Actor-Critic (SAC)

CODE FORMAT

All implementations in Spinning Up adhere to a standard template. They are split into two files: an algorithm file, which contains the core logic of the algorithm, and a core file, which contains various utilities needed to run the algorithm.
Spinning Up中的所有实现都遵循标准模板。它们分为两个文件:一个算法文件,其中包含算法的核心逻辑,以及一个核心文件,其中包含运行算法所需的各种函数。

1.algorithm file

首先,包含类的定义
接下来,有一个运行算法的函数,执行以下任务(按此顺序):
Logger setup设定计数器
Random seed setting
Environment instantiation
Making placeholders for the computation graph
Building the actor-critic computation graph via the actor_critic function passed to the algorithm function as an argument
Instantiating the experience buffer
Building the computation graph for loss functions and diagnostics specific to the algorithm
Making training ops
Making the TF Session and initializing parameters
Setting up model saving through the logger
Defining functions needed for running the main loop of the algorithm (eg the core update function, get action function, and test agent function, depending on the algorithm)
Running the main loop of the algorithm:
Run the agent in the environment
Periodically update the parameters of the agent according to the main equations of the algorithm
Log key performance metrics and save agent
Finally, there’s some support for directly running the algorithm in Gym environments from the command line.
1.记录器设置
2.随机种子设定
3.环境实例化
为计算图制作占位符
通过actor_critic传递给算法函数的函数构建actor-critic计算图作为参数
实例化体验缓冲区
构建特定于算法的损失函数和诊断的计算图
进行培训操作
制作TF会话并初始化参数
通过记录器设置模型保存
定义运行算法主循环所需的函数(例如核心更新函数,获取动作函数和测试代理函数,具体取决于算法)
运行算法的主循环:
在环境中运行代理
根据算法的主要方程定期更新代理的参数
记录关键性能指标和保存代理

核心文件
核心文件不像算法文件那样严格遵守模板,但确实有一些近似结构:

与制作和管理占位符相关的功能
用于构建与actor_critic特定算法的方法相关的计算图的部分的函数
任何其他有用的功能
与算法兼容的MLP actor-critic的实现,其中策略和值函数都由简单的MLP表示

猜你喜欢

转载自blog.csdn.net/weixin_41913844/article/details/84030305