The main contents of this article: finite difference Policy gradient Monte-carlo Policy
In the last lesson we used parameters to estimate value functions and action-value functions, and when it comes to strategy, we only mention ϵ-greedy. In this lesson, we will directly parameterize the strategy πθ (s,a) =p (a|s,θ).
The reinforcement learning can be divided into value-based, policy-based and the combination of actor-critic. Value-based Strategies for enhancing learning (such as ϵ-greedy) are invariant, i.e., in a certain state, the choice of action is fixed. Policy-based's enhanced learning will learn different strategies, that is, how much probability to do in a certain state, and this probability may be constantly adjusted. Policy-based and value-based are shown in the following illustration:
The advantages of policy-based learning are: to converge to the optimal solution that can be achieved in high dimensional space or continuous behavior space to learn the stochastic strategy efficiently.
Disadvantage: Usually convergence to local optimal rather than global optimal evaluation a strategy is usually inefficient (this process may be slow, but with higher variability, there will be many ineffective attempts), and the variance is high
Then a strategy πθ (s,a) with parameter θ is given to determine the pros and cons of this strategy. There are usually three methods: using the initial value to judge: J1 (θ) =vπθ (S1) =EΠΘ[V1] Use average value: JAVV (theta) =∑sdπθ (s) vπθ (s) use the average reward for each time-step: Javr (theta) =∑sdπθ (s) ∑aπθ (s) (a) Ras, where dπθ (s) is the stationary distribution of the Markov chain of the strategy πθ (i.e., when the applied strategy πθ, the convergent distribution is achieved).
The gradient descent method is usually used to determine the value of θ by maximizing J (θ). Define policy gradients as:
∇θj (θ) =⎛⎝⎜⎜⎜⎜⎜⎜∂j (theta) ∂θ1⋮∂j (theta) ∂θn⎞⎠⎟⎟⎟⎟⎟⎟
The assumption that the policy πθ to zero is differentiable, and the gradient ∇θπθ (s,a) is known, and the ∇θlogπθ (S,A) is defined as the scoring function (score function). The relationship between the two is as follows:
∇θπθ (s,a) =∇θπθ (s,a) ∇θπθ (s,a) πθ (s,a) =πθ (s,a) ∇θlogπθ (s,a)
Next we consider a step-only MDP, which uses a policy gradient for it to drop. Πθ (s,a) represents a function on the parameter θ, and the mapping is P (a|s,θ). It goes a step forward in the state S, gaining reward r=rs,a. Then the reward for action A is πθ (s,a) rs,a, the weighted reward for the state S is ∑a∈aπθ (s,a) Rs,a, and the reward expectation and gradient available for the application strategy are:
J (θ) =eπθ[r]=∑s∈sd (s) ∑a∈aπθ (s,a) rs,a∇θj (theta) =∑S∈SD (s) ∑a∈aπθ (s,a) ∇θlogπθ (s,a) rs,a=eπθ[∇θlogπθ (s,a) R]
Then consider taking a multi-step MDP, using qπ (s,a) instead of the reward value r, for any differentiable strategy, the policy gradient is:
∇θj (theta) =eπθ[∇θlogπθ (s,a) qπθ (s,a)]
Monte-carlo policy gradients update parameters by sampling episode:
Using the stochastic gradient rise method to update the parameters, using the policy gradient method, using return VT as the unbiased estimate of qπθ (St,at). Then δθt=α∇θlogπθ (ST,AT) VT, as follows:
The variance of the Monte-carlo strategy gradient is higher, so we discard return to estimate the action-value function Q, but use critic to estimate Q. qπθ (s,a) ≈qw (s,a). This is an algorithm called actor-critic, with two sets of parameters. (1) The critic parameter is W. (2) The actor parameter is θ and is updated according to the direction recommended by critic.
Critic is actually evaluating the strategy. Suppose Q is about a linear combination of features: Qw (s,a) =ϕ (s,a) Tw. Critic updates the W,actor through the policy gradient according to the linear TD (0).
In the actor-critic algorithm, the strategy is estimated, which produces errors, but when the following two conditions are met, the policy gradient is accurate and the estimated value function does not violate the policy. ∇WQW (s,a) =∇θlogπθ (s,a) value function of the parameter w can minimize the error: ϵ=eπθ[(qπθ (s,a) −qw (S,a)) 2]
In addition, by subtracting a policy gradient from a baseline function B (s), you can reduce the variance without changing expectations. The proof does not change the expectation, is the proof added and is 0.
Eπθ[∇θlogπθ (s,a) b (s)]=∑s∈sdπθ (s) ∑a∇θπθ (s,a) b (s) =∑s∈sdπθ (s) b (s) ∇θ∑a∈aπθ (s,a) =0
The State value function vπθ (s) is a good baseline. Therefore, you can rewrite the value gradient function by using the Dominance function (Advantage function) aπθ (s,a).
aπθ (s,a) =qπθ (s,a) −vπθ (s) ∇θj (theta) =eπθ[∇θlogπθ (s,a) aπθ (s,a)]
The vπθ (s) is the real value function, the TD algorithm uses the Bellman equation to approximate the real value, and the error is δπθ=r+γvπθ (s′) −vπθ (s). This error is an unbiased estimate of the dominant function. So we can use this error to compute the policy gradient:
∇θj (theta) =eπθ[∇θlogπθ (s,a) δπθ]
This method only needs to critic, does not need actor.
Finally, we summarize the strategy gradient algorithm: