📔 筆記內容: 赵世钰老師 “强化学习的数学原理” 課程
很高興我初次學習 RL 就是透過這門課, 讓我扎實理解其背後的數學和邏輯
老實說 RL 方法很多很雜, 套句趙老師的話, RL 數學很深, 結構性又很強, 一環扣一環
如果沒有這堂課這樣循序剖析和從數學出發解釋的話, 我自己應該很難入門, 謝謝這門課的赵世钰老師! 🙏🏻
筆記方式盡量濃縮, 想詳細看怎麼推導或更多說明點擊超連結即可.
挖坑給自己: 下一次讀 Kevin Murphy 的 reinforcement learning [arxiv]

RL 的環境設定 reward $r$, action $a$, state $s$, policy $\pi(a|s)$ 等的初步介紹自行查資料即可
重點是套用 Markov Decision Process (MDP) 的框架.
Markov Decision Process (MDP) 給定前一次 state $s$ 和前一次 action $a$, 我們可以定義 state 和 reward 的 distribution:
$$ p(s',r|s,a)\triangleq Pr\{S_t=s',R_t=r|S_{t-1}=s,A_{t-1}=a\} $$
For all $s',s\in\mathcal{S}$, $r\in\mathcal{ R}$, and $a\in\mathcal{A}(s)$. Action space 是從 state 定義出來的.
所以 $p:\mathcal{S}\times\mathcal{R}\times\mathcal{S}\times\mathcal{A}\rightarrow[0,1]$. ($p$ 稱 dynamics function of MDP)
知道這個四元 $p(s',r|s,a)$ 的機率就稱 with model 的 RL 方法, 反之就是 without model 的方法
Return $G_t$ 定義為 (有些人稱 total rewards)
$$ \begin{align*} G_t\triangleq R_{t+1}+\gamma R_{t+2}+\gamma^2R_{t+3}+\cdots \\ =\sum_{k=0}^\infty\gamma^kR_{t+k+1}=R_{t+1}+\gamma G_{t+1} \end{align*} $$
Return 取期望值的話 (expected return) 就稱 Value (價值) ← RL 目標就是找到能最大化 value 的 policy $\pi(a|s)$.
| State Value $v_\pi(s)$ | Action Value $q_\pi(s,a)$ | |
|---|---|---|
| Definition | $v_\pi(s)\doteq\mathbb{E}_\pi[G_t | S_t=s],\quad \forall s\in\mathcal{S}$ |
| Elementwised form | ${\color{orange}{v_\pi(s)}} = \sum_a\pi(a | s) |
| {\color{orange}{\left( | ||
| \sum_{r}p(r | s,a)r + \gamma\sum_{s'}p(s' | s,a)v_\pi(s') |
| \right)}}$ | ||
| $=\sum_a\pi(a | s) {\color{orange}{q_\pi(s,a)}},\quad\forall s\in\mathcal{S}$ | 從左邊橘色可看到 |
| $q_\pi(s,a)= | ||
| \sum_{r}p(r | s,a)r + \gamma\sum_{s'}p(s' | s,a)v_\pi(s') |
| ,\quad\forall s\in\mathcal{S}$ | ||
| Expectation form | $v_\pi(s)=\mathbb{E}[R_{t+1}+\gamma v_\pi(S_{t+1}) | S_t=s],\quad \forall s\in\mathcal{S}$ |
| Matrix Vector form | $v_\pi=r_\pi+\gamma P_\pi v_\pi$ |