Reinforcement Learning. Yishay Mansour Tel-Aviv University

Similar documents
Lecture 1: March 7, 2018

Reinforcement Learning

Reinforcement Learning

CS 570: Machine Learning Seminar. Fall 2016

ARTIFICIAL INTELLIGENCE. Reinforcement learning

CS599 Lecture 1 Introduction To RL

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

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

CSC321 Lecture 22: Q-Learning

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

CS230: Lecture 9 Deep Reinforcement Learning

Introduction to Reinforcement Learning. CMPT 882 Mar. 18

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

Grundlagen der Künstlichen Intelligenz

CS 598 Statistical Reinforcement Learning. Nan Jiang

Introduction to Reinforcement Learning

Reinforcement Learning. Machine Learning, Fall 2010

, and rewards and transition matrices as shown below:

REINFORCEMENT LEARNING

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

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

6 Reinforcement Learning

Q-learning. Tambet Matiisen

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

Markov decision processes

Reinforcement Learning

Reinforcement learning an introduction

Reinforcement Learning with Function Approximation. Joseph Christian G. Noel

Reinforcement Learning. Introduction

MDP Preliminaries. Nan Jiang. February 10, 2019

Basics of reinforcement learning

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

Reinforcement Learning

Open Theoretical Questions in Reinforcement Learning

Reinforcement Learning and Control

Temporal difference learning

Decision Theory: Markov Decision Processes

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

CS788 Dialogue Management Systems Lecture #2: Markov Decision Processes

Trust Region Policy Optimization

Reinforcement Learning: An Introduction

Introduction to Reinforcement Learning

Balancing and Control of a Freely-Swinging Pendulum Using a Model-Free Reinforcement Learning Algorithm

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 ))]

Elements of Reinforcement Learning

Lecture 10 - Planning under Uncertainty (III)

Decision Theory: Q-Learning

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

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

Reinforcement Learning. Donglin Zeng, Department of Biostatistics, University of North Carolina

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. George Konidaris

Lecture 23: Reinforcement Learning

Lecture 18: Reinforcement Learning Sanjeev Arora Elad Hazan

University of Alberta

This question has three parts, each of which can be answered concisely, but be prepared to explain and justify your concise answer.

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

CS 7180: Behavioral Modeling and Decisionmaking

Machine Learning I Reinforcement Learning

An Adaptive Clustering Method for Model-free Reinforcement Learning

Lecture 3: Markov Decision Processes

REINFORCE Framework for Stochastic Policy Optimization and its use in Deep Learning

Reinforcement Learning II. George Konidaris

15-780: ReinforcementLearning

Reinforcement Learning II. George Konidaris

An Introduction to Reinforcement Learning

Markov Decision Processes Chapter 17. Mausam

Optimal Control. McGill COMP 765 Oct 3 rd, 2017

Approximation Methods in Reinforcement Learning

Q-Learning in Continuous State Action Spaces

CS 188: Artificial Intelligence

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

(Deep) Reinforcement Learning

Reinforcement Learning and NLP

Planning in Markov Decision Processes

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

Reinforcement Learning. Spring 2018 Defining MDPs, Planning

CMU Lecture 11: Markov Decision Processes II. Teacher: Gianni A. Di Caro

Markov Decision Processes (and a small amount of reinforcement learning)

The Simplex and Policy Iteration Methods are Strongly Polynomial for the Markov Decision Problem with Fixed Discount

Deep Reinforcement Learning: Policy Gradients and Q-Learning

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

Reinforcement Learning

Lecture 3: The Reinforcement Learning Problem

Course basics. CSE 190: Reinforcement Learning: An Introduction. Last Time. Course goals. The website for the class is linked off my homepage.

Reinforcement Learning II

1 MDP Value Iteration Algorithm

CSE250A Fall 12: Discussion Week 9

Reinforcement Learning

Reinforcement Learning Part 2

Chapter 3: The Reinforcement Learning Problem

Prioritized Sweeping Converges to the Optimal Value Function

Some AI Planning Problems

Markov Decision Processes Chapter 17. Mausam

Chapter 7: Eligibility Traces. R. S. Sutton and A. G. Barto: Reinforcement Learning: An Introduction 1

MS&E338 Reinforcement Learning Lecture 1 - April 2, Introduction

An Introduction to Markov Decision Processes. MDP Tutorial - 1

A Gentle Introduction to Reinforcement Learning

Transcription:

Reinforcement Learning Yishay Mansour Tel-Aviv University 1

