Reinforcement Learning Basics
Transcript
back everyone so this is cs229 lecture 14. the topic for today we'll be starting a new chapter is reinforcement learning and today we'll be covering markov decision processes value iteration and and policy iteration uh which form probably the core of reinforcement learning and um in in friday's lecture we'll see more complex extensions of this and before we jump into today's topics uh a few announcements so uh for those of you who've been sending in feedback through the google
forms that we submitted thank you so much there are um we got a lot of good suggestions a lot of points where we can improve and i would like to uh briefly summarize you know some of the feedback that we've got and the kind of steps that we'll be taking to um to improve so uh one of the uh concerns raised was office hours uh that there are uh there were a few too many last minute changes for office hours um and we will try to do our best not to change the office our schedule moving forward
unfortunately sometimes there may be personal emergencies or things beyond the ts control when it's too late to bring in a replacement ta but those exceptions apart we will do our best to keep the office our schedule fixed there were also a few very specific comments and suggestions about the way the office hours were were conducted and we noticed what you what you've said and we'll be definitely taking steps to improve and a few more uh comments from from you guys
so a few comments on the lectures so some of you have asked for uh doing the lectures with the slides format where we are projecting slides and um and and doing the lectures around the slides uh however uh this is a pretty matty class and um at least it's my opinion that um you know slides might not be the best approach because there'll be a lot of back and forth between going on the slide and going on the backboard and that can be pretty distracting for somebody who's watching the videos and also uh we just tend you know um probably math is better explained on a whiteboard than on on on slides uh several of you have asked that i write bigger on the whiteboard uh thank you for that feedback i will make a conscious decision to write bigger if any of you uh have any trouble understanding what's written on the whiteboard please stop me right right then and you know tell me that you cannot see it i will i will you know i have no problem erasing it and writing all over again
and also uh some of you have mentioned that the lectures are going too slow some of you have mentioned it's going too fast um so the the uh so i guess one one way to kind of accommodate both needs of going fast and going too slow uh is probably that uh uh i i think a good good compromise there would be to probably postpone some of the questions that that come from the audience to a few in a batched way so hold off till i you know complete some section and then ask your question in case
your question gets answered right then and if if the questions are not directly related to the lecture itself then i might ask you to just post the question on piazza and when i ask you to post it on queer on piazza it will be uh it's it's a sincere request that you actually do post it on piazza because you know i want to answer them uh and just not hold you know the hundred or more of you you know waiting while i answer the questions that may be of interest to a few of you um and then uh some of you have also uh given some feedback about the difficulty of homeworks so some find the math in it too hard some of you find the programming in it too hard and i don't know if there is a clear action that we can take over there because machine learning is is indeed um you know a field that that spans computer science and statistics so it will be hard on math it will be hard on programming and it's that's just the nature of of you know machine learning
and uh the programming assignments uh or the the uh homework assignments might feel a little too long um however uh you know in this course we are just following the the uh the following the pattern that has been followed for this course in the previous quarters right and and and the programming uh assignments and the homework assignments you know in each homework is not more or less than what's been done before and and that's just the way the course is structured it is
it is a work workload heavy course uh in terms of um in terms of help required for programming uh in general in office hours we tend not to focus on helping students debug their code we expect students to be comfortable with programming and be able to just implement things on your own however going forward if if there is no backlog in the queue you know the tas will might probably help you a little bit if there is nobody else waiting uh but in general the expectation for
the course is that you come with you know basic computer programming skills and you have no no problems writing simple code given an algorithm uh but at the same time we don't want to um you know um kind of leave you stuck if you're having some trouble so you know try attending office if you're especially if you need help in programming try attending office hours early in the homework phase so that office hours are free and maybe tas can help you out there if you if you attend office hours when the deadline to homework is is you know close then the tas will have a hard time helping you with with programming um and for those of you who you know the the the feedback form is still open uh i i'm still going to keep checking for it every once in a while if you have any feedbacks you know please feel free to give us candid feedbacks on how we can improve and we'll do our best to you know make changes and accommodate as many needs as possible okay with that let's start with a quick recap of
um of the last lecture and also do a quick summary of where we are standing in terms of the overall course so in the last lecture or the last two lectures we've been talking quite a bit about bias variance trade-off and this understanding this bias variance tradeoff in a deep way should probably be the highest priority for you of what you take away from this course right biased radius variance tradeoff is something that is so fundamental and understanding it in an intuitive and deep way will be
will probably serve you the longest it has probably the largest payoff into your future machine learning career right so uh to summarize uh bias variance trade-off in machine learning we are interested in generalization error right how well our model performs on unseen data not on the training data that we have and the test error or the generalization error can be decomposed into three parts three additive parts so one is irreducible error and this is just the noise in the test example right our training data is noisy and our test data is noisy and the noise in the in the in the test data is what contributes to irreducible error and there's nothing we can do about it it's just a fact of life and we accept it and then there are these two other components called bias and variance bias you can think of it as a systematic error of your model which means if you average it across all the possible training sets that you can get the the systematic error that your model
makes that's either your under predicting or overpredicting for certain examples or that your parameters are closer to zero than what it should be that systematic error is called bias and variance is how sensitive our model is to noise in the training data right and this is where the distinction between noise and the test data and the training data comes into picture noise in the test data contributes to irreducible error and that's you know one component of the generalization error and noise in the training data contributes to the variance of of your model right and the steps that we can take to reduce the test error the steps that we can take there are way too many steps that you can take for example you can try a bigger model you can try you can get more training data there are many steps that you can take however not all the steps work all the time and in order to determine what steps what what is the step that is most effective for the problem
that is immediately in front of you in order to make that decision it's very crucial that you understand this bias variance trade off right reducing training error is is simple you can always you know get a bigger model get a more complex model and that will reduce your training error but our goal is to improve on test error and and and the steps that we take as i said already is going to is going to depend on whether the current problem that you're facing is mostly a bias problem
or is it mostly a variance problem right and the bias variance trade off basically tells you that by taking some step you may be reducing you know one of them either bias or variance but that may also increase the other right and which is why it is very important that we that we are able to characterize which of the two problems is the bigger problem at hand and take a step to purposefully go after that particular problem either bias or variance right for example we saw that
if we if we increa increase the model capacity if you move to a more complex model that will reduce the bias of of your model but at the same time it may increase the variance of your model right so if if the problem that you're facing right now is high variance then you should almost certainly not use a bigger model because that is going to worsen the problem that you have right and similarly with regularization if we increase regularization that is going to reduce the variance in the model but it's going to increase the it's also going to increase the bias in the uh in the model which means if your problem right now is high bias then increasing regularization is going to make it worse whereas increasing regularization would have helped if the problem was high variance right which is why it is super super important for you to characterize and get a heuristic estimate of what the contribution of bias is towards our and what the contribution of variance is
towards the current uh test error and unfortunately there is no principled approach to decompose and get these estimates in practice which is why we use heuristics right the heuristics are you can think of the training error itself as the bias and you can think of the gap between cross validation error and training error as variance and this is where cross validation comes into picture cross validation is necessary or the the the most important use of cross validation is that we can get this
this decomposition of various variance and bias from the current model right and and once we get this we get this breakdown we can then make a judgment about whether a model is currently facing a larger bias problem or a larger variance problem and take some remedial step according to which of the two is larger right so the the summary is that whenever you are working on model development and you want to improve your model performance you should always always always look at the training error
and cross-validation error simultaneously right we care about improving the cross validation error or the or the test error but just looking at that alone will give you nothing actionable in order to have something actionable you need to see both the training error and the cross validation error simultaneously make a judgment about whether the situation is a high bias situation or a high variance situation and then accordingly take some action to remedy the high bias or high variance right then this this is probably the the most important thing that's going to serve you well for the rest of your machine learning career right so that's that's the bias variance tradeoff and to kind of take a larger look of where we are standing in terms of the overall course so here's here's a a a rough overview or a quick overview of what we've covered so far so approximately week one through four we cover supervised learning and what is supervised learning supervised learning
is learning some function h which you call the hypothesis that maps x to y right there is there is this clear concept of input and output in supervised learning which will not be the case in unsupervised learning in supervised learning there's a very clear sense of what is input and what's output and we have noisy examples of input output pairs right and most of the time the noise is embedded in the label what we call in in the output and we get a training set of size n
of you know these these xy pairs and from this training set our goal is to learn this hypothesis that that's a function that maps x to y such that it generalizes well to unseen data right there is some notion of a loss function and we want to minimize this loss function on unseen data right if the problem was just to minimize it on the given data that we have then we would just call it an optimization problem right but this is machine learning because we want to do well on unseen data right and that's that's where you know the concept of bias variance come into picture and we thought uh we've been seeing you know approximately you know two kinds of algorithms classification versus regression and this this categorization is based on the data type of the y variable right if the data type of the y variable is binary you know zero or one then we call it classification and this could not be just binary but it could be you know or multiple class like you know um for
example in the homework you're you're you're building a classifier for 100 digits for mnist where y can take anything between you know zero to nine and that is called classification where y is discrete and in cases where y is continuous we call it regression right and we have seen you know simple two very simple models that we started off with that was linear regression and logistic regression for uh for for regression problems and classification problems and then we after after seeing those two
we kind of generalized the the data type of y to not just you know be this strict regression versus classification but generalize them into something called glms generalized linear models where y given x is some distribution in the exponential family right it could be discrete it could be continuous it could be poisson which is just integers it could be anything it could be you know positive only and as long as that y given x distribution is belongs to the exponential family then we can solve it with with you know common update rules and you know there were other niceties that we saw so generalized linear models is not just for classification or for regression or for poisson it generalizes the data type of y to any any kind of data type essentially right and then we also saw two different uh kinds of approaches for building models discriminative versus generative and discriminative models we are directly learning y given x so generalized linear model is an
example of a discriminative model where we are only interested in learning the probability distribution of y when the corresponding x is given to you and the the other approach for building models is called generative models where we want to learn how to generate new examples how to generate a full pair x y pair right and this can be generally broken down using the chain rule as p of y times p of x given y and we saw a few examples of of generative models so we saw a naive bayes
where x was discrete and we saw gda gaussian discriminant analysis where x was real valued right and we also saw that ah with with with gda there is a one-to-one correspondence between gda and logistic regression in fact for any x given y where x belongs to exponential family p of y given x will always take a logistic regression form right and we saw that in the homework as well and then we moved on to nonlinear models right the what we we actually did explore
non-linearity using feature maps in your homework already in the first homework where you try different feature maps we get non-linear hypotheses right and the the more formal approach to feature maps that we saw was kernels right kernels are are these you know symmetric positive definite functions which have an implicit feature map embedded in them and using kernels we can we can build uh you know kernel based methods you know we call them kernel methods and we saw two such examples support
vector machines for classification problems and gaussian processes for regression problems both of these methods use kernels and svm in particular was was you know particularly well suited for a kernel method and that was because with with um with the non-kernel based approaches the complexity of the model depends on the number of parameters that we have that depends on the number of features that we have whereas with kernel methods the the complexity depends on the number of
examples that we have right those those are the two two kind of sides of your design matrix with with normal models we learn one parameter per feature that is per column and with kernel methods we learn one coefficient for example you know per row and so kernel methods in general tend not to work so well when the number of examples is a lot when you have a very big data set kernel methods tend to tend to be more expensive and we saw that in svms in particular
the set of coefficients that we learned for with the kernel approach happens to be sparse which means you get the best of both worlds you get good scalability in the number of features because kernels can potentially give you infinite number of features and you also get good scalability in terms of number of examples because the coefficients are mostly zero and even with large data sets therefore svms tend to work well right and then we moved on to another kind of non-linearity so you know kernel methods was one and the other approach that we that we saw was learnable features where in in the first approach the feature map or the kernel is hand designed you decide what the kernel you want to use is the other approach is to again use data to learn what are good feature maps right that's where neural networks came into picture right with neural networks you can think of neural network as a generalized linear model at the last layer and everything before that
as some kind of a learnable feature map right and after that we moved on to learning theory and in learning theory the the main topics that we touched upon was regularization and it's its bayesian interpretation of how regularization uh corresponds to performing map estimation in the in the bayesian setting and we saw um we studied bias and variance and the bias variance trade off which which we covered already and we also studied uniform convergence right so uniform convergence is a more
theoretical theoretical part of the course and in general you know understanding the contents of you know the lecture notes on uniform convergence and what we covered in the lecture can be very useful if you're interested in getting into machine learning research because you know that's that's like the common framework in which most of the machine learning uh theory problems are posed and that's until the last lecture so we are here right now right and today and in the next lecture we'll
be covering reinforcement learning it's going to be a very quick overview of reinforcement learning we will not be going very deep there are multiple courses uh offered only on reinforcement learning you know it's a super vast uh uh field and but we'll only be covering just the basics and giving you kind of you know a big picture or a mind map of how the different reinforcement learning algorithms that we are not going to cover how they all kind of fit together in one one piece so that's the plan for reinforcement learning and starting next week we will be starting unsupervised learning for me personally i like unsupervised learning the most um it's it's um i know it's it's very exciting and once we kind of finish up with unsupervised learning we're going to cover some general topics you know things like you know evaluation metrics maybe a few a few theoretical ideas like kl divergence or a few such things some some general topics
that don't kind of you know fit into this you know supervised versus unsupervised classification and finally in the last week uh on week eight we'll have only two lectures on the monday and the and the wednesday and those two lectures will be doing a full review of the entire course again with the hope that it prepares you well for the final exam right so any questions before we move into today's uh today's topic of reinforcement learning yes questions
so the question is why are these two uh why is wise training error and approximation of bias and cross-validation i would say you know post that on piazza um and and you know i'll be happy to kind of give you more give you more details on that all right so let's let's start with um reinforcement learning
so in the in the in the examples that uh in in the topics that we've covered so far which has been mostly supervised learning we were always told for a given input or for a given situation what the correct answer is right so for every x we had a corresponding y which was the correct answer or the the the answer that our model should learn to predict and that was given directly to us right and which is which is why we called it supervised learning right whereas in reinforcement learning this kind of supervision is a little weak instead of telling us what to do in a given situation we are instead given some kind of a reward right so in in rl we you know one way to think of it is replace y which is supervision with reward
right and reward is always a real value it could be positive it could be negative and the way you want to think of reward is kind of um how good a job you did right there is no right reward so to speak you know you there is there is no um there is no optimal reward uh as such and the goal in in reinforcement learning is to kind of maximize our long-term reward which means we are dealing with situations which are changing over time right in supervised learning we were dealing with
fixed situations and each example was what we call as iid where each example was independent of the other whereas in reinforcement learning we are trying to trying to program an agent that kind of lives in in an environment or in the real world or in a simulator that performs well over time and examples of of of such agents could be you know for example it could be um a robot which is learning how to walk it could be a game-playing agent that plays chess or go it could be even some kind of an
automated trading agent that you you know um that you that you use in a financial market right things where you're making multiple decisions over time and at each time after you make every uh after you take every action you get some kind of a reward right and the the goal with with reinforcement learning is to maximize this accumulated reward over time right which means we need to take this long term view of trying to optimize how how much reward we're going to accumulate
starting from now all the way into the future right which is very different from the supervised learning setting where in supervised learning setting we were given an example and our only concern was to do well on that example alone and the next example was completely independent right and so it is this this concept of time that makes reinforcement learning different from general supervised learning right in reinforcement learning we are making multiple decisions once one decision at one decision at a time and with each decision we are earning some reward and our goal is to maximize this accumulated reward into the future and the way we kind of formalize reinforcement learning is through this formalism called mdp or markov decision process or call decision process fdp right so an mdp is
it is ah is ah one two three it's a five tuple it is a tuple containing five things s a p s a gamma and r where s is a set of states it is the set of all possible states that our agent can can currently be in
a is a set of actions right p s a are transition probabilities gamma this is zero to one discount factor and r just s cross
is called the reward function right now lets lets look at an example of what all of these actually mean supposing ah this example comes from a very famous textbook on on artificial intelligence and its also very standard example used in many courses so you might have seen this before so supposing there is this
right supposing this is there is this agent that lives in some kind of a map some kind of a region where your agent at any given time can be in one of these grids and our goal is to reach here and ah and you get a reward of plus one if you reach here and you get a reward of minus one if you reach here and our goal is to is to ah is to be able to solve this and by what i mean by solving is so first of all what is s s is the set of all possible states where our agent can be so states in this case s
in this case is the set you know 1 1 1 2 and so on and the size of this the size of our state space in this case is 11 it can be in 1 2 3 4 5 6 7 8 9 10 11 and you know this is blocked you cannot be in the state the set of actions that we can take in this case are to move our agent one step at a time in any of the direction so the set of actions we take can be move north move south move west or move east right four simple actions that we can take and the probability psa is also called
the transition probability what this means is this is a probability distribution over the states and what this specifically means is if we are in one particular state that indexed by s and we take an action index by a then what is the probability that we are going to end up in one of the other states right so it is a probability distribution over the state space and it has two indices the current state and the action that we are taking so for example if you're if you're building a robot
that has to move in this kind of a map if the robot is in is in ah one three then p 1 3 and let's say the action that we take is go north north so this is p s a state is you know the state we are in 1 3 and action we take is go north then this will be a probability distribution such that ah let us say there is there is you know some kind of uncertainty in the robot and whenever we ask it to go north with let's say with 80 probability it actually goes north and with a 10 percent probability it
goes west and with 10 percent probability it goes east right so this will be a probability distribution that has zeros everywhere point one that corresponds to the state one four right point one that corresponds to the state one two point eight corresponding to the state two three and zeros everywhere right is this clear for for every state we take an action and when we take an action we can end up in a new state and that the that transition of moving to the next state
is stochastic and that stochasticity that stochasticity is captured by this probability distribution which tells us with what probability we are going to end up in any given state depending on what action we took and what state we were currently in this question yeah i'll come to that i'll come to that so uh uh so let's for you know simplicity assume we can take any action in any state for now right so uh so that's that's called a transition probability and then there is something called
ah the discount factor gamma will come to that and there is a reward function so a reward function is basically uh the reward that our agent earns immediately after you know when it is in some particular state for example if if our agent comes to this state where we you know want it to be it earns a reward of plus one and if you wanted to avoid the state it earns a reward of minus 1 right and let us say you know the reward at all the other places is a small negative reward 0.02
minus you know 0.02 minus 0.4 and so on right and these are the immediate rewards that the model gets or the agent gets for entering a particular state and most of the times the reward function is represented as a function of the state you know gives you some ah real valued reward and sometimes it is also modeled as r of s comma a where when you are in a particular state and you take the next action a you get some particular reward the reason why sometimes uh we tend to model
model it as a state action pair rather than state alone is because taking uh taking different actions may have different costs so uh even though you earned the same reward for being in a state the fact that you took one action over another you may be paying a different cost so you know to to account for such action-specific costs you know it's it and sometimes you would model the reward function as as a function over the state action pair rather than just a state alone but for uh in terms of what we are going to cover most of the times we'll be just focusing on reward functions as a function of state and assume that all actions have equal questions yes question yeah so in practice how do we know we will get to that we know it's it's it's part of how we define the uh problems itself um yeah so that's the reward function and
in terms of in terms of uh what happens when we start an agent we assume that the agent is going to start in some initial state s s naught so let's assume that the agent starts at some initial state s naught and we take an action a or a naught that is the first action taken by the agent and by taking an action a at a state s we enter a new state s1 which is according to the transition probabilities so s 1 is now s one is sampled from p of s zero a zero right and once we are in s one
we take action a one and enter state s two where s two is sampled from p of s to s one a one right and then we take action a two enter s three no action a three and so on right this sequence of states and actions is commonly called there are multiple names that you will see in in in different books or different resources you can either call it a trial or you can call it an episode or trajectory right all these are you know synonymous for a sequence of states and actions are taken by an agent
where the action is taken by the agent and the environment lands you in the new state according to the transition probabilities yes question so the question is why is uh the probability of going north when we are in one three a vector yeah so um in general so so the way to think of reinforcement learning is you are in an agent that lives in some kind of an environment right you are in one particular state and you take an action and by taking an action you end up in another state but the state that you end up in can be random right so let's say you are building a robot and in your robot you ask the robot to move north and for
whatever reason maybe there's a stone under its wheel or maybe there are some some things that are beyond our control your robot may end up going to a different location than the one that you are then you were actually interested in maybe you ask your robot to move you know a meter in one direction but in reality it may end up moving say 95 centimeters or 105 centimeters right so there is some stochasticity in the environment due to which we always don't go to the same state that we that an action will not always take you to the same state all the time right and that is why here if you are in you know one three and you you know ah and your and you go north most of the times you will go to two three with probability you know point eight but sometimes you may go to you know one two or you may go to one four so either here or here the probability point one but you know most of the times you end up going no that's that's the general idea this
question yeah so so i i think you're talking about about a game playing where there is an opponent uh so uh i i'll push that question until later uh for now let's assume we are you know the environment is stochastic for whatever reason right um yeah so it could be if you're in if you're in in a game playing scenario it could be due to the opponent um so um yeah so this this we call it as a as a trial or an episode or a trajectory and all three are all three names are synonymous
and now what we what we ah when when an agent goes through a particular trajectory at each state s it is earning some reward so over here it earns rfs naught when it lands in state s1 the agent earns r of s1 right from here r of s2 so the agent is accumulating rewards at each step right and the and this is where the discount factor comes into picture right so the discount factor is basically a factor which we multiply all future rewards by so the reward for being in state
s1 will be discounted by a factor gamma the rewarded state s 2 will be discounted by a factor gamma square the reward from s 3 will be discounted by a factor gamma q and what the agent what the agent accumulates over the future is basically the sum of these discounted rewards right and this is and this sum of accumulated rewards is what we want to maximize and the the idea here the reason why we call it discount factor is one way to think of it is
any positive reward that we get is better obtained sooner rather than later right so the discount factor incentivizes the model to earn larger rewards sooner and it also incentivizes the model to postpone any negative rewards into the future right that's one way to think of it another common interpretation of the discount factor especially if you're in a finance setting is you can think of the discount factor as interest rate right which means uh you want to you want to earn your money sooner rather than later and you want to postpone your losses into the future rather than you know rather than sooner right next question uh with respect to game doesn't that lead to some optimal strategies well so let's let's push game game playing you know we'll cover
environment right we'll gameplay game game planning yeah so we we're gonna we're gonna touch upon exactly that that that topic of you know sub-optimality right so uh this is this is the uh setting in which uh the the agent operates so we want to design uh an agent that given this markov decision process wants to or needs to maximize the sum of accumulated rewards into the future right and these rewards are discounted by a discount factor gamma and this discount factor gamma um there are many many uh good reasons to
have this discount factor gamma but some of the interpretation is you can think of this gamma as you know interest rate or you can think of it as a motivation to make the agent get reward sooner rather than later yes question yeah it's it's uh the gamma is the same gamma that we use at all time steps yes there's a particular reason uh we'll we'll um we're going to we'll cover this in a shortly why why we're going to use the same camera right so now ah given this given this setting we can define two central concepts right and these two concepts are going to are going to stay with us for the rest of reinforcement learning
right so so we are going to define something called as a policy pie which is mapping from state to action so the policy tells you what action to take when you are in a given state right and this is the policy over which the agent has flexibility to learn right our goal is to learn a policy we want to learn this function that maps us from state to action and we want to learn a policy that is going to maximize something called as the value right so the value associated with the policy pi
is a function that takes us from a state to real valued where v pi of s is defined as expectation of r of s naught plus gamma times r of s one plus gamma square times r of s2 so on until s naught equals s comma so we define the value of a state by following a particular policy to be the sum of all the expected rewards from starting from the first state all the way you know until until infinity where each reward at a particular time step is discounted by the corresponding gamma factor
right and over over here ah the the s which is the parameter of the value function decides what is the starting state could be right so the value of the value of a particular state by following a policy pi is the discounted sum of all future rewards assuming we start at the given state and the actions that we take at each step is according to the policy that that is given to us right you start at a given state start taking actions according to a policy the environment based on the
transition probabilities is going to keep throwing you to different states and when you go to a new state refer to your policy and take the next action and you know you keep going to new states and as you are going to as you are going from one state to another you are accumulating rewards and we discount each of those rewards by the corresponding gamma factor right and the value of a particular value of a policy at a given state is this expected sum of future words and
the reason why we use expectation here is because these rewards are random the reason why the rewards are random is because the state that we end up in is random and this reason why the state that we end up in is random is because of the transition probabilities right so if the transition probabilities were not stochastic so if we always reach the same state when we took a particular action every time then we would not need this expectation but because the transitions are stochastic we are the values defined as the expected sum of future rewards or some of future discounted rewards any questions about this yes question so this is a comma
right so this is this is ah this is called the value function and this is called the policy right and as we will see probably tomorrow you know these two concepts are are kind of they are at the heart of reinforcement learning because you can kind of classify the entire field of reinforcement learning into those that try to optimize or learn good value functions versus those that directly try to learn policies right so this this uh these two are central concepts that that we're going to
encounter over and over and it's this value function that is um that's related to rewards but also it is different from rewards so reward is you know you can think of reward as like the reward is the immediate reward that you get by just entering into a state whereas value is you can think of value as the long-term benefit or the sum of all future rewards that you're going to accumulate by following a particular policy so reward you can think of it as short-sighted you know something that you're going to get immediately by going into a particular state whereas you know value is is like the long-term value by following a particular policy this question so the value keeps changing right um depending on where you are in the next state so even in the first stage um is always taken at where you are at the moment and therefore your value is shifting
so the question is the states that you end up in are you know can be different because of you know the the dynamics are stochastic which is why we have the expectation yeah so in this expression s naught is not random because we we have condition s naught to be something and that s s that is you know parameter to the function so s naught here is not random because it is given all the future s one s two are random
right so we can now rewrite this in a slightly different way you know by actually recognizing that s naught is [Music] not random and so we can rewrite this as r of s because s naught was just equal to s plus gamma times sum over s prime in s p of s pi of s
s prime v pi of s prime how did we go from this equation to this equation so the way we went from this equation to this equation is by recognizing the fact that this this expression can be now written as r of s plus gamma times expectation of r of s 1 plus plus r of s 1 plus gamma time r of s two plus gamma times gamma square times r of s three and so on right because this was this was not random we took it out and all of these terms have a gamma so we take the gamma factor out and what

Ask anything
We've read this whole study set, so questions about it get the best answers.