Policy Gradient Algorithms

2023-05-16

Policy Gradient Algorithms

 2019-10-02 17:37:47

This blog is from: https://lilianweng.github.io/lil-log/2018/04/08/policy-gradient-algorithms.html 

 

Abstract: In this post, we are going to look deep into policy gradient, why it works, and many new policy gradient algorithms proposed in recent years: vanilla policy gradient, actor-critic, off-policy actor-critic, A3C, A2C, DPG, DDPG, D4PG, MADDPG, TRPO, PPO, ACER, ACTKR, SAC, TD3 & SVPG. 

 

  • What is Policy Gradient
    • Notations
    • Policy Gradient
    • Policy Gradient Theorem
    • Proof of Policy Gradient Theorem
  • Policy Gradient AlgorithmsQuick Summary
    • REINFORCE
    • Actor-Critic
    • Off-Policy Policy Gradient
    • A3C
    • A2C
    • DPG
    • DDPG
    • D4PG
    • MADDPG
    • TRPO
    • PPO
    • ACER
    • ACTKR
    • SAC
    • SAC with Automatically Adjusted Temperature
    • TD3
    • SVPG
  • References

What is Policy Gradient

Policy gradient is an approach to solve reinforcement learning problems. If you haven’t looked into the field of reinforcement learning, please first read the section “A (Long) Peek into Reinforcement Learning » Key Concepts” for the problem definition and key concepts.

Notations

Here is a list of notations to help you read through equations in the post easily.

SymbolMeaning
sSs∈SStates.
aAa∈AActions.
rRr∈RRewards.
St,At,RtSt,At,RtState, action, and reward at time step t of one trajectory. I may occasionally use st,at,rtst,at,rt as well.
γγDiscount factor; penalty to uncertainty of future rewards; 0<γ10<γ≤1.
GtGtReturn; or discounted future reward; Gt=k=0γkRt+k+1Gt=∑k=0∞γkRt+k+1.
P(s,r|s,a)P(s′,r|s,a)Transition probability of getting to the next state s’ from the current state s with action a and reward r.
π(a|s)π(a|s)Stochastic policy (agent behavior strategy); πθ(.)πθ(.) is a policy parameterized by θ.
μ(s)μ(s)Deterministic policy; we can also label this as π(s)π(s), but using a different letter gives better distinction so that we can easily tell when the policy is stochastic or deterministic without further explanation. Either ππ or μμ is what a reinforcement learning algorithm aims to learn.
V(s)V(s)State-value function measures the expected return of state s; Vw(.)Vw(.) is a value function parameterized by w.
Vπ(s)Vπ(s)The value of state s when we follow a policy π; Vπ(s)=Eaπ[Gt|St=s]Vπ(s)=Ea∼π[Gt|St=s].
Q(s,a)Q(s,a)Action-value function is similar to V(s)V(s), but it assesses the expected return of a pair of state and action (s, a); Qw(.)Qw(.) is a action value function parameterized by w.
Qπ(s,a)Qπ(s,a)Similar to Vπ(.)Vπ(.), the value of (state, action) pair when we follow a policy π; Qπ(s,a)=Eaπ[Gt|St=s,At=a]Qπ(s,a)=Ea∼π[Gt|St=s,At=a].
A(s,a)A(s,a)Advantage function, A(s,a)=Q(s,a)V(s)A(s,a)=Q(s,a)−V(s); it can be considered as another version of Q-value with lower variance by taking the state-value off as the baseline.

Policy Gradient

The goal of reinforcement learning is to find an optimal behavior strategy for the agent to obtain optimal rewards. The policy gradient methods target at modeling and optimizing the policy directly. The policy is usually modeled with a parameterized function respect to θ, πθ(a|s)πθ(a|s). The value of the reward (objective) function depends on this policy and then various algorithms can be applied to optimize θ for the best reward.

The reward function is defined as:

