Actor - Critic Algorithms: A Brief Note

简介: Actor - CriticA class of algorithms that precede Q-Learning and SARSA are actor - critic methods. Refer to V. Konda and J. Tsitsiklis: Actor -critic algorithms. SIAM Journal on Contr

Actor - Critic

A class of algorithms that precede Q-Learning and SARSA are actor - critic methods. Refer to

V. Konda and J. Tsitsiklis: Actor -critic algorithms. SIAM Journal on Control and Optimization 42(4), 1143-1166 (2003).

for more details. We first give some basics:

Policy Gradient Methods & Policy Gradient Theorem

We consider methods for learning the policy weights based on the gradient of some performance measure η(θ) with respect to the policy weights. These methods maximize performance, so their updates approximate gradient ascent in η:

θt+1=θt+α∇η(θt)ˆ

All methods that follow this general schema are known as policy gradient methods, whether or not they also learn an approximate value function. A value function may still be used to learn the policy weight θ∈Rn, but may not be required for action selection.

We consider the episodic case only, in which performance is defined as the value of the start state under the parameterized policy, η(θ)=vπθ(s0). (In continuing case, the performance is defined as the average reward rate.) In policy gradient methods, the policy can be parameterized in any way as long as π(a|s,θ) is differentiable with respect to its weights, i.e. ∇θπ(a|s,θ) always exists and is finite. To ensure exploration, we generally require the policy never becomes deterministic.

Without losing any meaningful generality, we assume that every episode starts in some particular state s0. Then we define performance as:

η(θ)=vπθ(s0)

The policy gradient theorem is that
∇η(θ)=∑sdπ(s)∑aqπ(s,a)∇θπ(a|s,θ)

where the gradients in all cases are the column vectors of partial derivatives with respect to the components of θ, π denotes the policy corresponding to weights vector θ and the distribution dπ here is the expected number of time steps t on which St=s in a randomly generated episode starting in s0 and following π and the dynamics of the MDP.

REINFORCE

Now we have an exact expression for updating gradient. We need some way of sampling whose expectation equals or approximates this expression. Notice that the right-hand side is a sum over states weighted by how often the states occurs under the target policy π weighted again by γ times how many steps it takes to get to those states. If we just follow π we will encounter states in these proportions, which we can then weighted by γt to preserve the expected value:

∇η(θ)=Eπ[γt∑aqπ(St,a)∇θπ(a|St,θ)]

Then we approximate a sum over actions:
∇η(θ)=Eπ[γt∑aqπ(St,a)π(a|St,θ)∇θπ(a|St,θ)π(a|St,θ)]=Eπ[γtqπ(St,At)∇θπ(At|St,θ)π(At|St,θ)]=Eπ[γtGt∇θπ(At|St,θ)π(At|St,θ)]

Using the sample to instantiate the generic stochastic gradient ascent algorithm, we obtain the update:
θt+1=θt+αγtGt∇θπ(At|St,θ)π(At|St,θ)

It is evident that REINFORCE is a type of Monte Carlo Policy Gradient methods. The update increases the weight vector in this direction proportional to the return but inversely proportional to the action probability. The former makes sense because it causes the weights to move most in the directions that favor actions yielding the highest return. The latter makes sense because otherwise actions that are selected frequently are at an advantage and might win out even if they do not yield the highest return.

The update law can also be written as:

θt+1=θt+αγtGt∇θlogπ(At|St,θ)

The policy gradient theorem can be generalized to include a comparison of the action value to an arbitrary baseline b(s):

∇η(θ)=∑sdπ(s)∑a(qπ(s,a)−b(s))∇θπ(a|s,θ)

the baseline can be any function, even a random variable, as long as it does not vary with a. Then we rewrite the update law to be:
θt+1=θt+α(Gt−b(St))∇θlogπ(At|St,θ)

The baseline leaves the expected value of the update unchanged, but it can have a large effect on its variance. One natural choice is an estimate of the state value v^(St,w).

Actor-Critic

Methods that learn approximations to both policy and value functions are called actor-critic methods. REINFORCE with baseline methods use value functions only as a baseline, not a critic, i.e. not for bootstrapping. This is a useful distinction, for only through bootstrapping do we introduce bias and an asymptotic dependence on the quality of the function approximation.

Consider one-step action-critic methods. The main appeal of one step methods is that they are fully online and incremental such as TD(0), SARSA(0) and Q-Learning. One-step actor-critic methods replace the full return of REINFORCE with the one-step return:

θt+1=θt+α(Rt+1+γv^(St+1,w)−v^(St,w))∇θlogπ(At|St,θ)

Full algorithm can be formulated as follows:

  1. Initialize a differentiable policy parameterization π(a|s,θ).
  2. Initialize a differentiable state-value parameterization v^(s,w).
  3. Set step sizes α>0,β>0.
  4. Initialize policy weights θ and state-value weights w.
  5. Repeat:
    1. Initialize S - first state
    2. I=1
    3. While S is not terminal
      1. A∼π(⋅|S,θ)
      2. Take A, observe S′,R
      3. δ=R+γv^(S′,w)−v^(S,w)
      4. w=w+βδ∇wv^(S,w)
      5. θ=θ+αIδ∇θlogπ(A|S,θ)
      6. I=γI
      7. S=S′

