Lecture 10 - Planning under Uncertainty (III)

Similar documents
Grundlagen der Künstlichen Intelligenz

Q-learning. Tambet Matiisen

Decision Theory: Q-Learning

Reinforcement Learning

CMU Lecture 12: Reinforcement Learning. Teacher: Gianni A. Di Caro

15-780: ReinforcementLearning

Decision Theory: Markov Decision Processes

CSC321 Lecture 22: Q-Learning

Reinforcement Learning Part 2

INF 5860 Machine learning for image classification. Lecture 14: Reinforcement learning May 9, 2018

Reinforcement Learning

1 Introduction 2. 4 Q-Learning The Q-value The Temporal Difference The whole Q-Learning process... 5

Basics of reinforcement learning

Reinforcement Learning. Yishay Mansour Tel-Aviv University

Q-Learning in Continuous State Action Spaces

Notes on Reinforcement Learning

Marks. bonus points. } Assignment 1: Should be out this weekend. } Mid-term: Before the last lecture. } Mid-term deferred exam:

Administration. CSCI567 Machine Learning (Fall 2018) Outline. Outline. HW5 is available, due on 11/18. Practice final will also be available soon.

Trust Region Policy Optimization

Introduction to Reinforcement Learning

Machine Learning. Reinforcement learning. Hamid Beigy. Sharif University of Technology. Fall 1396

COMP3702/7702 Artificial Intelligence Lecture 11: Introduction to Machine Learning and Reinforcement Learning. Hanna Kurniawati

Reinforcement Learning. Spring 2018 Defining MDPs, Planning

Internet Monetization

Lecture 1: March 7, 2018

Sequential Decision Problems

Reinforcement Learning as Variational Inference: Two Recent Approaches

Lecture 25: Learning 4. Victor R. Lesser. CMPSCI 683 Fall 2010

Machine Learning I Reinforcement Learning

CS599 Lecture 1 Introduction To RL

Learning Control for Air Hockey Striking using Deep Reinforcement Learning

Reinforcement Learning

Lecture 23: Reinforcement Learning

Reinforcement learning

CS230: Lecture 9 Deep Reinforcement Learning

ECE276B: Planning & Learning in Robotics Lecture 16: Model-free Control

Reinforcement Learning with Function Approximation. Joseph Christian G. Noel

Reinforcement Learning

Approximate Q-Learning. Dan Weld / University of Washington

CS Machine Learning Qualifying Exam

Temporal Difference. Learning KENNETH TRAN. Principal Research Engineer, MSR AI

Machine Learning and Bayesian Inference. Unsupervised learning. Can we find regularity in data without the aid of labels?

Reinforcement Learning

Real Time Value Iteration and the State-Action Value Function

MARKOV DECISION PROCESSES (MDP) AND REINFORCEMENT LEARNING (RL) Versione originale delle slide fornita dal Prof. Francesco Lo Presti

Christopher Watkins and Peter Dayan. Noga Zaslavsky. The Hebrew University of Jerusalem Advanced Seminar in Deep Learning (67679) November 1, 2015

Reinforcement Learning: An Introduction

Introduction to Reinforcement Learning. CMPT 882 Mar. 18

Temporal difference learning

(Deep) Reinforcement Learning

ARTIFICIAL INTELLIGENCE. Reinforcement learning

Reinforcement Learning

Dueling Network Architectures for Deep Reinforcement Learning (ICML 2016)

An Adaptive Clustering Method for Model-free Reinforcement Learning

Reinforcement Learning

Lecture 4: Approximate dynamic programming

Approximation Methods in Reinforcement Learning

Reinforcement Learning. Machine Learning, Fall 2010

Lecture 7: Value Function Approximation

16.410/413 Principles of Autonomy and Decision Making

Markov Decision Processes

Reinforcement Learning

REINFORCEMENT LEARNING

Markov Decision Processes and Solving Finite Problems. February 8, 2017

Reinforcement Learning. George Konidaris

Deep Reinforcement Learning SISL. Jeremy Morton (jmorton2) November 7, Stanford Intelligent Systems Laboratory

Today s s Lecture. Applicability of Neural Networks. Back-propagation. Review of Neural Networks. Lecture 20: Learning -4. Markov-Decision Processes

Comparison of Information Theory Based and Standard Methods for Exploration in Reinforcement Learning

CS181 Midterm 2 Practice Solutions

Reinforcement Learning

Lecture 8: Policy Gradient

Reinforcement Learning. Introduction

Course 16:198:520: Introduction To Artificial Intelligence Lecture 13. Decision Making. Abdeslam Boularias. Wednesday, December 7, 2016

Deep Reinforcement Learning: Policy Gradients and Q-Learning

Reinforcement learning an introduction

Value Function Methods. CS : Deep Reinforcement Learning Sergey Levine

Deep Reinforcement Learning. STAT946 Deep Learning Guest Lecture by Pascal Poupart University of Waterloo October 19, 2017

Short Course: Multiagent Systems. Multiagent Systems. Lecture 1: Basics Agents Environments. Reinforcement Learning. This course is about:

arxiv: v1 [cs.ai] 5 Nov 2017

Reinforcement Learning Active Learning

Lecture 3: Policy Evaluation Without Knowing How the World Works / Model Free Policy Evaluation

Reinforcement Learning and NLP

1 MDP Value Iteration Algorithm

Planning in Markov Decision Processes

Prof. Dr. Ann Nowé. Artificial Intelligence Lab ai.vub.ac.be

Introduction of Reinforcement Learning

Temporal Difference Learning & Policy Iteration

6 Reinforcement Learning

Lecture 9: Policy Gradient II 1

Today s Outline. Recap: MDPs. Bellman Equations. Q-Value Iteration. Bellman Backup 5/7/2012. CSE 473: Artificial Intelligence Reinforcement Learning

Reinforcement Learning for NLP

Reinforcement Learning and Control

Reinforcement Learning

CS 598 Statistical Reinforcement Learning. Nan Jiang

Reinforcement Learning

Review: TD-Learning. TD (SARSA) Learning for Q-values. Bellman Equations for Q-values. P (s, a, s )[R(s, a, s )+ Q (s, (s ))]

Policy Gradient Methods. February 13, 2017

Reinforcement Learning: the basics

Reinforcement Learning. Summer 2017 Defining MDPs, Planning

Q-learning Tutorial. CSC411 Geoffrey Roeder. Slides Adapted from lecture: Rich Zemel, Raquel Urtasun, Sanja Fidler, Nitish Srivastava

Transcription:

Lecture 10 - Planning under Uncertainty (III) Jesse Hoey School of Computer Science University of Waterloo March 27, 2018 Readings: Poole & Mackworth (2nd ed.)chapter 12.1,12.3-12.9 1/ 34

Reinforcement Learning What should an agent do given: Prior knowledge Observations possible states of the world possible actions current state of world immediate reward / punishment Goal act to maximize accumulated reward Like decision-theoretic planning, except model of dynamics and model of reward not given. 2/ 34

Experiences We assume there is a sequence of experiences: state, action, reward, state, action, reward,... What should the agent do next? It must decide whether to: explore to gain more knowledge exploit the knowledge it has already discovered 3/ 34

Reinforcement Learning Each machine has a Pr(win)... but you don t know what it is... Which machine should you play? 4/ 34

Why is reinforcement learning hard? What actions are responsible for the reward may have occurred a long time before the reward was received. The long-term effect of an action of the robot depends on what it will do in the future. The explore-exploit dilemma: at each time should the robot be greedy or inquisitive? 5/ 34

Reinforcement learning: main approaches search through a space of policies (controllers) learn a model consisting of state transition function P(s a, s) and reward function R(s, a, s ); solve this as an MDP. learn Q (s, a), use this to guide action. 6/ 34

Model-based Reinforcement Learning Model-based reinforcement learning uses the experiences in a more effective manner. It is used when collecting experiences is expensive (e.g., in a robot or an online game), and you can do lots of computation between each experience. Idea: learn the MDP and interleave acting and planning. After each experience, update probabilities and the reward, then do some steps of asynchronous value iteration. 7/ 34

Model-based learner Data Structures: Q[S, A], T [S, A, S], R[S, A] Assign Q, R arbitrarily, T = prior counts α is learning rate observe current state s repeat forever: select and carry out action a observe reward r and state s T [s, a, s ] T [s, a, s ] + 1 R[s, a] R[s, a] + α(r R[s, a]) repeat for a while: select state s 1, action a 1 let P = s 2 T [s 1, a 1, s 2 ] Q[s 1, a 1 ] ( ) T [s 1, a 1, s 2 ] R[s 1, a 1 ] + γ max Q[s 2, a 2 ] P a 2 s 2 s s 8/ 34

Temporal Differences Suppose we have a sequence of values: v 1, v 2, v 3,... And want a running estimate of the average of the first k values: A k = v 1 + + v k k 9/ 34

Temporal Differences (cont) When a new value v k arrives: A k = v 1 + + v k 1 + v k k ka k = v 1 + + v k 1 + v k = (k 1)A k 1 + v k A k = k 1 A k 1 + 1 k k v k Let α = 1 k, then A k = (1 α)a k 1 + αv k = A k 1 + α(v k A k 1 ) TD formula Often we use this update with α fixed. 10/ 34

Q-learning Idea: store Q[State, Action]; update this as in asynchronous value iteration, but using experience (empirical probabilities and rewards). Suppose the agent has an experience s, a, r, s This provides one piece of data to update Q[s, a]. The experience s, a, r, s provides the data point: r + γ max a Q[s, a ] which can be used in the TD formula giving: ( ) Q[s, a] Q[s, a] + α r + γ max Q[s, a ] Q[s, a] a 11/ 34

Q-learning begin initialize Q[S, A] arbitrarily observe current state s repeat forever: select and carry out an action a observe reward r and state s Q[s, a] Q[s, a] + α (r + γ max a Q[s, a ] Q[s, a]) s s ; end-repeat end 12/ 34

Convergence and Termination N(s, a): number of times action a taken in state s learning rate in TD-formula α = 1 N(s,a) Q-learning converges if every state-action is visited infinitely often. 1. t=0 α t = 2. t=0 α2 t < converge when at time, average error over last N steps is below a threshold ɛ: ɛ > 1 N t i=t N (r + γmax a Q(s i+1, a )) Q(s i, a) 13/ 34

Properties of Q-learning Q-learning converges to the optimal policy, no matter what the agent does, as long as it tries each action in each state enough. But what should the agent do? exploit: when in state s, select the action that maximizes Q[s, a] explore: select another action 14/ 34

Exploration Strategies The ɛ-greedy strategy: choose a random action with probability ɛ and choose a best action with probability 1 ɛ. Softmax action selection: in state s, choose action a with probability e Q[s,a]/τ a eq[s,a]/τ where τ > 0 is the temperature. Good actions are chosen more often than bad actions; τ defines what is good. 15/ 34

Exploration Strategies optimism in the face of uncertainty : initialize Q to values that encourage exploration. Upper Confidence Bound (UCB): Also store N[s, a] (number of times that state-action pair has been tried) and use arg max a [ ] N[s] Q(s, a) + k N[s, a] where N[s] = a N[s, a] 16/ 34

Example: studentbot studentbot state variables: tired: studentbot is tired (no/a bit/very) passtest: studentbot passes test (no/yes) knows: studentbot s state of knowledge (nothing/a bit/a lot/everything) goodtime: studentbot has a good time (no/yes) 17/ 34

Example: studentbot studentbot studentbot actions: study: studentbot s knowledge increases, studentbot gets tired sleep: studentbot gets less tired party: studentbot has a good time, but gets tired and loses knowledge take test: studentbot takes a test (can take test anytime) 17/ 34

Example: studentbot studentbot studentbot rewards: +20 if studentbot passes the test +2 if studentbot has a good time when not very tired basic tradeoff: short term vs. long-term rewards 17/ 34

Studentbot Policy tired no a_bit very knows knows a_lot everything a_bit nothing a_bit nothing a_lot everything take_test study party sleep 18/ 34

On-policy Learning Q-learning does off-policy learning: it learns the value of the optimal policy, no matter what it does. This could be bad if the exploration policy is dangerous. On-policy learning learns the value of the policy being followed. e.g., act greedily 80% of the time and act randomly 20% of the time If the agent is actually going to explore, it may be better to optimize the actual policy it is going to do. SARSA uses the experience s, a, r, s, a to update Q[s, a]. 19/ 34

SARSA begin initialize Q[S, A] arbitrarily observe current state s select action a using a policy based on Q repeat forever: carry out an action a observe reward r and state s select action a using a policy based on Q Q[s, a] Q[s, a] + α (r + γq[s, a ] Q[s, a]) s s ; a a ; end-repeat end 20/ 34