Reinforcement Learning: Course Information Classes: Wednesday Lecture 10-13 Yishay Mansour Recitations:14-15/15-16 Eliya Nachmani Adam Polyak Course Web site: rl-tau-2018.wikidot.com Resources: Markov Decision Processes Puterman Reinforcement Learning Sutton and Barto Neuro-dynamic Programming Bertsekas and Tsitsiklis 2

Reinforcement Learning: Course requirements Homework: Every two week: Theory and Programming Project: Near the end of the term Deep RL/Atari Final Exam Grade: 60% Final exam Have to pass 20% HW 20% project 3

Playing Board Games AlphaGo, DeepMind 2015-17 Gerald Tesauro, TD-gammon 1992 4

Other notable board games Arthur Samuel 1962 Deep Blue1996 5

Playing Atari Games 6

Controlling Robots 7

Today Outline: Overview Basics Goal of Reinforcement Learning Mathematical Model (MDP) Planning Value iteration Policy iteration Learning Algorithms Model based Model Free Large state space Function approx Policy gradient 8

Goal of Reinforcement Learning Goal oriented learning through interaction Control of large scale stochastic environments with partial knowledge. Supervised / Unsupervised Learning Learn from labeled / unlabeled examples 9

10

Mathematical Model - Motivation Model of uncertainty: Environment, actions, our knowledge. Focus on decision making. Maximize long term reward. Markov Decision Process (MDP) 11

Contrast with Supervised Learning The system has a state. The algorithm influences the state distribution. Inherent Tradeoff: Exploration versus Exploitation. * There is a cost to discover information! 12

Mathematical Model - MDP Markov Decision Processes S- set of states A- set of actions d - Transition probability R - Reward function Similar to DFA! 13

