3. Policy Gradient
Q. Why do we use Action-value function over State-Value function in Model Free reinforcement learning

Q. ์์์ Action-value function Q๋ฅผ ์ ๋ฐ์ดํธ ํ ๋ total discounted return Gt๋ฅผ Q๋ฅผ ์ด์ฉํด ๊ทผ์ฌํ๋ค.
State-value function V์ Q ๋ชจ๋ ์์ผ๋ก์ ๊ธฐ๋๋๋ return์ ๋ํ ํจ์์ด์ง๋ง ํด๋น state์์ ์ป์ ์ ์๋ return์ธ์ง, ํด๋น state์ ์ด๋ค action์์ ์ป์ ์ ์๋ return ์ธ์ง์ ๋ํด ์ฐจ์ด๊ฐ ์๋ค.
์ด ๋, V์์ ์ํ๋งํ ์ ์์๊น? ์ model-free์์๋ V๋ณด๋ค Q๊ฐ ํ์ํ ๊น?
A. Model-free ์ ๊ทผ ๋ฐฉ์์ ์ฌ์ฉํ์ฌ ์ฃผ์ด์ง policy์ ๋ํ State-value function V๋ฅผ ํ์ตํ ์ ์๋ค. ํ์ง๋ง ํ์ตํ V๋ฅผ ์ฌ์ฉํ์ฌ action์ ์ ํํ ์๋ ์๋ค.
๊ทธ ์ด์ ๋ action์ ๋ฐ๋ผ ๋ค์์ ์ด๋ค state๊ฐ ๋ฐ์ํ ์ง ์์ธกํ ๋ฐฉ๋ฒ์ด ์๊ธฐ ๋๋ฌธ์ด๋ค. ์ด๋ ๋ชจ๋ action ๊ฐ์ ์ฌ์ฉํด์ผ ํ๋ ๋ชฌํ ์นด๋ฅผ๋ก(Monte-Carlo) ์ ์ด, SARSA ๋ฐ Q-๋ฌ๋๊ณผ ๊ฐ์ ๊ฒฝ์ฐ์์ ๋ฌธ์ ๋ค. Actor-Critic ๋ฐฉ๋ฒ์์์ ๊ฐ์ด policy gradient์ ๊ฒฐํฉํ๋ฉด ๋ณ๋์ ์ ์ด ๊ฐ๋ฅํ policy์ ์ ๊ณตํ๊ธฐ ๋๋ฌธ์ ๋ฌธ์ ๊ฐ ๋์ง ์๋๋ค.
RL Agent Taxonomy

