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 的相关文章

  • CSS3中的块状渐变效果

    是否可以使下面的渐变看起来更 块状 这样就不用逐渐从绿色切换到红色 而是按照如下图所示的步骤完成 期望的效果 现在 gradients background image webkit gradient linear left bottom
  • Android:在canvas api中使用渐变填充颜色绘制圆弧

    我想使用渐变填充使用画布绘制圆弧 如何才能实现这一点呢 嘿 我从这里偷了这个 在 Android 中使用 SweepGradient 绘制圆弧 https stackoverflow com questions 4786318 draw a
  • AWS创建POST策略base64编码+签名

    我正在尝试生成一个带有 PHP 签名的 AWS POST 策略 该策略将发送到客户端以允许通过 javascript AJAX 在浏览器中上传 我已将示例复制到http docs aws amazon com AmazonS3 latest
  • 像渐变一样将图像淡入透明

    我希望将图像 背景图像 淡化为透明 以便实际上可以看到其后面的内容 由于透明度 只能勉强看到 显然 我可以使用 PNG 图像来实现它 但是每次我想要更改开始 gt 停止透明度点时 我都需要要求我的图形设计师更改图像 也许我想要更多的颜色 或
  • 如何在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
  • HTML5画布覆盖透明渐变

    我正在 HTML5 中创建一个颜色选择器 如下面的渐变 它由三个要素组成 纯红色背景色 必须可变 从下到上黑 透明渐变 从左到右白色透明渐变 我已经成功创建了单个渐变和单个颜色 但我不知道如何将纯色和两个渐变叠加在一起 我怎样才能做到这一点
  • 是否可以在 TensorFlow 中仅在一次图形运行中高效地计算每个示例的梯度?

    TD DR 有没有一种方法可以在一次图形运行中以矢量化形式评估 f x1 f x2 f xn 其中 f x 是 f x 的导数 就像是 x tf placeholder tf float32 shape 100 f tf square x
  • 在一个 ggplot 上使用两种比例颜色渐变[重复]

    这个问题在这里已经有答案了 我想将散点图上的点的色阶渐变与绘图上某些文本的色阶渐变结合起来 我可以单独执行它们 如下面的示例所示 但我似乎无法将它们放在一起 有没有办法做到这一点 这是我想要组合的两种类型的图 p 和 p1 的示例代码 l
  • 您可以在 iPhone 中使用 Quartz 制作渐变动画吗?

    我是 iPhone 开发新手 目前正在尝试重新创建我为 Silverlight 开发的图表工具 目前 我正在使用渐变来 填充 代表图表中条形的矩形 是否可以为该渐变设置动画 以便当用户触摸图表中的条形时它会改变颜色 我已经浏览了 Apple
  • 如何在MatLab中求曲线上一点的法向量

    我有一条曲线 我想找到该曲线上给定点的法线向量 稍后我必须找到该法线向量与另一个向量的点积 我尝试了MatLab的梯度函数 但我想当我们需要在特定点找到梯度时它不起作用 但我不确定我是否错了 请指导我如何在 MatLab 中实现这一目标 提
  • 底部渐变边框

    根据CSS 技巧 http css tricks com examples GradientBorder 以下 CSS 语法将导致左边框渐变 left to right border width 3px 0 3px 3px webkit b
  • 用渐变色绘制一个 D3 圆

    如何用渐变颜色画一个圆 比如说 从黄色到蓝色的渐变 通常 要创建黄色圆圈 我们可以使用以下代码 var cdata 50 40 var xscale 40 var xspace 50 var yscale 70 var svg d3 sel
  • CSS 渐变内容很少:修复了 Chrome 的问题

    我问了一个问题内容很少的 CSS 渐变 https stackoverflow com questions 4873150 css gradients with little content前段时间 我想出了一个可能的解决办法http js
  • 使用XACML来表达策略,它是一个逻辑表达式

    我对 XACML 很陌生 我正在使用 XACML 来表达策略 但除了以下几个例子之外 我找不到任何好的例子OASIS XACML技术委员会 http docs oasis open org xacml 3 0 xacml 3 0 core
  • 以编程方式生成渐变?

    给定 2 个 RGB 颜色和一个矩形区域 我想在颜色之间生成基本的线性渐变 我进行了快速搜索 我唯一能找到的是这个博客条目 http jtauber com blog 2008 05 18 creating gradients progra
  • 您可以使用 CSS 或 JavaScript 创建渐变为不透明的渐变吗?

    WebKit 引入了创建 CSS 渐变的功能 例如 使用以下代码 webkit gradient linear left top left bottom from fff to 000 但是 是否可以使用 CSS 实现不透明度渐变 我希望渐
  • svg 圆形描边上的多种颜色

    我想创建一个彩虹圈 如下图所示 如何绘制弯曲的多色标渐变 这是我当前的代码
  • 将渐变应用于 CAShapeLayer

    有人有将渐变应用于 CAShapeLayer 的经验吗 CAShapeLayer 是一个很棒的图层类 但它似乎只支持纯色填充着色 而我希望它具有渐变填充 实际上是一个可设置动画的渐变 与 CAShapeLayer 相关的所有其他内容 阴影
  • PyTorch 如何计算二阶雅可比行列式?

    我有一个正在计算向量的神经网络u 我想计算关于输入的一阶和二阶雅可比矩阵x 单个元素 有人知道如何在 PyTorch 中做到这一点吗 下面是我项目中的代码片段 import torch import torch nn as nn class
  • Java-创建离散彩虹颜色数组

    很难描述我想要做什么 我基本上想创建一个离散的彩虹渐变 这样对于 i 个 JButton 的任何一行 它们之间的颜色渐变都会看起来彩虹 我已经完成了以下操作 但它实际上只创建了一个红色渐变 然后是绿色渐变 然后是蓝色渐变 Color c n

随机推荐

  • 基于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