MDP model - states and actions Environment = states 0.3 0.7 action a Actions = transitions d ( s, a, s ' ) 14

MDP model - rewards R(s,a) = reward at state s for doing action a (a random variable). Example: R(s,a) = -1 with probability 0.5 +10 with probability 0.35 +20 with probability 0.15 15

MDP model - trajectories trajectory: s 0 a 0 r 0 s 1 a 1 r 1 s 2 a 2 r 2 16

MDP - Return function. Combining all the immediate rewards to a single value. Modeling issues: Are early rewards more valuable than later rewards? Is the system terminating or continuous? Usually the return is linear in the immediate rewards. 17

MDP model - return functions Finite Horizon - parameter H return = å R( s i, ai ) Infinite Horizon 1 i H i discounted - parameter g<1. return = å γ R(si,ai ) i=0 undiscounted 1 N N -1 å i= 0 R(s i,a i ) ¾ N ¾ return Terminating MDP 18

MDP Example: Inventory P= Price/item, J(.)=order cost C(.)=inventory cost - " = min (! " + # ", $ " ) ) " =, - " +. # " /! "%& # " $ "! "! "%& =! " + # " $ " % 19

MDP model - action selection AIM: Maximize the expected return. This talk: discounted return Fully Observable - can see the exact state. Policy - mapping from states to actions Optimal policy: optimal from any start state. THEOREM: There exists a deterministic optimal policy 20

MDP model - summary s Î S a Î A d ( s1, a, s2 ) p : R(s,a) S å i = 0 g i ri A - set of states, S =n. - set of k actions, A =k. - transition function. - immediate reward function. - policy. - discounted cumulative return. 21

Contrast with Supervised Learning Supervised Learning: Fixed distribution on examples. Reinforcement Learning: The state distribution is policy dependent!!! A small local change in the policy can make a huge global change in the return. 22

Simple setting: Multi-armed bandit Single state. Goal: Maximize sum of immediate rewards. a 1 s a 2 Given the model: Greedy action. a 3 Difficulty: unknown rewards. 23

Today Outline: Overview Basics Goal of Reinforcement Learning Mathematical Model (MDP) Planning Value iteration Policy iteration Learning Algorithms Model based Model Free Large state space Function Approx Policy gradient 24

Planning - Basic Problems. Given a complete MDP model. Policy evaluation - Given a policy p, evaluate its return. Optimal control - Find an optimal policy p * (maximizes the return from any start state). 25

Planning - Value Functions V p (s) The expected return starting at state s following p. Q p (s,a) The expected return starting at state s with action a and then following p. V * (s) and Q * (s,a) are define using an optimal policy p *. V * (s) = max p V p (s) 26

Planning - Policy Evaluation Discounted infinite horizon (Bellman Eq.) V p (s) = E s ~ p (s) [ R(s,p (s)) + g V p (s )] Rewrite the expectation V p ( s) = E[ R( s, p ( s))] + g å s ' d ( s, p ( s), s') V p ( s') Linear system of equations. 27

Algorithms -Policy Evaluation Example A={+1,-1} g = 1/2 d(s i,a)= s i+a p random "a: R(s i,a) = i s 0 s 1 0 1 3 2 s 3 s 2 V p (s 0 ) = 0 +g [p(s 0,+1)V p (s 1 ) + p(s 0,-1) V p (s 3 ) ] 28

Algorithms -Policy Evaluation Example A={+1,-1} g = 1/2 d(s i,a)= s i+a p random "a: R(s i,a) = i s 0 s 1 0 1 3 2 s 3 s 2 V p (s 0 ) = 5/3 V p (s 1 ) = 7/3 V p (s 2 ) = 11/3 V p (s 3 ) = 13/3 V p (s 0 ) = 0 + (V p (s 1 ) + V p (s 3 ) )/4 V p (s 1 ) = 1 + (V p (s 0 ) + V p (s 2 ) )/4 V p (s 2 ) = 2 + (V p (s 1 ) + V p (s 3 ) )/4 V p (s 3 ) = 3 + (V p (s 0 ) + V p (s 2 ) )/4 29

Algorithms - optimal control State-Action Value function: Q p (s,a) = E [ R(s,a)] + ge s ~ p (s) [ V p (s )] p p Note V ( s) = Q ( s, p ( s)) For a deterministic policy p. 30

Algorithms -Optimal control Example A={+1,-1} g = 1/2 d(s i,a)= s i+a p random R(s i,a) = i s 0 s 1 0 1 3 2 s 3 s 2 Q p (s 0,+1) = 7/6 Q p (s 0,-1) = 13/6 Q p (s 0,+1) = 0 +g V p (s 1 ) 31

Algorithms - optimal control CLAIM: A policy p is optimal if and only if at each state s: V p (s) = MAX a {Q p (s,a)} (Bellman Eq.) PROOF: (only if) Assume there is a state s and action a s.t., V p (s) < Q p (s,a). Then the strategy of performing a at state s (the first time) is better than p. This is true each time we visit s, so the policy that performs action a at state s is better than p. p 32

Algorithms -optimal control Example A={+1,-1} g = 1/2 d(s i,a)= s i+a p random R(s i,a) = i s 0 s 1 0 1 3 2 s 3 s 2 Changing the policy using the state-action value function. 33

MDP - computing optimal policy 1. Linear Programming 2. Value Iteration method. )}, ( arg max{ ) ( 1 a s Q s i a i - = p p ')} ( '),, ( ), ( max{ ) ( ' 1 s V s a s a s R s V s t a t å + + d g 3. Policy Iteration method. 34

Example: Grid world ACTIONS Initial State = Red Final State = Blue COST = steps to target (blue) 35

Example: Grid world 0 Initial Values t=0 36

Example: Grid world 1 0 1 One Iteration t=1 37

Example: Grid world 2 1 0 2 1 2 Two Iterations t=2 38

Example: Grid world Optimal Policy Q(s,à)= walk à and add distance to target Optimal policy Derive from Q(s, - ) 39

Convergence Value Iteration Decrease the distance from optimal By a factor of 1-γ Policy Iteration Policy improves Number of iteration less than Value Iteration 40

Today Outline: Overview Basics Goal of Reinforcement Learning Mathematical Model (MDP) Planning Value iteration Policy iteration Learning Algorithms Model based Model Free Large state space Function approx Policy gradient 41

Learning Algorithms Given access only to actions perform: 1. policy evaluation. 2. control - find optimal policy. Two approaches: 1. Model based. 2. Model free. 42

Learning - Model Based Estimate the model from the observation. (Both transition probability and rewards.) Use the estimated model as a true model, and find a near optimal policy. If we have a good estimated model, we should have a good estimation. 43

Learning - Model Based: off policy Let the policy run for a long time. o what is long?! o Assuming some exploration Build an observed model : o Transition probabilities o Rewards Both are independent! Use the observed model learn optimal policy. 44

Learning - Model Based off-policy algorithm Observe a trajectory generated by a policy π o off-policy: not need to control For every!,! # & and ' (: o ) (!, ',! ) = #(!, ',! ) / #(!, ', ) o 2 (!, ') = (34(5!, ') Find an optimal policy for (&, ', ), 2 ) 45

Learning - Model Based Claim: if the model is accurate we will compute a near-optimal policy. Hidden assumption: o Each (s,a, ) is sampled many times. o This is the responsibility of the policy π Off-policy Simple question: How many samples we need for each (s,a, ) 46

Learning - Model Based: on policy The learner has control over the action. o The immediate goal is to learn a model As before: o Build an observed model : Transition probabilities and Rewards o Use the observed model to estimate value of the policy. Accelerating the learning: o How to reach unexplored states?! 47

Learning - Model Based: on policy Well sampled states Relatively unknown states 48

Learning - Model Based: on policy HIGH REAWRD Well sampled states Relatively unknown states Exploration à Planning in new MDP 49

Learning: Policy improvement Assume that we can perform: Given a policy p, Compute V π and Q π functions of p Can run policy improvement: p = Greedy (Q π ) Process converges if estimates are accurate. 50

Model-Free learning 53

Q-Learning: off policy Basic Idea: Learn the Q-function. On a move (s,a) s update: Old estimate Q ( t+ 1 s, a) = (1 -a ( s, a)) Q a ( s, a)[ R t t t t ( s, a) + ( s, a) + g max u Q t ( s', u)] Learning rate a t (s,a)=1/t w New estimate 54

55 Q-Learning: update equation Old estimate New estimate update learning rate ) ', ( max ), ( ), ( ), ( ), ( ), 1( u s Q a s R a s Q a s a s Q a s Q t u t t t t t g a + - D = D - = +

Q-Learning: Intuition Updates based on the difference: D = Q t ( s, u) -[ R ( s, a) + g max Q ( s', u)] t u t Assume we have the right Q function Good news: The expectation is Zero!!! Challenge: understand the dynamics stochastic process 56

Learning - Model Free Policy evaluation: TD(0) An online view: At state s t we performed action a t, received reward r t and moved to state s t+1. Our estimation error is Err t =r t +gv(s t+1 )-V(s t ), The update: V t +1 (s t ) = V t (s t ) + a Err t Note that for the correct value function we have: E[r+gV(s )-V(s)] =E[Err t ]=0 57

Learning - Model Free Policy evaluation: TD(l) Again: At state s t we performed action a t, received reward r t and moved to state s t+1. Our estimation error Err t =r t +gv(s t+1 )-V(s t ), Update every state s: V t +1 (s) = V t (s ) + a Err t e(s) Update of e(s) : When visiting s: incremented by 1: e(s) = e(s)+1 For all other s : decremented by g l factor: e(s ) = g l e(s ) 58

Different Model-Free Algorithms On-policy versus Off-policy The function approximated (V vs Q) Fairly similar general methodologies Challenges: controlling stochastic process 59

Today Outline: Overview Basics Goal of Reinforcement Learning Mathematical Model (MDP) Planning Value iteration Policy iteration Learning Algorithms Model based Model Free Large state space Function approx Policy gradient 60

Large state MDP Previous Methods: Tabular. (small state space). Large state Exponential size. Similar to basic view of learning. 61

Large scale MDP Approaches: 1. Restricted Value function. 2. Restricted policy class. 3. Restricted model of MDP. 4. Different MDP representation: Generative Model 62

Large MDP - Restricted Value Function (Value) Function Approximation: Use a limited class of functions to estimate the value function. Given a good approximation of the value function, we can estimate the optimal policy. Vague Idea: reduce to a supervised (deep) learning. applications: most of the recent work (AlphaGo, Atari etc.) 63

Large MDP: Restricted Policy Fix a policy class Π = {$: & (} Given a policy $ Π Approximate V π and Q π Run policy improvement: p = Greedy (Q π ) Quality depends on approximation. Convergence not guaranteed. 64

Large MDP: Policy Gradient Improving the parameter of a policy Taking the gradient Challenge: The update impacts both: Action probabilities Distribution over states Use off-policy compute the gradient from policy history 65

Large MDP: Generative Model. Clearly we can not use matrix representation. Generator representation: s a Generator s r Algorithm for estimating optimal policy (for discounted infinite horizon) in time independent of the number of states 66

Large state MDP: Generative Model. Use generative model for look ahead Sample a tree of a shallow depth Using generative model Compute optimal policy on the tree Result in approximate optimal policy in the MDP 67

Today Outline: Overview Basics Goal of Reinforcement Learning Mathematical Model (MDP) Planning Value iteration Policy iteration Learning Algorithms Model based Model Free Large state space Function approx Policy gradient 68

Course (tentative) Outline Part 1: MDP basics and planning Part 2: MDP learning Model Based and Model free Part 3: Large state MDP Policy Gradient, Deep Q-Network Part 4: Special MDPs Bandits and Partially Observable MDP Part 5: Advanced topics 69