Compute the Monte Carlo advantage at every time step of a completed episode. First compute each discounted return backward:
Gt=rt+γGt+1,GT=0Then subtract the value baseline for the visited state:
At=Gt−V(st)Here, rt is the reward at time t, γ is the discount factor, and V(st) is the estimated value of the current state. Do not bootstrap beyond the final reward. Return the advantages as a NumPy array rounded to four decimals.
Input: states = [0, 1, 2], rewards = [1, 2, 3], V = [0.5, 1, 1.5], gamma = 1
Output: [5.5, 4, 1.5]
Explanation: The returns are [6, 5, 3], and subtracting the three state baselines gives the advantages.
Input: states = [0, 1, 2], rewards = [1, 2, 3], V = [0, 0, 0], gamma = 0
Output: [1, 2, 3]
Fill a return array backward with running = rewards[index] + gamma * running.
Index the baseline vector with values[np.asarray(states, dtype=int)].
Sign in to take notes on this problem
Accepts: array
Accepts: array
Accepts: array
Accepts: number
Compute the Monte Carlo advantage at every time step of a completed episode. First compute each discounted return backward:
Gt=rt+γGt+1,GT=0Then subtract the value baseline for the visited state:
At=Gt−V(st)Here, rt is the reward at time t, γ is the discount factor, and V(st) is the estimated value of the current state. Do not bootstrap beyond the final reward. Return the advantages as a NumPy array rounded to four decimals.
Input: states = [0, 1, 2], rewards = [1, 2, 3], V = [0.5, 1, 1.5], gamma = 1
Output: [5.5, 4, 1.5]
Explanation: The returns are [6, 5, 3], and subtracting the three state baselines gives the advantages.
Input: states = [0, 1, 2], rewards = [1, 2, 3], V = [0, 0, 0], gamma = 0
Output: [1, 2, 3]
Fill a return array backward with running = rewards[index] + gamma * running.
Index the baseline vector with values[np.asarray(states, dtype=int)].
Sign in to take notes on this problem
Accepts: array
Accepts: array
Accepts: array
Accepts: number