Skip to main content

RL 009

· 3 min read

Function Approximation​

v^(s,w)≈vπ(s)\hat{v}(s, \mathbf{w}) \approx v_\pi(s)

q^(s,a,w)≈qπ(s,a)\hat{q}(s, a, \mathbf{w}) \approx q_\pi(s, a)

  • Incremental methods for prediction
  • Model-free VFA: MC and TD targets

GPI, Generalized Policy Iteration​

  • Iterate between policy evaluation and policy improvement
  • Policy Evaluation: Approximate policy evaluation. q^(⋅,⋅,w)≈qπ\hat{q}(\cdot, \cdot, \mathbf{w}) \approx q_\pi
  • Policy Improvement: ϵ\epsilon-greedy policy improvement.

Types of Action-Value FA​

s→FA(w)→q^(s,w)s \to \text{FA}(\mathbf{w}) \to \hat{q}(s, \mathbf{w})
  • State Value Function Approximation
(s,a)→FA(w)→q^(s,a,w)(s, a) \to \text{FA}(\mathbf{w}) \to \hat{q}(s, a, \mathbf{w})
  • Action Value Function Approximation
    • q^(s,Left,w)=3.2\hat{q}(s, \text{Left}, \mathbf{w}) = 3.2
    • q^(s,Right,w)=8.7\hat{q}(s, \text{Right}, \mathbf{w}) = 8.7
s→FA(w)→q^(s,a1,w)⋯q^(s,an,w)s \to \text{FA}(\mathbf{w}) \to \hat{q}(s,a_1, \mathbf{w}) \cdots \hat{q}(s,a_n, \mathbf{w})
  • The network output is a vector of Q-values for each action.
  • More convenient to use discrete action spaces.
ActionQ-value
Left3.2
Right8.7
Jump5.3

Action VFA​

q^(s,a,w)≈qπ(s,a)\hat{q}(s, a, \mathbf{w}) \approx q_\pi(s, a)

  • Approximate the Action-value function.
  • Doing action aa at state ss, Approximate the Q-value of that action.

J=Eπ[(qπ(s,a)−q^(s,a,w))2]\mathcal{J} = \mathbb{E}_{\pi} \left[ (q_\pi(s, a) - \hat{q}(s, a, \mathbf{w}))^2 \right]

  • Minimize mean-squared error (MSE) between the approximate Q-value q^(s,a,w)\hat{q}(s, a, \mathbf{w}) and the true Q-value qπ(s,a)q_\pi(s, a).

Δw=α(qπ(s,a)−q^(s,a,w))∇wq^(s,a,w) \Delta \mathbf{w} = \alpha (q_{\pi}(s,a) - \hat{q}(s,a,\mathbf{w})) \nabla_{\mathbf{w}} \hat{q}(s,a,\mathbf{w})

  • Use SGD to find the local minimum.
  • qπ−q^q_{\pi} - \hat{q} tells us how much the prediction is off from the target.
  • ∇wq^(s,a,w)\nabla_{\mathbf{w}} \hat{q}(s,a,\mathbf{w}) tells us how each weight affects the predicted QQ-value.

Linear Action VFA​

x(s,a)=[x1(s,a)x2(s,a)⋮xn(s,a)]x(s, a) = \begin{bmatrix} x_1(s, a) \\ x_2(s, a) \\ \vdots \\ x_n(s, a) \end{bmatrix}
  • Feature vector is used to represent the state and action pair.

q^(s,a,w)≈x(s,a)Tw=∑jxj(s,a)wj\hat{q}(s, a, w) \approx x(s, a)^T w = \sum_j x_j (s, a) w_j

  • Predicted Q-value is a linear combination of the feature values. (sum of each feature value xjx_j multiplied by the weight wjw_j)
q^(s,a,w)=x(s,a)Twq^=x1w1+x2w2+⋯+xnwn\begin{aligned} \hat{q}(s, a, w) = x(s, a)^T w \\ \hat{q} = x_1w_1 + x_2w_2 + \cdots + x_n w_n \end{aligned}
  • x1,x2,⋯x_1, x_2, \cdots: features of the state and action pair.
  • w1,w2,⋯w_1, w_2, \cdots: weights that need to be learned.
  • derivative q^\hat{q} with respect to ww.
    • ∂q^∂w1=x1\frac{\partial \hat{q}}{\partial w_1} = x_1
    • ∂q^∂w2=x2\frac{\partial \hat{q}}{\partial w_2} = x_2
∇wq^=[x1x2⋮xn]=x(s,a)\nabla_w\hat{q} = \begin{bmatrix} x_1 \\ x_2 \\ \vdots \\ x_n \end{bmatrix} = x(s, a)
  • e.g. q^=2w1+5w2\hat{q} = 2w_1 + 5w_2, then ∇wq^=[25]\nabla_w\hat{q} = \begin{bmatrix} 2 \\ 5 \end{bmatrix}
Δw=α(qπ−q^)∇wq^=α(qπ−q^)x(s,a)=α(qπ(s,a)−q^(s,a,w))x(s,a)\begin{aligned} \Delta w \\ &= \alpha (q_{\pi} - \hat{q}) \nabla_w\hat{q} \\ &= \alpha (q_{\pi} - \hat{q}) x(s, a) \\ &= \alpha (q_{\pi}(s, a) - \hat{q}(s, a, w)) x(s, a) \end{aligned}