J(θ)=sSdπ(s)Vπ(s)=sSdπ(s)aAπθ(a|s)Qπ(s,a)J(θ)=∑s∈Sdπ(s)Vπ(s)=∑s∈Sdπ(s)∑a∈Aπθ(a|s)Qπ(s,a)

where dπ(s)dπ(s) is the stationary distribution of Markov chain for πθπθ (on-policy state distribution under π). For simplicity, the θ parameter would be omitted for the policy πθπθ when the policy is present in the subscript of other functions; for example, dπdπ and QπQπ should be dπθdπθ and QπθQπθ if written in full. Imagine that you can travel along the Markov chain’s states forever, and eventually, as the time progresses, the probability of you ending up with one state becomes unchanged — this is the stationary probability for πθπθ. dπ(s)=limtP(st=s|s0,πθ)dπ(s)=limt→∞P(st=s|s0,πθ) is the probability that st=sst=s when starting from s0s0 and following policy πθπθ for t steps. Actually, the existence of the stationary distribution of Markov chain is one main reason for why PageRank algorithm works. If you want to read more, check this.

It is natural to expect policy-based methods are more useful in the continuous space. Because there is an infinite number of actions and (or) states to estimate the values for and hence value-based approaches are way too expensive computationally in the continuous space. For example, in generalized policy iteration, the policy improvement step argmaxaAQπ(s,a)arg⁡maxa∈AQπ(s,a) requires a full scan of the action space, suffering from the curse of dimensionality.

Using gradient ascent, we can move θ toward the direction suggested by the gradient θJ(θ)∇θJ(θ) to find the best θ for πθπθ that produces the highest return.

Policy Gradient Theorem

Computing the gradient θJ(θ)∇θJ(θ) is tricky because it depends on both the action selection (directly determined by πθπθ) and the stationary distribution of states following the target selection behavior (indirectly determined by πθπθ). Given that the environment is generally unknown, it is difficult to estimate the effect on the state distribution by a policy update.

Luckily, the policy gradient theorem comes to save the world! Woohoo! It provides a nice reformation of the derivative of the objective function to not involve the derivative of the state distribution dπ(.)dπ(.) and simplify the gradient computation θJ(θ)∇θJ(θ) a lot.

θJ(θ)=θsSdπ(s)aAQπ(s,a)πθ(a|s)sSdπ(s)aAQπ(s,a)θπθ(a|s)∇θJ(θ)=∇θ∑s∈Sdπ(s)∑a∈AQπ(s,a)πθ(a|s)∝∑s∈Sdπ(s)∑a∈AQπ(s,a)∇θπθ(a|s)

Proof of Policy Gradient Theorem

This session is pretty dense, as it is the time for us to go through the proof (Sutton & Barto, 2017; Sec. 13.1) and figure out why the policy gradient theorem is correct.

We first start with the derivative of the state value function:

