【RL】Basic Concepts in Reinforcement Learning

2024-02-06 23:52

本文主要是介绍【RL】Basic Concepts in Reinforcement Learning,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!

Lecture1: Basic Concepts in Reinforcement Learning

MDP(Markov Decision Process)

Key Elements of MDP

Set

State: The set of states S \mathcal{S} S(状态 S \mathcal{S} S的集合)

Action: the set of actions A ( s ) \mathcal{A}(s) A(s) is associated for state s ∈ S s \in \mathcal{S} sS(对应于状态 s ∈ S s \in \mathcal{S} sS 的行为集合 A ( s ) \mathcal{A(s)} A(s)

Reward: the set of rewards R ( s , a ) \mathcal{R}(s, a) R(s,a)(对应于某一状态 s ∈ S s \in \mathcal{S} sS 和在该状态的某一行为 a ∈ A ( s ) a \in \mathcal{A}(s) aA(s)的奖励分数,是一个实数)

Probability distribution

State transition probability: at state s s s ,taking action a a a, the probability to transit to state s ′ s' s is (状态转移概率,在状态 s s s,行为 a a a,转移到状态 s ′ s' s的概率)
p ( s ′ ∣ s , a ) p(s' | s, a) p(ss,a)
Reward probability: at state s s s, taking action a a a, the probability to get reward r r r is (在状态 s s s,行为 a a a,得到的奖励分数 r r r
p ( r ∣ s , a ) p(r | s, a) p(rs,a)

Policy

Policy: at state s s s, the probability to choose action a a a is(在状态 s ∈ S s \in \mathcal{S} sS,选择状态 a ∈ A ( s ) a \in \mathcal{A}(s) aA(s)的概率)
π ( a ∣ s ) \pi (a | s) π(as)

Markov Property

Markov property: memoryless property (无记忆性;无后效性)
p ( s t + 1 ∣ a t + 1 , s t , . . . , a 1 , s 0 ) = p ( s t + 1 ∣ a t + 1 , s t ) p ( r t + 1 ∣ a t + 1 , s t , . . . , a 1 , s 0 ) = p ( r t + 1 ∣ a t + 1 , s t ) p(s_{t + 1} | a_{t + 1}, s_t, ..., a_1, s_0) = p(s_{t + 1} | a_{t + 1}, s_t) \\ p(r_{t + 1} | a_{t + 1}, s_t, ..., a_1, s_0) = p(r_{t + 1} | a_{t + 1}, s_t) p(st+1at+1,st,...,a1,s0)=p(st+1at+1,st)p(rt+1at+1,st,...,a1,s0)=p(rt+1at+1,st)

Grid-World Example

以grid-world为例对上面例子进行解释

请添加图片描述

Key Elements

state: 每个表格所在的位置即为state, 因此其有9个state s 1 , s 2 , . . . , s 9 s_1, s_2, ..., s_9 s1,s2,...,s9

每个表格所在的位置即为state, 因此其有9个state s 1 , s 2 , . . . , s 9 s_1, s_2, ..., s_9 s1,s2,...,s9

state space S = { s i } i = 1 9 \mathcal{S} = \{ s_i \}^9_{i=1} S={si}i=19

action:对于每一个state,有五个可能的action

  • a 1 a_1 a1: move upwards
  • a 2 a_2 a2: move rightwards
  • a 3 a_3 a3: move downwards
  • a 4 a_4 a4: move leftwards
  • a 5 a_5 a5: stay unchanged

Action space of a state:特定state其所有可能的action的集合 A ( s ) = { a i } i = 1 5 \mathcal{A}(s)= \{ a_i \}^5_{i=1} A(s)={ai}i=15

state transition

当采取action时,agent可能会从一个state转移到另一个state。例如 s 1 ⟶ a 2 s 1 s_1 \stackrel{a_2}{\longrightarrow}s_1 s1a2s1

  • tubular representation: 使用表格表示state transition

    请添加图片描述

  • state transition probability: 使用概率描述state transition

    • intuition: 在state s 1 s_1 s1,如果选择action a 2 a_2 a2,下一个state是 s 2 s_2 s2

    • math:
      p ( s 2 ∣ s 1 , a 2 ) = 1 p ( s i ∣ s 1 , a 2 ) = 0 ∀ ≠ 2 \begin{align*} &p(s_2 | s_1, a_2) = 1\\ &p(s_i | s_1, a_2) = 0 \;\;\; \forall \ne 2 \end{align*} p(s2s1,a2)=1p(sis1,a2)=0=2

Policy

告诉agent在某个state下要采取什么action。

直观表示如下图所示:

在这里插入图片描述

基于以上policy,针对不同的start area和end area,最优路径如下:

在这里插入图片描述

mathematical representation: 使用条件概率表示
π ( a 1 ∣ s 1 ) = 0 π ( a 2 ∣ s 1 ) = 1 π ( a 3 ∣ s 1 ) = 0 π ( a 4 ∣ s 1 ) = 0 π ( a 5 ∣ s 1 ) = 0 \pi(a_1 | s_1) = 0\\ \pi(a_2 | s_1) = 1 \\ \pi(a_3 | s_1) = 0 \\ \pi(a_4 | s_1) = 0 \\ \pi(a_5 | s_1) = 0 \\ π(a1s1)=0π(a2s1)=1π(a3s1)=0π(a4s1)=0π(a5s1)=0
其上为确定概率,也有随机概率:

在这里插入图片描述

π ( a 1 ∣ s 1 ) = 0 π ( a 2 ∣ s 1 ) = 0.5 π ( a 3 ∣ s 1 ) = 0.5 π ( a 4 ∣ s 1 ) = 0 π ( a 5 ∣ s 1 ) = 0 \begin{align*} &\pi(a_1 | s_1) = 0\\ &\pi(a_2 | s_1) = 0.5 \\ &\pi(a_3 | s_1) = 0.5 \\ &\pi(a_4 | s_1) = 0 \\ &\pi(a_5 | s_1) = 0 \\ \end{align*} π(a1s1)=0π(a2s1)=0.5π(a3s1)=0.5π(a4s1)=0π(a5s1)=0
tabular representation: 使用表格表示

在这里插入图片描述

Reward

在采取某个action后得到的实数

  • 正数代表鼓励去采取这种action
  • 复数代表惩罚采取这种action
  • 零代表不鼓励不惩罚

对于grid-world样例,reward可以设计成以下四种:

  • 如果agent尝试逃出表格边界: r r o u n d = − 1 r_{round}=-1 rround=1
  • 如果agent尝试进入禁区(蓝色方块): r f o r b i d = − 1 r_{forbid}=-1 rforbid=1
  • 如果agent到达目标单元: r t a r g e t = 1 r_{target}=1 rtarget=1
  • 其他情况: r = 0 r=0 r=0

reward可以理解为human-machine interface,通过它我们可以引导agent按照我们的期望行事。

  • tabular representation:

    在这里插入图片描述

  • Mathematical description:
    p ( r = − 1 ∣ s 1 , a 1 ) = 1 p ( r ≠ − 1 ∣ s 1 , a 1 ) = 0 p(r=-1 | s_1, a_1) = 1 \\ p(r \ne -1 | s_1, a_1) = 0 p(r=1∣s1,a1)=1p(r=1∣s1,a1)=0

Trajectory and Return

如下图:

在这里插入图片描述

trajectory 是一个state-action-reward 链:
s 1 → r = 0 a 2 s 2 → r = 0 a 3 s 5 → r = 0 a 3 s 8 → r = 1 a 2 s 9 s_1 \xrightarrow[r=0]{a_2} s_2\xrightarrow[r=0]{a_3} s_5\xrightarrow[r=0]{a_3} s_8\xrightarrow[r=1]{a_2} s_9 s1a2 r=0s2a3 r=0s5a3 r=0s8a2 r=1s9
return是沿该轨迹收集的所有奖励的总和:
return = 0 + 0 + 0 + 1 = 1 \text{return}=0 + 0 + 0 + 1 = 1 return=0+0+0+1=1

Discounted return

对于下图trajectory :

在这里插入图片描述

其可以定义为:
s 1 → a 2 s 2 → a 3 s 5 → a 3 s 8 → a 2 s 9 → a 5 s 9 → a 5 s 9 . . . s_1 \xrightarrow[]{a_2} s_2 \xrightarrow[]{a_3} s_5 \xrightarrow[]{a_3} s_8 \xrightarrow[]{a_2} s_9 \xrightarrow[]{a_5} s_9 \xrightarrow[]{a_5} s_9 ... s1a2 s2a3 s5a3 s8a2 s9a5 s9a5 s9...
return为:
return = 0 + 0 + 0 + 1 + 1 + 1 + . . . = ∞ \text{return} = 0 + 0 + 0 + 1 + 1 + 1 + ... = \infty return=0+0+0+1+1+1+...=
需要引入discount rate γ ∈ [ 0 , 1 ) \gamma \in [0, 1) γ[0,1)

discount return:
discount return = 0 + γ 0 + γ 2 0 + γ 3 1 + γ 4 1 + . . . = γ 3 ( 1 + γ + γ 2 + . . . ) = γ 3 1 1 − γ \begin{align*} \text{discount return} &= 0 + \gamma0 + \gamma^20 + \gamma^31 + \gamma^41 + ... \\ & = \gamma^3(1 + \gamma + \gamma^2 + ...)\\ &=\gamma^3 \frac{1}{1 - \gamma} \end{align*} discount return=0+γ0+γ20+γ31+γ41+...=γ3(1+γ+γ2+...)=γ31γ1

  • 如果 γ \gamma γ接近于0,则discounted return的值主要由近期获得的reward决定。
  • 如果 γ \gamma γ接近于1,则discounted return的值主要由远期获得的reward决定。

Episode

当遵循policy与环境交互时,agent可能会停在某些terminal states。 由此产生的轨迹称为一个episode(或一次trail)。

在这里插入图片描述

如上图,episode为:
s 1 → r = 0 a 2 s 2 → r = 0 a 3 s 5 → r = 0 a 3 s 8 → r = 1 a 2 s 9 s_1 \xrightarrow[r=0]{a_2} s_2\xrightarrow[r=0]{a_3} s_5\xrightarrow[r=0]{a_3} s_8\xrightarrow[r=1]{a_2} s_9 s1a2 r=0s2a3 r=0s5a3 r=0s8a2 r=1s9

一个episode通常被假设为一个有限的trajectory。 具有episodes的任务称为episodic tasks

有些任务可能没有终止状态(terminal states),这意味着与环境的交互永远不会结束。 此类任务称为连续任务(continuing tasks)

事实上,可以通过将episodic 任务转换为连续任务,以统一的数学方式来处理episodic任务和连续任务。

  • 选择1:将目标状态视为特殊的吸收状态(absorbing state)。 一旦agent达到吸收状态,它就永远不会离开。 随之而来的奖励 r = 0 r = 0 r=0
  • 选择2:将目标状态视为具有策略的正常状态。 agent仍然可以离开目标状态,并在进入目标状态时获得 r = + 1 r = +1 r=+1

选择2是较多人选择的方法。

Markov decision process (MDP)

在这里插入图片描述

grid-world可以抽象为一个更通用的模型,即马尔可夫过程。

圆圈代表state,带箭头的链接代表state transition。
一旦给出policy,马尔可夫决策过程就变成马尔可夫过程。



以上内容为B站西湖大学智能无人系统 强化学习的数学原理 公开课笔记。

这篇关于【RL】Basic Concepts in Reinforcement Learning的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!



http://www.chinasem.cn/article/685927

相关文章

Deep Learning复习笔记0

Key Concept: Embedding: learned dense, continuous, low-dimensional representations of object 【将难以表示的对象(如图片,文本等)用连续的低维度的方式表示】 RNN: Recurrent Neural Network -> for processing sequential data (time se

CesiumJS【Basic】- #008 通过canvas绘制billboard

文章目录 通过canvas绘制billboard1 目标2 实现 通过canvas绘制billboard 1 目标 通过canvas绘制billboard 2 实现 /** @Author: alan.lau* @Date: 2024-06-16 11:15:48* @LastEditTime: 2024-06-16 11:43:02* @LastEditors: al

GIM: Learning Generalizable Image Matcher From Internet Videos

【引用格式】:Shen X, Yin W, Müller M, et al. GIM: Learning Generalizable Image Matcher From Internet Videos[C]//The Twelfth International Conference on Learning Representations. 2023. 【网址】:https://arxiv.or

5.How Fast Should You Be When Learning?(你应该用多快的速度学习? (一))

Normally when I talk about learing quickly, I’m using speed as a synonym for efficiency.Use more effective methods and you’ll learn more in less time.All else being equal, that means you’re learing fa

【Deep Learning】Meta-Learning:训练训练神经网络的神经网络

元学习:训练训练神经网络的神经网络 本文基于清华大学《深度学习》第12节《Beyond Supervised Learning》的内容撰写,既是课堂笔记,亦是作者的一些理解。 1 Meta-Learning 在经典监督学习中,给定训练数据 { ( x i , y i ) } i \{(x_i,y_i)\}_i {(xi​,yi​)}i​,我们需要训练一个神经网络 f f f使得 f (

【Deep Learning】Self-Supervised Learning:自监督学习

自监督学习 本文基于清华大学《深度学习》第12节《Beyond Supervised Learning》的内容撰写,既是课堂笔记,亦是作者的一些理解。 在深度学习领域,传统的监督学习(Supervised Learning)的形式是给你输入 x x x和标签 y y y,你需要训练一个基于参数 θ \theta θ的神经网络 f θ ( x ) f_\theta(x) fθ​(x)使其能

Representation Learning on Network 网络表示学习笔记

Embedding Nodes Encoder-decoder ViewEncoding Methods 1 Factorization based2 Random Walk based3 Deep Learning based 网络表示学习(Representation Learning on Network),一般说的就是向量化(Embedding)技术,简单来说,就是

Apple - Core Foundation Design Concepts

本文翻译整理自:Core Foundation Design Concepts(更新日期:2013-12-16 https://developer.apple.com/library/archive/documentation/CoreFoundation/Conceptual/CFDesignConcepts/CFDesignConcepts.html#//apple_ref/doc/uid/1

AI播客下载:Machine Learning Street Talk(AI机器学习)

该频道由 Tim Scarfe 博士、Yannic Kilcher 博士和 Keith Duggar 博士管理。 他们做了出色的工作,对每个节目进行了彻底的研究,并与机器学习行业中一些受过最高教育、最全面的嘉宾进行了双向对话。 每一集都会教授一些新内容,并且提供未经过滤、毫不掩饰的技术对话。 他们列出的人工智能研究人员名单令人印象深刻,他们总是能提供有趣的对话。 之前的一些嘉宾包括 Je

【读论文】Learning perturbations to explain time series predictions

文章目录 Abstract1. Introduction2. Background Work3. Method4. Experiments4.1 Hidden Markov model experiment4.2 MIMIC-III experiment 5. ConclusionReferences 论文地址:Learning Perturbations to Explain