CSE510 Deep Reinforcement Learning (Lecture 6)
Active reinforcement learning
Exploration vs. Exploitation
-
Exploitation: To try to get reward. We exploit our current knowledge to get a payoff.
-
Exploration: Get more information about the world. How do we know if there is not a pot of gold around the corner?
-
To explore we typically need to take actions that do not seem best according to our current model
-
Managing the trade-off between exploration and exploitation is a critical issue in RL
-
Basic intuition behind most approaches
- Explore more when knowledge is weak
- Exploit more as we gain knowledge
ADP-based RL
Model based
- Start with an initial (uninformed) model
- solve for optimal policy given the current model (using value or policy iteration)
- Take action according to an exploration/exploitation policy
- Update estimated model based on observed transition
- Goto 2
Exploration/Exploitation policy
Greedy action is the action maximizing estimated value
- where is current optimal value function estimate (based on current model), and are current estimates of model
- is the expected value of taking action in state and then getting estimated value for the next state
Want an exploration policy that is greedy in the limit of infinite exploration (GLIE)
- Try each action in each state and unbounded number of times
- Guarantees convergence
GLIE: Greedy in the limit of infinite exploration
Greedy Policy 1
On time step select random action with probability and greedy action with probability
will lead to convergence, but is slow.
In practice, it’s common to simply set for all .
Greedy Policy 2
Boltzmann exploration
Selection action with probability,
is the temperature. Large means that each action has about the same probability. Small leads to more greedy behavior.
Typically start with large and decrease with time.
Example: impact of temperature
Suppose we have two actions and that and .
When , we have
When , we have
When , we have
(Alternative Model-Based RL) Optimistic Exploration: Rmax [Brafman & Tennenholtz, 2002]
- Start with an optimistic model
- (assign largest possible reward to “unexplored states”)
- (actions from “unexplored states” only self transition)
- Solve for optimal policy in optimistic model (standard VI)
- Take greedy action according to the computed policy
- Update optimistic estimated model
- (if a state becomes “known” then use its true statistics)
- Goto 2
Agent always acts greedily according to a model that assumes all “unexplored” states are maximally rewarding
Implementation for optimistic model
- Keep track of number of times a state-action pair is tried
- If then and in optimistic model,
- Otherwise, and are based on estimates obtained from the experiences (the estimate of true model)
- can be determined by using Chernoff Bound
- An optimal policy for this optimistic model will try to reach unexplored states (those with unexplored actions) since it can stay at those states and accumulate maximum reward
- Never explicitly explores. Is always greedy, but with respect to an optimistic outlook.
Algorithm: (for Infinite horizon RL problems)
Initialize $\hat{p}, \hat{r}$, and $N(s,a)$ For $t = 1, 2, ...$
1. Build an optimistic reward model $(Q(s,a))_{s,a}$ from $\hat{p}, \hat{r}$, and $N(s,a)$
2. Select action $a(t)$ maximizing $Q(s(t),a)$ over $A_{s(t)}$
3. Observe the transition to $s(t+1)$ and collect reward $r(s(t),a(t))$ according to $\hat{p}$
4. Update $\hat{p}, \hat{r}$, and $N(s,a)$Efficiency of Rmax
If the model is very completely learned (i.e. for all ), then Rmax will be near optimal.
Results how that this will happen “quickly” in terms of number of steps.
General proof strategy: PAC Guarantee (Roughly speaking): There is a value , such that with high probability the Rmax algorithm will select at most a polynomial number of actions with value less than of optimal.
RL can be solved in poly-time in number of actions, number of states, and discount factor.
TD-based Active RL
- Start with initial value function
- Take action from an exploration/exploitation policygiving new state (should converge to optimal policy)
- Update estimated model (To compute the exploration/exploitation policy.)
- Perform TD update is new estimate of optimal value function at state .
- Goto 2
Given the usual assumptions about learning rate and GLIE, TD will converge to an optimal value function!
- Exploration/Exploitation policy requires computing for the exploitation part of the policy
- Computing requires in addition to
- Thus TD-learning must still maintain an estimated model for action selection
- It is computationally more efficient at each step compared to Rmax (i.e., optimistic exploration)
- TD-update vs. Value Iteration
- But model requires much more memory than value function
- Can we get a model-fee variant?
Q-learning
Instead of learning the optimal value function , directly learn the optimal function.
Recall is the expected value of taking action in state and then following the optimal policy thereafter
Given the function we can act optimally by selecting action greedily according to without a model
The optimal -function satisfies which gives:
How can we learn the -function directly?
Q-learning implementation
Model-free reinforcement learning
- Start with initial Q-values (e.g. all zeros)
- Take action from an exploration/exploitation policy giving new state (should converge to optimal policy)
- Perform TD update is current estimate of optimal Q-value for state and action .
- Goto 2
- Does not require model since we learn the Q-value function directly
- Use explicit table to store Q-values
- Off-policy learning: the update does not depend on the actual next action
- The exploration/exploitation policy directly uses -values
Convergence of Q-learning
Q-learning converges to the optimal Q-value in the limit with probability 1 if:
- Every state-action pair is visited infinitely often
- Learning rate decays just so: and
Speedup for Goal-Based Problems
- Goal-Based Problem: receive big reward in goal state and then transition to terminal state
- Initializing for all and to zeros and then observing the following sequence of (state, reward, action) triples
- The sequence of Q-value updates would result in: , ,
- So nothing was learned at and
- Next time this trajectory is observed we will get non-zero for but still
From the example we see that it can take many learning trials for the final reward to “back propagate” to early state-action pairs
- Two approaches for addressing this problem:
- Trajectory replay: store each trajectory and do several iterations of Q-updates on each one
- Reverse updates: store trajectory and do Q-updates in reverse order
- In our example (with learning rate and discount factor equal to 1 for ease of illustration) reverse updates would give
- , ,
Off-policy vs on-policy RL
SARSA
- Start with initial Q-values (e.g. all zeros)
- Take action on state from an -greedy policy giving new state
- Take action on state from an -greedy
- Perform TD update
- Goto 2
Compared with Q-learning, SARSA (on-policy) usually takes more “safer” actions.