Parameterization for Continuous Actions

Policy based methods offer practical ways of dealing with large actions spaces, even continuous spaces. All of the notes above are dealing with discrete actions, nevertheless, we begin with continuous ones from now on.

Instead of computing learned probabilities for each of many actions, we learn the statistics of the probability distributions. Take the Gaussian distribution for example. The actions set might be the real numbers with actions chosen from a Gaussian distribution:

p(x)=1σ2π−−√exp(−(x−μ)22σ2)

The value p(x) is the density of the probability at x.

To produce a policy parameterization, we can define the policy as the normal probability density over a real-valued scalar action, with mean and standard deviation give by parametric function approximators:

π(a|s,θ)=1σ(s,θ)2π−−√exp(−(a−μ(s,θ))22σ(s,θ)2)

Then we divide the policy weight vector into two parts: θ=[θμ,θσ]T. The mean can be approximated as a linear function:
μ(s,θ)=θμTϕ(s)

The standard deviation must always be positive and is better approximated as the exponential of a linear function:
σ(s,θ)=exp(θσTϕ(s))
\
where ϕ(s) is a basis function of some type. With these definitions, all the algorithms described above can be applied to learn to select real-valued actions.

Summary

Actor -Critic, which is a branch of TD methods, keeps a separate policy independent of the value function. The policy is called the actor and the value function is called the critic. An advantage of having a separate policy representation is that if there are many actions, or when the action space is continuous, there is no need to consider all actions’ Q-values in order to select one of them. A second advantage is that they can learn stochastic policies naturally. Furthermore, a prior knowledge about policy constraints can be used.

相关文章
|
机器学习/深度学习 人工智能 自然语言处理
AI视频大模型Sora新视角:从介绍到商业价值,全面解读优势
Sora是OpenAI于`2024年2月16日`发布的文生视频模型,`能够根据用户输入的提示词、文本指令或静态图像,生成长达一分钟的视频`,其中既能实现多角度镜头的自然切换,还包含复杂的场景和生动的角色表情,且故事的逻辑性和连贯性极佳。
|
Rust 安全 JavaScript
掌握Option类型(Rust中优雅处理空值的利器)
Option是Rust处理“可能无值”的核心类型,通过Some和None枚举强制显式处理空值情况,避免空指针异常。它结合unwrap、map、and_then等方法,实现安全、优雅的空值控制,是Rust内存安全设计的基石,助力开发者写出健壮的代码。来源:https://www.vpshk.cn/
|
人工智能 运维 安全
从电力营业厅到电网中枢:AI数字人+大模型升级电力电网智慧服务
AI数字人融合电力大模型,赋能智慧电网升级。从客服到运维,实现全链条智能化服务,提升效率与体验,助力电力行业迈向安全、高效、绿色的新型智能化时代。
522 0
|
移动开发 小程序 前端开发
小程序开发平台有哪些?小程序开发制作软件推荐
小程序开发方案全解析:5种主流方式与选择指南 小程序开发需根据技术能力、预算、时间及功能需求综合决策。以下为5种主流开发方案及适用场景分析:
26856 0
|
自然语言处理 安全 程序员
程序员推荐的12款实用模板免费的WordPress主题
本文介绍了12款实用的免费WordPress主题,包括Sydney、PopularFX、Zakra等,涵盖企业、博客、美食等多种风格。这些主题功能丰富,如自定义布局、预制模板、AMP兼容等,适合不同需求的用户。每款主题均有精美预览图展示,建议收藏以备后续使用。更多主题可访问ztmao.com。
1066 2
程序员推荐的12款实用模板免费的WordPress主题
|
机器学习/深度学习 算法 文件存储
YOLOv8改进 | 主干篇 | 利用MobileNetV3替换Backbone(轻量化网络结构)
YOLOv8改进 | 主干篇 | 利用MobileNetV3替换Backbone(轻量化网络结构)
1772 0
YOLOv8改进 | 主干篇 | 利用MobileNetV3替换Backbone(轻量化网络结构)
|
机器学习/深度学习 人工智能 算法
AI鱼类识别技术原理及示例代码
本文详细解析了AI鱼类识别的代码示例,涵盖深度学习框架选择、数据集处理、模型构建与训练优化全流程。内容包括技术选型对比(如TensorFlow、PyTorch、YOLO系列)、数据准备流程(开源数据集与标注规范)、完整代码示例(以PyTorch版ResNet50改进模型为例)以及模型优化策略(如量化压缩、知识蒸馏)。此外,还提供了典型应用场景(如渔业资源监测系统)、模型评估指标及开源项目推荐,并针对常见问题(小样本、水下模糊、类别不平衡等)提出解决方案。
1413 5
|
人工智能 自然语言处理
使用企业微信或公众号自动回复图片消息
AppFlow支持企业微信和公众号接收图片消息,并提供两种回复方式。方式一:直接回复图片消息,用户发送图片后立即收到回复,但无法继续追问。方式二:先保存图片,待用户发送文字后再一并处理并回复。配置步骤包括选择模板、配置鉴权信息、设置执行动作参数及发布连接流。详细操作可参考相关文档。
2179 1
使用企业微信或公众号自动回复图片消息
|
编解码 人工智能 自然语言处理