今年1 月的目標想複習三下時學的 RL,主要的參考教材為李宏毅老師的 DRL 8 講及 Sergey 在 Berkeley 開的 CS294。
先讓我們從 Policy Gradient 開始吧!
Terminology
這裡假設讀者熟悉 RL 的基本概念 (env/action/state 的交互作用及相關名詞)。
Policy
Policy 為 given state ,採取 action 的機率。而我們可以以一組參數 去描述。
Given 一個固定的 policy 的 agent (或者又叫做 actor),我們讓其去與環境互動,每玩一次(一個 episode) 會收集到一個序列 {},稱為 trajectory ,並會得到一個 final reward
Value Function
Given policy, expected return from state
Note: 是指 Given policy,特定 trajectory 被 sample 出來的機率
Action-Value Function
Given policy, expected return when taking at ,之後稱其為 Q function
Goal
我們想找到一個最好的 policy 去 maximize 最後得到 reward 的期望值 ( optimize 的目標)
Optimal value function
Note: exploration 只在 training 的時候做,一旦摸清整個環境(i.e optimal policy is claimed),在決定時便不用再加上隨機性了 (so that's why I directly write down )
Decoding Problem (how to construct such policy)
Only considered in non policy-based method, more discussion on Lec3
Learning Problem
而後續討論的演算法,都是圍繞著如何找出這樣符合optimal value equation 的 policy。
- DP-based Planning: value iteration, policy iteration
- Discrete action/state and is small (i.e tabular): \
- MDP is known
- Contraction Mapping Theorem 可以 prove 最佳解的存在性) see Lec3
- Value-based Learning: Monte-Carlo RL, Temporal-Difference (bootstrapping) RL
- In generate, discrete action (since we need to choose argmax from )
- MDP is unknown
- Tradeoff between biased or not and low/high variance
- Policy-based Learning: REINFORCE
- Continuous action/state (since we usually use NN as hypothesis set)
- MDP is unknown
- Variance reduction trick (see Lec2)
- Combined with value-based algorithm: Actor-Critic (see Lec5)
How to update in Policy Gradient
Optimal policy 所對應到的 滿足以下
利用 Graient Descent。
$$ \begin{align} \nabla_\theta J(\theta) &= \int \color{blue}{\nabla_\theta[\pi_\theta(\tau)]} r(\tau) d\tau\\ &= \int \color{blue}{\pi_\theta \nabla_\theta[\log \pi_\theta(\tau)]}r(\tau) d\tau \\ &= \mathbb{E}_{\tau \; \sim \; \pi_\theta(\tau)} \nabla_\theta[\log\pi_\theta(\tau)]r(\tau) \\ \end{align} $$
直覺來說,相同於傳統 supervised learning 的 setting ,但更新的步伐大小,跟 reward 成線性關係\
(i.e try & error,哪個方向好就走多一點,weighted by reward)
但上述的 無法很直覺地用於 policy 的更新,所以我們做了以下改動
- Policy Gradient Theorem 告訴我們
For any differentialble policy , for any of the policy objective functions …,\
- 我們是對每一個 做更新 (因 能管的也只有 Given ,選擇採取 的機率)
- 在大多數情況,無法窮舉所有可能的 去求期望值,只能用 sampling 去估計
Note: 在最基本的 policy gradient 中,我們用 來作為 的 unbiased estimation。
Drawback
- Online policy,need to resample when is updated Data collection 費時
- Sample is finite variance 大,難 train 。