Lecture 1��Overview of introductory reinforcement learning
1
Instructor: Ercan Atam
Institute for Data Science & Artificial Intelligence
Course: DSAI 642- Advanced Reinforcement Learning
2
List of contents for this lecture
3
Relevant readings for this lecture
4
Branches of machine learning
5
What is reinforcement learning? (1)
The learner is not told which actions to take, but instead must discover which actions yield the most reward by trying them.
Reinforcement learning is the training of machine learning models to make a sequence of decisions in
order to maximize a reward-based metric through interaction with environment :
6
State space & action space
State space: The state space is the set of all possible states.
Action space: The set of all possible actions the learning agent can take in the environment.
7
Return (1)
Episodic tasks
8
Return (2)
9
Some remarks on discounted rewards
(*)
10
State-value function
Definition
specifies what is good in the long run.
because it is regularly followed by other states that yield high rewards.
Note: A value function is used to evaluate the goodness/badness of states.
11
State-action-value (action-value) function
Definition
12
Model (1)
Definition
A model predicts what the environment will do for a given input.
Examples (of models for probabilistic transitions):
Note: Both of the above forms will be used in the lectures.
Data-based model fitting is a learning problem of its own called “system identification”.
13
Model (2)
actually experienced (simulated experience).
high-level, deliberative planning.
14
More general framework of reinforcement learning
15
Fully/partially observable environments
Example: A poker playing agent only observes public cards.
16
Exploration and exploitation
(if we have no perfect model of it)
a split between both strategies!
(source, W. Kirchgässner, M. Schenke,
O. Wallscheid and D. Weber, RL Course Material,
Paderborn University, 2020)
Fig: The exploration- exploitation dilemma
17
Categorizing reinforcement learning agents (1)
18
Categorizing reinforcement learning agents (2)
19
Reinforcement agent taxonomy
Fig: RL categories (source, D. Silver, Reinforcement Learning, 2016)
20
Note:
Markov Decision Processes (MDPs)
Definition (MDP=MRP extended with actions)
21
Definition
We differentiate between two kinds of policies:
Remarks:
Policy (1)
22
Definition (state-value function)
Definition (action-value function)
Value functions for MDPs
23
The state-value function can be decomposed into immediate reward plus discounted value of successor state:
Bellman expectation equation for state-value function of MDPs
Bellman expectation equation for state-value function of MDPs
24
Bellman expectation equation for action-value function of MDPs
The action-value function can similarly be decomposed as:
Bellman expectation equation for action-value function of MDPs
25
Summary Bellman expectation equations and backup diagrams
26
Optimal policy in an MDP
Theorem: Optimal policies in MDPs
27
Deterministic optimal policy in an MDP
28
Summary of “Bellman Optimality Equations” and backup diagrams
29
Monte Carlo methods (1)
terminate no matter what actions are selected.
policies are changed.
step-by-step (online) sense.
30
Monte Carlo methods (2)
31
Monte Carlo methods (3)
32
Monte Carlo methods vs dynamic programming
(Source, derivative of W. Kirchgässner, M. Schenke, O. Wallscheid and D. Weber, RL Course Material, Paderborn University, 2020)
Dynamic programming:
Monte Carlo methods:
33
Monte Carlo prediction (1)
MC prediction problem
…
34
Monte Carlo prediction (2)
35
Monte Carlo prediction (3)
(terminal)
36
First-visit and every-visit MC prediction methods
Definition: first-visit MC prediction method
In the first-visit MC prediction method, when you are at state “s” you start to sum the rewards
until the end of the episode.
If the state “s” appears again during a transition, you ignore re-appearance and don't start
counting again. For state “s”, we have maximum one sum per episode.
Then, the value of state “s” is taken as the average of the sums corresponding to all episodes
where “s” appears.
Definition: every-visit MC prediction method
In the every-visit MC prediction method, for every re-appearance of “s” in an episode you
start a new sum.
For state “s”, we can have multiple sums per episode.
Then, the value of state “s” is taken as the average of all sums corresponding to all episodes
where “s” appears.
37
Pseudocode for every-visit MC prediction
38
Pseudocode for first-visit MC prediction
39
Incremental implementation (1)
(Source, derivative of W. Kirchgässner, M. Schenke, O. Wallscheid and D. Weber, RL Course Material, Paderborn University, 2020)
40
Incremental implementation (2)
(Source, derivative of W. Kirchgässner, M. Schenke, O. Wallscheid and D. Weber, RL Course Material, Paderborn University, 2020)
41
Statistical properties of MC-based prediction (1)
(Source, W. Kirchgässner, M. Schenke, O. Wallscheid and D. Weber, RL Course Material, Paderborn University, 2020)
42
Statistical properties of MC-based prediction (2)
(Source, W. Kirchgässner, M. Schenke, O. Wallscheid and D. Weber, RL Course Material, Paderborn University, 2020)
43
Backup diagrams: DP vs MC
Fig.: Backup diagrams for DP (left) and MC (right) prediction: shallow one-step backups with bootstrapping vs. deep backups over full epsiodes.
44
one step and chooses whichever action leads to the best combination of reward and next state, as we
did in the DP lectures of the RL course:
Monte Carlo estimation of action values (1)
45
Monte Carlo estimation of action values (2)
46
Remarks:
Monte Carlo estimation of action values (3)
47
Complications in Monte Carlo estimation of action values (1)
48
Complications in Monte Carlo estimation of action values (2)
A must:
49
pair, and that every pair has a nonzero probability of being selected as the start. This assumption is
called “exploring starts”.
number of times in the limit of an infinite number of episodes.
interaction with the environment, exploring starts may not be possible to satisfy.
action in every state is non-zero.
method.
A remedy to complications in Monte Carlo estimation of action values
50
Objective: To use Monte Carlo estimation methods for approximation of optimal policies under the assumption of exploring starts.
Monte Carlo control with exploring starts (1)
51
First, we will consider the MC version of classical policy iteration:
Monte Carlo control with exploring starts (2)
E
: a complete policy evalution
I
: a complete policy improvement
52
Monte Carlo control with exploring starts (3)
53
Monte Carlo control with exploring starts (4)
54
Monte Carlo control with exploring starts (5)
55
Monte Carlo control with exploring starts (6)
evaluation
improvement
56
policy improvement on an episode-by-episode basis.
improved at all the states visited in the episode.
Monte Carlo control with exploring starts (7)
57
First-visit MC control with exploring starts algorithm
58
Advantages of MC learning methods
59
59
Definition: behavior policy and target policy
MC control without exploring starts: Behavior and Target policies
60
Definition: on-policy learning
On-policy learning algorithms are algorithms that evaluate and improve the same policy which
is being used to select actions.
In short, in on-policy learning algorithms we have target policy = behavior policy.
Some examples of on-policy learning algorithms: policy iteration, Monte Carlo for on-policy, Sarsa.
Definition: off-policy learning
Note: The Monte Carlo control with exploring starts method is an example of an on-policy method.
MC control without exploring starts: On-policy vs Off-policy methods
61
Before developing a “MC control without exploring starts” approach, we need some definitions...
Note: In on-policy control methods without exploring starts, the soft policy is gradually shifted closer
and closer to a deterministic optimal policy.
MC control without ES: on-policy methods (1)
62
MC control without ES: on-policy methods (2)
63
Random
number
in [0, 1]
MC control without ES: on-policy methods (3)
64
We need a mechanism to derive “target policy” from “behaviour policy”
Derive/test new (preferably optimal) policies from old data: Evaluate a target policy using logs from a
different policy—no risky deployments.
Fix distribution mismatch: Reweight samples from the behavior policy so that estimates reflect the target policy.
Reuse data efficiently: Learn from past experience by applying “adaptation” ratios.
All these call for “Importance Sampling”.
65
Importance sampling (1)
66
Importance sampling (2)
67
Importance sampling (3)
68
Note that the general form of MC-based every-visit incremental state-value update rule suitable for
non-stationary environments is:
constant step-size parameter in (0,1)
TD prediction (1)
69
This new every-visit incremental state-value update rule is called TD learning rule:
TD prediction (2)
combine
70
target: the actual return after time t
target: an estimate of return after time t
TD prediction vs MC prediction
71
One-step TD prediction
target: an estimate of return after time t
72
TD off-policy control: Q-learning (1)
Remember the “Bellman Optimality Equation” for the state-action value function:
For a deterministic optimal policy (remember that it always exists for an MDP), we have:
73
Update rule:
TD off-policy control: Q-learning (2)
Q-learning is based on approximating the optimal action-value function iteratively by making use of the “Bellman Optimality Equation” corresponding to the action-value function.
74
Requirements for Q-learning
75
Q-learning algorithm