Large State Spaces Computer Go : 3361 states Atari Games 210 160 3 dimensions (pixels) 21/ 34

Q-function Approximations Let s = (x 1, x 2,..., x N ) T Linear Q w (s, a) i w ai x i Non-linear (e.g. neural network) Q w (s, a) g(x; w) 22/ 34

Recall: Logistic Regression Logistic function of linear weighted inputs: Ŷ w (e) = f (w 0 + w 1 X 1 (e) + + w n X n (e)) n = f ( w i X i (e)) i=0 The sum of squares error is: Error(E, w) = e E(Y (e) f ( n w i X i (e))) 2 i=0 The partial derivative with respect to weight w i is: Error(E, w) = 2 δ f ( w i X i (e)) X i (e) w i i where δ = (Y (e) f ( n i=0 w ix i (e))). Thus, each example e updates each weight w i by w i w i + η δ f ( i w i X i (e)) X i (e) 23/ 34

Approximating the Q-function for experience tuple s, a, r, s we have: target Q-function: R(s) + γ maxa Q w (s, a ) or R(s) + γq w (s, a ) current Q-function: Q w (s, a) Squared error: Gradient: Err(w) = 1 2 Err w = [ ] 2 Q w (s, a) R(s) γ max Q w (s, a ) a [ Q w (s, a) R(s) γ max a Q w (s, a ) ] Qw(s,a) w 24/ 34

SARSA with linear function approximation Given γ:discount factor; α:learning rate Assign weights w = w 0,..., w n arbitrarily begin observe current state s select action a repeat forever: carry out action a observe reward r and state s select action a (using a policy based on Q w ) let δ = r + γq w (s, a ) Q w (s, a) For i = 0 to n end w i w i + α δ Q w(s,a) w s s ; a a ; end-repeat 25/ 34

Convergence Linear Q-learning (Q w (s, a) i w aix i ) converges under same conditions as Q-learning ( t=0 α t = and t=0 α2 t < ) w i w i + α [ Q w (s, a) R(s) γq w (s, a ) ] x i Non-linear Q-learning (e.g. neural network, Q w (s, a) g(x; w)) may diverge Adjusting w to increase Q at (s, a) might introduce errors at nearby state-action pairs. 26/ 34

Mitigating Divergence Two tricks used in practice: 1. Experience Replay 2. Use two Q function (two networks): Q network (currently being updated) Target network (occasionally updated) 27/ 34

Experience Replay Idea: Store previous experiences (s, a, r, s, a ) in a buffer and sample a mini-batch of previous experiences at each step to learn by Q-learning Breaks correlations between successive updates (more stable learning) Few interactions with environment needed to converge (greater data efficiency) 28/ 34

Target Network Idea: use a separate target network that is updated only periodically target network has weights w and computes Q w (s, a) repeat for each (s, a, r, s, a ) in mini-batch: w w w w + α [ Q w (s, a) R(s) γq w (s, a ) ] Q w (s, a) w 29/ 34

Deep Q-Network Assign weights w = w 0,..., w n at random in [ 1, 1] begin observe current state s select action a repeat forever: carry out action a observe reward r and state s select action a (using a policy based on Q w ) add (s, a, r, s, a ) to experience buffer Sample mini-batch of experiences from buffer For each experience (ŝ, â, ˆr, ŝ, â ) in mini-batch: let δ = ˆr + γq w (ŝ, â ) Q w (ŝ, â) w w + α δ Qw(ŝ,â) w s s ; a a ; every c steps, update target w w end-repeat end 30/ 34

Deep Q-Network for Atari from: Mnih et. al. Human-level control through deep reinforcement learning. Nature 18(7540):529533 2015. 31/ 34

Deep Q-Network vs. Linear Approx. from: Mnih et. al. Human-level control through deep reinforcement learning. Nature 18(7540):529533 2015. 32/ 34

Bayesian Reinforcement Learning Include the parameters (transition function and observation function) in the state space Model-based learning though inference (belief state) State space is now continuous, belief space is a space of continuous functions Can mitigate complexity by modeling reachable beliefs 33/ 34

Next: Affective Computing Recap 34/ 34