RL ์๊ณ ๋ฆฌ์ฆ์๋ ์๋์ ๊ฐ์ ์ข ๋ฅ๊ฐ ์๋ค.
- Policy gradients: ์ ๋ํด ๋ฏธ๋ถํ์ฌ
- REINFORCE
- Natural policy gradient
- Trust Region Policy Optimization (TRPO)
- Value-based RL: ์ต์ policy์ value function์ด๋ Q-function์ ์ถ์
- Q-learning, DQN
- Temporal Difference Learning
- Fitted value iteration
- Actor-critic RL: ํ์ฌ policy์ value function์ด๋ Q-function์ ์ถ์ ํ์ฌ policy ๊ฐ์ ์ ์ฌ์ฉ
- Asynchronous advantage actor-critic (A3C)
- Soft Actor-Critic (SAC), DDPG
- Model-based RL: transition model์ ์ถ์ ํ์ฌ planning์ ์ฌ์ฉํ๊ฑฐ๋ policy ๊ฐ์ ์ ์ฌ์ฉ
- Dyna
- Gaussian Process dynamic programming / PILCO (https://mlg.eng.cam.ac.uk/pub/pdf/DeiRas11.pdf)
Model-based algorithms
Diagram

Policy๋ฅผ ๊ฐ์ ํ๊ธฐ ์ํ ๋ช๊ฐ์ง ์ต์
- Model๋ฅผ ์ด์ฉํ๋ค(policy X)
- ๊ฒฝ๋ก ์ต์ ํ ํน์ ์ต์ ์ ์ดํ๋ค
- Discrete action spaces ์์ planningํ๋ค.( e.g. Monte Carlo tree search)
- Policy์ gradient๋ก ์ญ์ ํ(backpropagate)ํ๊ธฐ
- ์ฐ์์ ์ธ ์ต์ ํ ๋ฐฉ์์ ์ฌ์ฉ
- numerically unstable ํ๊ธฐ ๋๋ฌธ์ ์ฝ๊ฐ์ trick์ด ํ์ํ๋ค
- Value function์ ํ์ตํ๊ธฐ ์ํด model์ ์ฌ์ฉํ๋ค
- Dynamic programming
- Generate simulated experience for model-free learner
Question
- ์์ ๋ด์ฉ๋ค์ด ์ด๋ค ๋ป์ธ์ง ์ ๋๋ก ์ดํด ๋ชปํจ
Model-based RL์ ๋ฐ์ดํฐ๋ก๋ถํฐ MDP๋ฅผ ์ถ์ ํ๋ค. ๋ฐ๋ผ์ ๋ฐ์ดํฐ๋ฅผ ํจ์จ์ ์ผ๋ก ์ฌ์ฉํ์ง๋ง ๋ณต์กํ(high-demensional) state space์์๋ ์ข์ง ์๋ค.

Value function-based algorithms

- Learnt value function
- Implicit policy (e.g. - greedy)
- Examples
- Q-learning, DQN
- Temporal Difference Learning
- Fitted value iteration
Direct policy gradients

Policy based์๋
- No value function
- Learnt policy
- Examples
- REINFORCE
- Natural policy gradient
- Trust Region Policy Optimization (TRPO)
Actor-critic: value functions + policy gradients

- Learnt value function
- Learnt policy
- Examples
- Asynchronous advantage actor-critic (A3C)
- Soft Actor-Critic (SAC), DDPG
์ ์ด๋ ๊ฒ ๋ง์ ์๊ณ ๋ฆฌ์ฆ๋ค์ด ์๋ ๊ฑธ๊น?
-
๋ค๋ฅธ tradeoffs
์ฌ๋ฌ ๋ฌธ์ ๋ค์ด ์๊ธฐ ๋๋ฌธ์ ๊ฐ๊ฐ์ ๋ฌธ์ ์ ๋ ๋์ ๋ฐฉ๋ฒ๋ค์ด ๋ค๋ฅด๋ค.
- Sample efficiency: ์ข์ policy๋ฅผ ์ป๊ธฐ ์ํด ์ผ๋ง๋ ๋ง์ sample๋ค์ด ํ์ํ์ง
- ์๊ณ ๋ฆฌ์ฆ์ด off policy์ธ์ง on policy์ธ์ง์ ๋ฐ๋ผ ๋ค๋ฅด๋ค.
- Off policy: ์๋ก์ด ์ํ๋ค์ ๋ง๋ค์ง ์๊ณ ๋ policy๋ฅผ ๊ฐ์ ํ ์ ์๋ค.
- On policy: ๋งค๋ฒ policy๊ฐ ๋ฐ๋๊ธฐ ๋๋ฌธ์ ์๋ก์ด sample์ ๋ง๋ค์ด์ผ ํ๋ค.
- ์๊ณ ๋ฆฌ์ฆ ๋ณ๋ก ๋น๊ต

- ํจ์จ์ ์ด๊ณ ์ ์ ์ํ๋ก๋ ์ถฉ๋ถํ ์๋ก ๋ง์ ๊ฐ์ ์ด ํ์ํ๋ค.(๋๋ก๋ ์ข์ ๋ชจ๋ธ์ ์ป๊ธฐ ์ํ ์๊ฐ์ด ๋ ํ์ํ ์ ์์.)
- Stability & easy of use
- Sample efficiency: ์ข์ policy๋ฅผ ์ป๊ธฐ ์ํด ์ผ๋ง๋ ๋ง์ sample๋ค์ด ํ์ํ์ง
-
Different assumptions
๋ฌธ์ ์ ๋ํ ๊ฐ์ ๋ค์ด ๋ค๋ฅด๋ค.
- Stochastic or deterministic?
- Continuous or discrete?
- Episodic of infinite horizon?
-
Different things are easy or hard in different settings
๊ฐ๊ฐ์ด ๊ฐ์ง ์ฅ๋จ์ (1๋ฒ์ด๋ ์ ์ฌ)
- Easier to represent the policy?
- Easier to represent the model?
On-Policy Control with SARSA
SARSA๋ State-Action-Reward-State-Action์ ์ฝ์๋ก on-policy TD control method์ด๋ค.

Policy improvement์๋ - greedy ๋ฐฉ์์ ์ฌ์ฉํ๋ค. ์ด๋ฅผ ํตํด Action์ ์ ํํ๊ณ ์ด๋ฅผ ๋ฐ๋ณตํ๋ค.
Off-Policy Control with Q-Learning
behaviour, target policies๋ฅผ ๋ชจ๋ improve ํ์ง ์๋ ๊ฒ์ off-policy ๋ฐฉ์์ด๋ค.
Q-learning์ SARSA์ ์ ์ฌํ์ง๋ง policy๋ฅผ ์ด์ฉํด ๋ค์ action์ ์ ํํ๊ธฐ ๋ณด๋ค greedyํ ๋ฐฉ์์ ์ทจํ๋ค.

์์ SARSA pseudocode์ ๋น๊ตํด๋ณด๋ฉด Action์ updateํ์ง ์๋๋ค. ๋์ policy๋ก๋ถํฐ ๊ณ์ Action์ ์ ํํ๋ค.
Policy Gradient
ํฐ MDP๋ฌธ์ ๋ฅผ ํธ๋ ๊ฒ์ ๋ฌธ์ ๋ ๋๋ฌด ๋ง์ state์ action์ ์ ์ฅํ๊ณ ์์ด์ผ ํ๋ ๊ฒ๊ณผ ๊ฐ๊ฐ์ state์ ๋ํด ํ์ตํ๋ ๊ฒ์ด ๋๋ฌด ๋๋ฆฌ๋ค๋ ๊ฒ์ด๋ค.
์ด๋ฅผ ํด๊ฒฐํ๊ธฐ ์ํด
- function approximation์ ์ด์ฉํด value function์ ์ถ์ ํ๋ค.
- ๊ด์ฐฐ๋ state๋ฅผ ํตํด ๊ด์ฐฐ๋์ง ์์ state๋ค์ generalizeํ๋ค.
- MC๋ TD ๋ฐฉ์์ ํตํด ๋ฅผ ์ ๋ฐ์ดํธ ํ๋ค.
Function approximation์๋ ์ฌ๋ฌ ๋ฐฉ๋ฒ์ด ์๋ค.
- Linear combinations of features
- Neural network
- Decision tree
- Nearest neighbour
- Fourier / wavelet basis
๊ทธ๋ฆฌ๊ณ ๋ฏธ๋ถ๊ฐ๋ฅํ ์ข ๋ฅ๋ค์ ๊ณ ๋ คํ๋ค๋ฉด Linear combinations of features, NN ๊ทธ๋ฆฌ๊ณ Gaussian process๊ฐ ์๋ค.
Advantages of Policy-Based RL
์์ Policy-based RL์ ๋ํด ๊ฐ๋ตํ ์์๋ณด์๋ค. ์ด Policy-based RL์ ์ฅ๋จ์ ์ ์๋์ ๊ฐ๋ค.
Advantages
- ๋์ ์๋ ด์ฑ
- high-dimensional์ด๋ continuousํ action space์์ ํจ์จ์ ์ด๋ค
- Stochastic policy๋ฅผ ํ์ตํ ์ ์๋ค. (??)
Disadvantages
- local optimum์ผ๋ก ์๋ ดํ ๊ฐ๋ฅ์ฑ์ด ๋๋ค
- policy evaluation์ด ๋นํจ์จ์ ์ด๋ค.
Policy Optimization
Policy-based RL์ ์ต์ ํ ๋ฌธ์ ์ด๋ค(an optimization problem)
์ด๋ฌํ ๋ฌธ์ ๋ฅผ ํธ๋ ๋ฐฉ์์๋ ์ข ๋ฅ๊ฐ ์ฌ๋ฌ๊ฐ์ง ์๋ค.
Gradient๋ฅผ ์ฌ์ฉํ์ง ์๋ ๋ฐฉ์์๋
- Hill climbing
- Simplex / amoeba / Nelder Mead
- Genetic algorithms
Gradient๋ฅผ ์ฌ์ฉํ๋ฉด ์ฃผ๋ก ํจ์จ์ ์ด๋ค
- Gradient ascent
- Conjuage gradient
- Quasi-newton