=====θVπ(s)θ(aAπθ(a|s)Qπ(s,a))aA(θπθ(a|s)Qπ(s,a)+πθ(a|s)θQπ(s,a))aA(θπθ(a|s)Qπ(s,a)+πθ(a|s)θs,rP(s,r|s,a)(r+Vπ(s)))aA(θπθ(a|s)Qπ(s,a)

转载于:https://www.cnblogs.com/wangxiaocvpr/p/11617854.html

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

Policy Gradient Algorithms 的相关文章

  • Android LinearLayout 渐变背景

    我在将渐变背景应用于 LinearLayout 时遇到问题 从我读过的内容来看 这应该相对简单 但它似乎不起作用 作为参考 我正在 2 1 update1 上进行开发 header bg xml
  • 图中的颜色点根据值向量的不同而不同

    我正在使用 R 绘制下图plot 功能 这是一个向量图shiftTime的时间转变 我有另一个向量intensity强度值范围从 3到 9 我想根据具有颜色渐变的这些值对图中的点进行着色 在示例中 我可以在实际绘制点的值上找到颜色 因此在本
  • Chrome 中 SVG 线性渐变的舍入误差?

    我最近在 Chrome 渲染 SVG 线性渐变时发现了一些问题 看看下面这个 SVG
  • Chrome 自动播放政策中的自动播放背景视频

    因此 在最新的 chrome 中 显然自动播放策略已更改 因此这反过来又破坏了每个具有应自动播放视频背景的网站 我想知道是否有人有任何聪明的解决办法可以 解决 这个问题 我相信按钮或 进入页面 解决方案将是一种糟糕的解决方法 特别是对于背景
  • 生成颜色渐变

    我有一个想法以编程方式生成匹配的配色方案 但是我需要能够在给定一组两种颜色 十六进制或 RGB 值 的情况下生成线性渐变 任何人都可以向我提供 伪 代码或为我指明完成此任务的正确方向吗 EDIT 我忘了提及 但我还需要指定 或知道 从颜色
  • HTML5 Canvas - alpha 值较低的条带?

    介绍 我目前正在开发一个类似于 MugTug 的小型绘图应用程序画板 http mugtug com sketchpad 不过 有一个非常烦人的问题我还没有解决 绘图算法 我的基本绘制算法与 MugTug 使用的算法类似 基本上它只是在用户
  • 张量流梯度 - 获取所有 nan 值

    我正在使用带有 anaconda 的 python 3 以及带有 eager eval 的tensorflow 1 12 我正在使用它为暹罗网络创建三元组损失函数 并且需要计算不同数据样本之间的距离 我创建了一个函数来创建距离计算 但无论我
  • CSS3中的块状渐变效果

    是否可以使下面的渐变看起来更 块状 这样就不用逐渐从绿色切换到红色 而是按照如下图所示的步骤完成 期望的效果 现在 gradients background image webkit gradient linear left bottom
  • 带有渐变的CSS3动画[重复]

    这个问题在这里已经有答案了 难道真的没有办法用 CSS 来制作渐变背景的动画吗 就像是 webkit keyframes pulse 0 background webkit gradient linear left top left bot
  • 如何在CSS中制作具有透明度的径向渐变

    我想在透明度变化的地方制作一个径向渐变 我可以让它线性工作 但不是径向工作 background webkit gradient linear left top left bottom from rgba 50 50 50 0 8 to r
  • 在 OpenCV 中绘制梯度向量场

    我想计算灰度图像的梯度 平滑平面在代码中 并将其绘制为 OpenCV 中的矢量场 叠加到现有图像上 我尝试应用一对 Sobel 运算符 我也尝试过 Scharr 来计算沿 x 和 y 的两个导数 如 OpenCV 文档中所述 但当我尝试绘图
  • 如何在pytorch中返回中间梯度(对于非叶节点)?

    我的问题是关于 pytorch 的语法register hook x torch tensor 1 requires grad True y x 2 z 2 y x register hook print y register hook p
  • iPhone 上的 OpenGL 渐变填充看起来有条纹

    当我使用 OpenGL 绘制渐变填充时 输出看起来是条纹的 即它仅使用大约四分之一的可能颜色进行渲染 所有颜色都会出现在渲染缓冲区中 但不会出现在实际输出中 我正在运行 iOS4 的 iPhone 3G 上进行开发 有任何想法吗 Peter
  • CSS 中缩放渐变背景

    第一次提问 请对我宽容一些 我正在尝试为使用 JQuery Mobile 的网络应用程序制作背景渐变 我对 CSS 和 UI 设计一无所知 我希望渐变填充整个页面的空间 现在 它填充到原始窗口的大小 但向下滚动时会 切断 大多数建议都指向这
  • facet_wrap() + ggplot2() 中每个面的独立颜色渐变

    我正在努力为每个方面绘制渐变色标facet wrap 独立 数据太大 无法在这里发布 但这是我的代码 ggplot stack aes hour day geom tile aes fill percent colour white fac
  • 用python计算梯度

    我想知道如何numpy gradient工作 我用梯度来尝试计算群速度 波包的群速度是频率相对于波数的导数 而不是一组速度 我向它提供了一个 3 列数组 前 2 列是 x 和 y 坐标 第三列是该点 x y 的频率 我需要计算梯度 我确实期
  • 下载时出错

    下载控制台会返回以下错误 帧加载因策略更改而中断 Example a href app exe Start Download a Console Preview 我应该在中配置一些东西吗Compiler or QWeb设置 我发现了 在传统
  • 底部渐变边框

    根据CSS 技巧 http css tricks com examples GradientBorder 以下 CSS 语法将导致左边框渐变 left to right border width 3px 0 3px 3px webkit b
  • 如何在R中制作渐变颜色填充时间序列图

    How to 填充区域 sp 线下方和上方渐变色 这个例子是在 Inkscape 中绘制的 但我需要垂直渐变 不是水平的 间隔从zero to positive 来自white to red 间隔从zero to negative 来自wh
  • 以编程方式生成渐变?

    给定 2 个 RGB 颜色和一个矩形区域 我想在颜色之间生成基本的线性渐变 我进行了快速搜索 我唯一能找到的是这个博客条目 http jtauber com blog 2008 05 18 creating gradients progra

随机推荐

  • 基于51单片机的超声波测距

    1 超声波测距原理 超声波是利用反射的原理测量距离的 xff0c 被测距离一端为超声波传感器 xff0c 另一端必须有能反射超声波的物体 测量距离时 xff0c 将超声波传感器对准反射物发射超声波 xff0c 并开始计时 xff0c 超声波
  • 超细!详解AD13:如何从零开始画出一个PCB(电路板)

    在学电子或者单片机的小伙伴们或许有过这种念头 xff0c 就是想把自己的设计的电路或者单片机系统做成一个电路板出来 xff1b 但却不知怎样做出来 今天我就给大家详细讲解如果通过AD13电路设计软件设计出一个电路板 1 首先打开AD13 x
  • 基于51单片机液晶万年历设计

    电子万年历是一种非常广泛日常计时工具 xff0c 给人们的带来了很大的方便 xff0c 在社会上越来越流行 它可以对年 月 日 时 分 秒进行计时 xff0c 采用直观的数字显示 xff0c 可以同时显示年月日时分秒和温度等信息 xff0c
  • 基于51单片机的简易计算器

    1 简介 本计算器是以MCS 51系列AT89C51单片机为核心构成的简易计算器系统 该系统通过单片机控制 xff0c 实现对4 4键盘扫描进行实时的按键检测 xff0c 并由LCD1602显示屏将过程与结果显示出来 2 硬件原理图 硬件主
  • 基于51单片机的红外解码器

    1 简介 本红外解码器是以MCS 51系列AT89C512片机为核心 xff0c 将红外传感器接收的信号解析出来 xff0c LCD1602显示屏将解码数据显示出来 2 总体原理图 硬件组成 单片机最小系统LCD1602显示屏IR红外接收器
  • 基于51单片机的心率脉搏计检测系统

    1 功能原理 脉搏传感器采样脉搏信号 xff0c 采用STC89C51单片机作为控制器 xff0c 脉搏传感器输出方波传入单片机 xff0c 触发单片机进去外部中断函数 xff0c 每接收一个脉冲波形 xff0c 显示屏就计数一次 如果脉搏
  • 基于51单片机的智能调光台灯

    1 功能介绍 智能台灯可分成自动和手动两种模式 在自动模式下 xff0c 台灯能根据环境光的亮暗与人是否被台灯所检测到 xff08 人是否在 xff09 来自动开启台灯 当人被微机检测到 xff0c 环境光又达到某个程度的时候 xff08
  • app元素辅助定位三种方式:Appium-Inspector、uiautomatorviewer、Weditor(uiautomator2)

    xff08 1 xff09 使用Appium Desktop中Appium Inspector辅助进行元素定位 早期版本集成在Appium Desktop中 xff0c 最新版本已分开 下载地址 xff1a Releases appium
  • 俄罗斯方块游戏的算法

    1 原理 这个游戏设计 xff0c 本质上就是用一个线程或者定时器产生重绘事件 用线程和用户输入改变游戏状态 这个游戏也不例外 xff0c 启动游戏后 xff0c 就立即生成一个重绘线程 xff0c 该线程每隔50ms绘制一次屏幕 当然 x
  • 基于51单片机的俄罗斯方块游戏

    俄罗斯方块游戏算法 请参考俄罗斯方块游戏的算法 1 概述 俄罗斯方块是一款风靡全球的益智游戏 它规则简单 xff0c 容易上手 xff0c 且游戏过程变化无穷 xff0c 使用户在游戏中得到乐趣 本设计是采用单片机来实现的智能俄罗斯方块游戏
  • 基于51单片机的智能温控风扇

    1 功能 本设计为一种温控风扇系统 xff0c 具有灵敏的温度感测和显示功能 xff0c 系统选用STC89C52单片机作为控制平台对风扇转速进行控制 可在测得温度值在高低温度之间时打开风扇弱风档 xff0c 当温度升高超过所设定的温度时自
  • 基于51单片机的数字频率计

    1 简介 数字频率计是现代科研生产中不可或缺的测量仪器 xff0c 它以十进制数显示被测频率 xff0c 基本功能是测量正弦信号 xff0c 方波信号 xff0c 及其它各种单位时间内变化的物理量 本系统采用AT89C52单片机智能控制 x
  • 基于51单片机的火灾报警器

    1 系统功能 火灾报警器 xff0c 主要检测温度和烟雾 xff0c 再通过单片机控制相应的报警和驱动负载 通过液晶显示当前的烟雾值和温度值 xff0c 通过按键设定相应的阀值 主要包括以下几项功能 xff1a 1 火情探测功能 xff1a
  • 基于51单片机的指纹密码锁

    1 系统功能概述 本次分享的是一款基于51单片机的指纹识别电子密码锁系统 xff0c 该系统以STC89C52单片机作为模块核心 xff0c 通过串口通信控制指纹模块AS608实现录取指纹并存储指纹数据 xff0c 并通过LCD12864液
  • 基于51单片机的智能电子秤

    1 概述 xff08 1 xff09 系统原理 本电子秤系统利用压力传感器采集因压力变化产生的电压信号 xff0c 经过电压放大电路放大 xff0c 然后再经过模数转换器转换为数字信号 xff0c 最后把数字信号送入单片机 单片机经过相应的
  • 基于51单片机的智能垃圾桶

    1 简介 本次主要是利用单片机设计并制作一套智能垃圾箱 要求以单片机为控制核心 xff0c 通过红外传感器检测是否有人扔垃圾 xff0c 并自动打开垃圾箱盖 xff0c 扔完垃圾后再自动关闭 主要内容包括 xff08 1 xff09 红外对
  • gmake: No rule to make target `C:/ti/controlSUITE2_DMC Rev/device_support/f2803x/v122/DSP2803x_h的解决

    注 xff1a 此方法是在CCS8环境下的使用成功的 在使用controlSUITE的例程编译时 xff0c 工程老出现这种错误 xff0c 排查了很久 xff0c 终于找到了原因 xff0c 造成这种原因主要是CCS在安装时没有按照默认的
  • 基于51单片机的数字气压计

    1 概述 本设计是基于MPX4115的数字气压计 xff0c 硬件处理电路为大气压传感器模拟信号的采集 转换 处理和显示 xff0c 并根据相应的软件需求设计控制程序 2 硬件设计 xff08 1 xff09 硬件总体框图 气压计的硬件主要
  • 一站式开源分布式集群云真机测试平台Sonic——基于Docker方式部署sonic前后端(体验版)

    Sonic xff1a 一站式开源分布式集群云真机测试平台 xff0c 致力服务于中小企业的客户端UI测试 xff0c 永久免费 sonic官网 xff1a Sonic 开源云真机测试平台 开源不易 xff0c 请大家多多支持作者 xff0
  • Policy Gradient Algorithms

    Policy Gradient Algorithms 2019 10 02 17 37 47 This blog is from https lilianweng github io lil log 2018 04 08 policy gr