














Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
Material Type: Notes; Class: MACHINE LEARNING; Subject: Computer Science; University: University of Maryland; Term: Unknown 1989;
Typology: Study notes
1 / 22
This page cannot be seen from the preview
Don't miss anything!















R. S. Sutton and A. G. Barto: Reinforcement Learning: An Introduction (^1)
Slides from Sutton and Barto
R. S. Sutton and A. G. Barto: Reinforcement Learning: An Introduction (^2)
Agent
Environment
action a s (^) t t
reward r t r (^) t+ 1 s (^) t+ 1
state
Agent and environment interact at discrete time steps : t = 0,1, 2, K Agent observes state at step t : s (^) t ∈ S produces action at step t : at ∈ A ( st ) gets resulting reward : rt + 1 ∈ℜ and resulting next state: s (^) t + 1
t
... (^) s t (^) a
rt +1 (^) s t +1 (^) at +
rt +2 (^) s t +2 (^) at (^) +
rt +3 (^) s t +3 (^) a t +...
R. S. Sutton and A. G. Barto: Reinforcement Learning: An Introduction (^3)
a mapping from states to action probabilities
Reinforcement learning methods specify how the agent changes its policy as a result of experience. Roughly, the agent’s goal is to get as much reward as it can over the long run.
R. S. Sutton and A. G. Barto: Reinforcement Learning: An Introduction (^4)
Suppose the sequence of rewards after step t is : rt + 1 , rt + 2 , rt + 3 , K What do we want to maximize?
In general, we want to maximize the expected return , E R { } t , for each step t.
Episodic tasks : interaction breaks naturally into episodes, e.g., plays of a game, trips through a maze. Rt = rt + 1 + rt + 2 + L + rT ,
where T is a final time step at which a terminal state is reached, ending an episode.
R. S. Sutton and A. G. Barto: Reinforcement Learning: An Introduction (^7)
Get to the top of the hill as quickly as possible.
reward = −1 for each step where not at top of hill ⇒ return = − number of steps before reaching top of hill
Return is maximized by minimizing number of steps reach the top of the hill.
R. S. Sutton and A. G. Barto: Reinforcement Learning: An Introduction (^8)
In episodic tasks, we number the time steps of each episode starting from zero. We usually do not have distinguish between episodes, so we write instead of for the state at step t of episode j. Think of each episode as ending in an absorbing state that always produces reward of zero:
We can cover all cases by writing
st s (^) t , j
s^ r^1 = + 0 s 1 r 2 = +1 (^) s 2 r 3 = +1 r r 4 = 0 5 = 0
Rt = γ k^ rt + k + 1 , k = 0
∞ ∑
where γ can be 1 only if a zero reward absorbing state is always reached.
R. S. Sutton and A. G. Barto: Reinforcement Learning: An Introduction (^9)
By “the state” at step t , the book means whatever information is available to the agent at step t about its environment. The state can include immediate “sensations,” highly processed sensations, and structures built up over time from sequences of sensations. Ideally, a state should summarize past sensations so as to retain all “essential” information, i.e., it should have the Markov Property :
Pr (^) { s (^) t + 1 = s ′ , rt + 1 = r st , at , rt , st − 1 , at − 1 ,K, r 1 , s 0 , a 0 }=
Pr (^) { s (^) t + 1 = s ′ , rt + 1 = r st , a (^) t } for all s ′, r , and histories st , a (^) t , rt , st − 1 , at − 1 ,K, r 1 , s 0 , a 0.
R. S. Sutton and A. G. Barto: Reinforcement Learning: An Introduction (^10)
If a reinforcement learning task has the Markov Property, it is basically a Markov Decision Process (MDP). If state and action sets are finite, it is a finite MDP. To define a finite MDP, you need to give: state and action sets one-step “dynamics” defined by transition probabilities :
reward probabilities :
Ps sa ′^ = Pr (^) { s (^) (^) t + 1 = s ′ st = s , a (^) t = a } for all s , s ′ ∈ S , a ∈ A ( s ).
Rsa s^ ′= E r { t (^) + 1 st = s , at = a , s (^) t + 1 = s ′} for all s , s ′ ∈ S , a ∈ A ( s ).
R. S. Sutton and A. G. Barto: Reinforcement Learning: An Introduction (^13)
State - value function for policy π :
V^ π^ ( s ) = E π { R (^) t st = s }= E π γ k^ rt + k + 1 st = s k = 0
∞ ∑
⎧ ⎨ ⎩
⎫ ⎬ ⎭
Action - value function for policy π :
Q^ π^ ( s , a ) = E π { R (^) t s (^) t = s , at = a }= E π γ k^ rt + k + 1 s (^) t = s , at = a k = 0
∞ ∑
⎧ ⎨ ⎩
⎫ ⎬ ⎭
The value of a state is the expected return starting from that state; depends on the agent’s policy:
is the expected return starting from that state, taking that
R. S. Sutton and A. G. Barto: Reinforcement Learning: An Introduction (^14)
Bellman Equation for a Policy π
= rt + 1 +γ (^) ( r (^) t + 2 +γ rt + 3 +γ 2 rt + 4 L)
The basic idea:
So: V^ π^ ( s ) = E π { R (^) t st = s }
= E π { rt (^) + 1 +γ V s ( (^) t + 1 ) s (^) t = s }
Or, without the expectation operator:
V^ π^ ( s ) = π ( s , a ) Ps sa ′^ [ R (^) sa s^ ′+γ V^ π^ ( s ′ )] s ′
∑ a
∑
R. S. Sutton and A. G. Barto: Reinforcement Learning: An Introduction (^15)
V^ π^ ( s ) = π ( s , a ) Ps sa ′^ [ R (^) sa s^ ′+γ V^ π^ ( s ′ )] s ′
∑ a
∑
This is a set of equations (in fact, linear), one for each state.
Backup diagrams : s s,a
a
s'
r a'
s'
r
(a) (b)
for V π (^) for Q^ π
R. S. Sutton and A. G. Barto: Reinforcement Learning: An Introduction (^16)
π ( s ) ≥ V π ′ ( s ) for all s ∈ S
For finite MDPs, policies can be partially ordered :
There is always at least one (and possibly many) policies that is better than or equal to all the others. This is an optimal
Optimal policies share the same optimal state-value function :
Optimal policies also share the same optimal action-value function :
∗ ( s ) = max π
π ( s ) for all s ∈ S
Q ∗( s , a ) = max π Q^ π^ ( s , a ) for all s ∈ S and a ∈ A ( s )
This is the expected return for taking action a in state s and thereafter following an optimal policy.
R. S. Sutton and A. G. Barto: Reinforcement Learning: An Introduction (^19)
a) gridworld (^) b) V * (^) c) π*
22.0 24.4 22.0 19.4 17. 19.8 22.0 19.8 17.8 16. 17.8 19.8 17.8 16.0 14. 16.0 17.8 16.0 14.4 13. 14.4 16.0 14.4 13.0 11.
A B
A'
(^10) B'
V ∗
V
∗
Any policy that is greedy with respect to is an optimal policy.
Therefore, given , one-step-ahead search produces the long-term optimal actions.
E.g., back to the gridworld:
R. S. Sutton and A. G. Barto: Reinforcement Learning: An Introduction (^20)
Given , the agent does not even have to do a one-step-ahead search:
π ∗ ( s ) = arg max a ∈ A ( s )
Q ∗ ( s , a )
R. S. Sutton and A. G. Barto: Reinforcement Learning: An Introduction (^21)
Finding an optimal policy by solving the Bellman Optimality Equation requires the following: accurate knowledge of environment dynamics; we have enough space an time to do the computation; the Markov Property. How much space and time do we need? polynomial in number of states (via dynamic programming methods; Chapter 4), BUT, number of states is often huge (e.g., backgammon has about 10**20 states). We usually have to settle for approximations. Many RL methods can be understood as approximately solving the Bellman Optimality Equation.
R. S. Sutton and A. G. Barto: Reinforcement Learning: An Introduction (^22)
State - value function for policy π :
V^ π^ ( s ) = E π { R (^) t st = s }= E π γ k^ rt + k + 1 st = s k = 0
∞ ∑
⎧ ⎨ ⎩
⎫ ⎬ ⎭
Bellman equation for V^ π^ : V^ π^ ( s ) = π ( s , a ) Ps sa ′^ [ R (^) sa s^ ′+γ V^ π^ ( s ′ )] s ′
a
— a system of S simultaneous linear equations
state-value function V π
Recall:
R. S. Sutton and A. G. Barto: Reinforcement Learning: An Introduction (^25)
π
For a given state s , would it be better to do an action a^ ≠^ π( s )?
Q^ π^ ( s , a ) = E π { rt (^) + 1 + γ V^ π^ ( st + 1 ) s (^) t = s , at = a }
s ′
∑ Rs s ′
[ ]
R. S. Sutton and A. G. Barto: Reinforcement Learning: An Introduction (^26)
a
a
s ′
∑ Rss ′
[ ]
R. S. Sutton and A. G. Barto: Reinforcement Learning: An Introduction (^27)
What if V π^ ′= V^ π^? i.e., for all s ∈ S , V π^ ′( s ) = max a Ps sa ′ s ′
∑ Rs s ′
a (^) +γ V π (^) ( s ′) [ ]?
But this is the Bellman Optimality Equation. So V π^ ′= V ∗^ and both π and π ′are optimal policies.
R. S. Sutton and A. G. Barto: Reinforcement Learning: An Introduction (^28)
π 0 → V
π (^0) →π 1 → V
π 1 → L π
→π
policy evaluation policy improvement “greedification”
R. S. Sutton and A. G. Barto: Reinforcement Learning: An Introduction (^31)
R. S. Sutton and A. G. Barto: Reinforcement Learning: An Introduction (^32)
All the DP methods described so far require exhaustive sweeps of the entire state set. Asynchronous DP does not use sweeps. Instead it works like this: Repeat until convergence criterion is met:
R. S. Sutton and A. G. Barto: Reinforcement Learning: An Introduction (^33)
π (^) V
evaluation
improvement
V → V π
π→greedy( V )
π* V^ *
starting V π
V (^) = (^) V π
π^ =^ g re e
d y^ (^ V^ )
V * π*
Generalized Policy Iteration (GPI): any interaction of policy evaluation and policy improvement, independent of their granularity.
A geometric metaphor for convergence of GPI:
R. S. Sutton and A. G. Barto: Reinforcement Learning: An Introduction (^34)
To find an optimal policy is polynomial in the number of states… BUT, the number of states is often astronomical, e.g., often growing exponentially with the number of state variables (what Bellman called “the curse of dimensionality”). In practice, classical DP can be applied to problems with a few millions of states. Asynchronous DP can be applied to larger problems, and appropriate for parallel computation. It is surprisingly easy to come up with MDPs for which DP methods are not practical.
R. S. Sutton and A. G. Barto: Reinforcement Learning: An Introduction (^37)
T T T T T
T T^ T T T
V ( st ) ← V ( s (^) t ) +α (^) [ r (^) t + 1 + γ V ( s (^) t + 1 ) − V ( st )]
T T T T^ T
T (^) T T T T
R. S. Sutton and A. G. Barto: Reinforcement Learning: An Introduction (^38)
V ( st ) ← E π { rt (^) + 1 + γ V ( st )}
T
T T^ T
st
T
T T
T
T T
T
T
T
R. S. Sutton and A. G. Barto: Reinforcement Learning: An Introduction (^39)
MC does not bootstrap DP bootstraps TD bootstraps
MC samples DP does not sample TD samples
R. S. Sutton and A. G. Barto: Reinforcement Learning: An Introduction (^40)
TD methods do not require a model of the environment, only experience TD, but not MC, methods can be fully incremental You can learn before knowing the final outcome