[Reinforcement Learning Algorithm] Proximal Policy Optimization (PPO)
Fundamentals
Value-Based
This category includes methods such as Q-Learning and DQN.
(1) Q and V Values
- V value: The sum of the rewards from all future states given the current state. (Make N copies of the current state. For each state, select a different possible action according to the policy, continue until the final state, and calculate the average of the N rewards.) It measures how reasonable the current policy’s action selection is.
- Q value: Measures the value of an action node. (Make N copies of the current action. Let each action continue interacting with the environment, record the rewards obtained, and calculate the average of the N rewards.) The Q value is not directly related to the policy but is related to the environment’s state transition probabilities.
(2) Monte Carlo
For a given state, first proceed from the current state to the end (the policy may generate different actions, creating different branches), calculate all the rewards r, and then backtrack to calculate the G value.
- G value: . The G value represents the total return from a state to the final state.
- The V value is the average of the G values from N copies of state S. (It is closely related to the policy. With different policies, the probabilities that the N copies of state S produce action A are different.)
The disadvantage is that every state must proceed from beginning to end each time, so updating the G value may take a long time. An estimation method is therefore considered:
That is, the V value estimated at the previous time step uses the learning-rate hyperparameter to move the V value closer to . This way, whenever any state reaches the end and returns a G value, an update can be performed.
However, this method still requires a branch to reach the final state before an update can be performed. This led to the temporal-difference (TD) algorithm.
Unlike Monte Carlo, the TD algorithm only needs to proceed N steps before it can start backtracking and updating. That is, it assumes that the final state has been reached after N steps. If no branch has ever visited the final state, set the state to 0. If a branch has visited this state, the V value of this state is its current value.
Here, is equivalent to the value calculated by Monte Carlo, and represents the V value of the state after N steps.
Policy-Based
(1) Policy Gradient
The idea behind policy gradient (PG) is to directly use a neural network that takes state as input and outputs action. This process does not calculate Q.
The goal of PG is to maximize the total reward over the entire episode. Because both the actor and the environment are stochastic, is random. Its expectation, , must therefore be maximized to measure how good the actor is.
Here, is the probability of obtaining trajectory through the actions selected by the policy. Averaging the rewards obtained from all trajectories gives .
The PG algorithm optimizes the network to maximize the expected reward. That is, it uses a gradient descent strategy to differentiate with respect to and optimize the network through gradient descent.
Using the derivative form of the log function, this can be written as:
Here, represents the probabilities from to and from to . Their product represents the probability that the current trajectory occurs.
Because log converts a product into a sum,
its derivative with respect to is:
Therefore,
In other words, for the action taken in the state at time t, if the total reward obtained is positive, the model should be updated so that the probability becomes as large as possible, and vice versa.
Actor–Critic
Two networks can be used to estimate the Q value and V value separately.
- Actor: Can be based on PG; it takes a state as input and outputs a policy, namely, an action selection (policy gradient RL).
- Critic: Takes a state as input and calculates the score of each action (Value-Based RL).
However, when two networks are used, the parameters of both networks need to be adjusted, creating a greater risk of inaccurate estimates. Therefore, consider using only one V value and replacing the Q value with . The difference is called the TD error (that is, ).
Comments