A collection of fragments of understanding in the pursuit of deeper questions.
Content of the Lecture
What is Reinforcement Learning? Reinforcement Learning fuses ideas from neuroscience and AI. The model describes how an agent can interact with an environment and in that environment learn to improve its actions when it comes to gathering a targeted reward.
What makes reinforcement learning different from other machine learning paradigms?
Dopamine: Reward Prediction Error Papers: "Predictive Reward Signal of Dopamine Neurons"
From Schultz (89): "Dopamine neurons are activated by rewarding events that are better than predicted, remain uninfluenced by events that are as good as predicted, and are depressed by events that are worse than predicted. Most dopamine neurons show phasic activations [...] reward-predicting [...] However, only few phasic activations follow aversive (causing avoidance of a thing) stimuli. By signalling rewards according to a prediction error, dopamine responses have the formal characteristics of a teaching signal postulated by reinforcement learning theories."
![]() |
![]() |
|---|
If the neocortex mostly performs unsupervised learning why does the VTA strongly project to almost all cortical areas and what is the effect of DA on a cortical neuron?
The figure above pictures an animal experiment: Dopamine neurons report rewards according to an error in reward prediction. Top: drop of liquid (reward) occurs although no reward is predicted at this time. Middle: conditioned stimulus predicts a reward, and the reward occurs according to the prediction, hence no error in the prediction of reward. Bottom: conditioned stimulus predicts a reward, but the reward fails to occur because of lack of reaction by the animal. (CS = Conditioned Stimulus; R = Primary Reward).
The predicted reward is further modified by other factors:
Models of Learning Reward Prediction Even though these models here are called predicting models, we are looking at update rules which means the system changes over time -- it learns. We might connect one of these learning rules to a MDP or RL to find an optimal behavior function for our agent.
Rescorla Wagner Rule Model of classical conditioning in which learning is conceptualized in terms of associations between conditioned and unconditioned stimuli. Change in value is proportional to the difference between actual and predicted reward.
where: is the stimulus, is the associative strength of conditioned stimulus , R is the reward, is the learning rate, is the sum of associative strengths of all conditioned stimuli (including ) that are presented on this trial (the n-th trial) and is the surprise.
Two assumptions/hypotheses:
Temporal Difference (TD) Rule to Q-Learning Key Idea of the Temporal Difference Rule (TDR): update the value of the current state based on the immediate reward and the estimated value of the next state. Interpretation: we must not look only at immediate rewards but future rewards should be taken into consideration as well on a discounted valuation. We assume that the path our agents takes to navigate the system is given.
where is the previous estimate, is the next reward, is the discounted value on the next step and represents the TD target.
Lets now include the fundamental concept of an action to this equation. This adds one dimension to the value function and gives the agent a choice. This new function is called
By just a few trivial steps one can show that the TD rule is used to get the convex combination in the Q-Learning update rule between old and new Q value seen in the literature:
Given this rule, we can create and update a map over future states and actions. We can optimize w.r.t. the action to get an optimal path (policy). The key idea is that we do not need to know any transition probabilities to learn (model), we just need an unbiased estimate from out world (sample). We can get these samples by just playing the "game". If we store the actions a and rewards r from these samples, we can directly apply Q-learning. Thus, Q-learning is considered model-free. Keep in mind that (in the end), the optimal policy can be deducted from the optimal value function V*:
Introduction to Reinforcement Learning
![]() |
![]() |
|---|
We saw the concept of looking at expected reward and choosing actions to maximize this reward, but the idea was not well embedded into a generalizing concept. Reinforcement Learning (RL) exactly puts a name on this framework, which includes Q-Learning as well. RL is about an agent taking suitable action to maximize reward in a particular situation. It is employed by various software and machines to find the best possible behavior or path it should take in a specific situation.
In the pictures: influences from and to the agent in RL to the surrounding world. At each step t, the agent executes an action which the environment receives. The agent receives an observation of the environment, for example through a sensor and the agent is rewarded by its behavior from the environment.
Reinforcement Learning is based on the reward hypothesis: All goals of an agent can be described by the maximization of expected cumulative reward. A reward is a scalar feedback signal. It indicates how well the agent is doing at step t. The agent's job is to maximize cumulative reward.
Example rewards:
The Goal is to select actions that maximize total future rewards:
The fact that reward presented to the agent is not always immediate leads to the exploration/exploitation dilemma. An agent does not intrinsically know the future implications of its actions, or the dynamics of the environment.
The Agent State
At each point in time, the agent is in a state, because this information state is all that is necessary to fully determine the agent, it is also said that the state is markovian. This means we can throw away the history ( of previous actions, observations and rewards:
For the reasons explained above: . An RL agent may compute different functions on top of its state. An RL agent may include one or more of these components:
Policy The agents behavior function called policy maps from state s to action a. The policy may be stochastic or deterministic:
Value Function The value function is a prediction of future rewards and does so by assigning a number to every state s, it is used to evaluate the goodness/badness of states. It depends on a policy to determine where the agent could go and a probability distribution . We compute this value as an expectation over the joint distribution: .
The value function is defined as:
In the lecture slides is formulated as:
Model A model predicts what the environment will do next. From the previous section we see that we require a probability distribution that depends on direct actions a or a policy returning action :
That predicts the next (immediate) reward:
In the lecture slides is formulated as:
where P predicts the next state and R predicts the next (immediate) reward.
This is called the model. Model free RL uses tricks to not compute/require this distribution. As it is often intractable (Imagine the state space being the input of a video game).
In the image, a small example of a mice showing all the agent related components together with some numbers. (Top left) Actions, start, end and definition of other states (the maze). (Top right) Immediate rewards. (Bottom) Policy and Value Function for each state.
We have seen different RL-subtypes that need to be distinguished. Comment: from the Bellman Theorem we know that every value function induces a policy and every policy induces a value function:
A more sophisticated example is represented by the Atari Games. The Atari video-gaming platform provides an ideal environment to test RL/Planning strategies. For some games, we don't know the rules and apply RL. This means we learn directly from interactive gameplay. Pick actions on a joystick and observe the pixels. For other games we know the rules. This allows to apply planning strategies where we might ask ourselves: What would the next state be? What would the score be? We can query the future by tree search to some extent.
Planning Even though planning appear later in the lecture it is actually the logical step before we arrive at RL. It is a more constrained view where a model of the environment is known. The agent performs computations with its model (without any external interaction). This is a simplification compared to RL where the environment is initially unknown and the agent may only discover it. By interacting with the environment. In RL, the agent improves its policy or value function. If the agent/solver has access to the model, i.e., and , and it employs it when optimizing the MDP, then we are in the planning settings (or dynamic programing, DP, setting). Otherwise, we are in the RL settings. Of course, sometimes, even though we have access to the model, still we do RL since it is hard to solve directly the MDP, and we prefer to interact with the MDP rather than solving it, i.e., we ignore the model. In a planning scenario, we can query the future through the emulator. We can therefore play/plan ahead to find the optimal policy by tree search. As already mentioned, this might not be possible even for simple games. RL on the other hand can be as well referred to as "trial-and-error" learning. However, obviously we try to guide the agent to lose the least amount of reward that is possible.
Exploration / Exploitation Everyone is confronted with the same dilemma on a daily basis: should I keep doing what I do, or should I try something else. For example should I go to my preferred restaurant or should I try a new one, should I keep my current job or should I find a new one, etc...
In Reinforcement Learning, this type of decision is called exploitation when you keep doing what you were doing, and exploration when you try something new.
Basics Remark: In my opinion these chapters build the foundation for RL but in the lecture they appear after RL and thus I kept that order. If you are a beginner to these topics, I highly recommend to gain some basic knowledge about probabilistic graphic models (PGM) (Bayesian Networks) first. They are used from here on, but were not introduced explicitly in the lecture.
Markov Chain (MC) A Bayesian Network is a kind of PGM that uses a directed (acyclic) graph to represent a factorized probability distribution and associated conditional independence over a set of variables.
Definition: A state is Markov if and only if:
where is the current state and is the successor state.
The state captures all relevant information from the history. Once the state is known, the history may be thrown away. This means that the state is a sufficient statistic of the future.
![]() |
![]() |
![]() |
|---|
The state transition matrix P defines transition probabilities from all states to all successor states : (Left) An example Markov Chain showing all state transition probabilities next to its node. (Right) The corresponding state transition matrix and results of a sampling procedure applied to this Markov chain. Be aware that this is not a PGM, the nodes are not random variables.
Markov Reward Process (MRP) A Markov reward process is a stochastic process which extends a Markov chain by adding a reward rate to each state. Definition: A Markov Reward Process is a tuple where S is a finite set of states, P is a state transition probability matrix , is a reward function and is a discount in the interval (0,1).
Facts:
We call the return which is the total discounted reward from time step t onward.
If we just look at we must assume that we know the chain of events that lead to the specific rewards R, however the MRP is a stochastic process. Therefore we may compute the conditional value function given that we know where we start (. We have seen this function before in the RL chapter:
which is just
Hence, the state value function of an MRP is the expected return starting from state s. It gives the long-term value of state s.
![]() |
![]() |
![]() |
|---|
Markov Decision Process (MDP) Markov Decision Process (MDP) is a Markov reward process with decisions (actions that we can take). It is still an environment in which all states are Markov.
Definition: A Markov Reward Process is a tuple where S is a finite set of states, A is a finite set of actions, P is a state transition probability matrix , is a reward function and is a discount in the interval (0,1).
Markov Decision Processes formally describe an environment for Reinforcement Learning where the environment is fully observable. Almost all RL problems can be formalized as MDPs.
The MC seen before extended to be a MRP is here extended again to be an MDP. However, we should be careful with the comparisons. In the MRP, our agent was guided purely by randomness and we had no choice. Now, the agent is able to directly influence its path. Note that some of the transitions are deterministic. For example, if we quit Facebook, we are for sure back to studying, however if were in the pub, we might be too drunk and randomness influences the outcome.
One can see that we are very close now to what we introduced in the RL section, however, one key piece is missing. Given that we have choice as an agent now, how do we know the optimal behavior?
Bellman Equation The Bellman Equation (BE), named after Richard E. Bellman, is a necessary condition for optimality associated with the mathematical optimization method known as dynamic programming (aka. RL when the environment is known MDP). It allows us to "solve" the MDP problem, the problem of not knowing how to act in an environment where we are able to take action.
BE in MRP In the most simple case, we can just evaluate the Bellman expectation equation in an MRP where we have no policy to optimize.
This is the immediate reward plus the discounted value of the successor state . This is again close to the temporal difference rule. If we move the reward from the next state to the current one (by definition), we can pull out of it and compute the expected value through the sum and the equation becomes:
In figure below, we have an example computation of the value of the red node in an MRP.
One might argue that this leads to action values by choosing the next state based on its value "score". Also this can be solved explicitly as a linear system.
BE in MDP In MDP, we must somehow include the actions. Over the entire task, the actions we take are defined to be the policy. Since we can optimize this policy, one might ask how to do this using the Bellman optimality equation.
We may rewrite both in a similar manner as we did in the MRP case.
And if we again shift the reward:
As you can see, the notation becomes quite tedious. From now on we use . The same applies to actions. In the figure below we have an example of policy based computation of the value of the red node in an MDP.
Finding the optimal action-value (Q) function We can now define the optimal value function:
and the optimal action-value (q) function:
You may have noticed that we depend on the policy for and . An optimal policy can be found by maximizing the optimal Q-function :
There is always a deterministic optimal policy for any MDP. If we know , we immediately have the optimal policy. In the last step, this theorem allows us to assemble the Bellman optimality update equations. We now use the optimal value function ( to get the optimal Q-function:
Note that the agent has to average, because we can't choose. This is decided by the environment. Finally we may write down the Bellman optimality equations for and :
Bellman figured out that our policy being optimal means that we can be greedy w.r.t these optimality equations. If we update over and over again, we will converge to a fixed point which is the optimality policy.
Deep Reinforcement (Q) Learning Paper: "Human-Level Control Through Deep Reinforcement Learning".
In the previous sections, distribution were always treated as discrete tables. This is not possible for large state/action spaces. Therefore, functional approximations to these functions must be found. We have already seen that deep neural networks (DNN) are function approximators in their nature. One can parametrize a policy or Q-function and use DNN to estimate its parameters directly from state space. For optimization purposes, we define a loss function. This loss follows from moving Q inside of expectation.
We find the optimal action-value function by parametrizing it with (make it DNN compatible).
and then minimize the loss w.r.t . Comment: Often, we approximate by sampling. The following represents the loss function to update the Q-learning rule:
This is again the temporal difference rule.
In the picture above we have a deep RL system trained directly from input (Atari game video output) to actions of the controlling joystick.
On-policy methods estimate the value of a policy while using it for control. In Off-policy methods, the policy used to generate behavior, called the behavior policy, may be unrelated to the policy that is evaluated and improved, called the estimation policy.
From the Sutton book: "The on-policy approach in the preceding section is actually a compromise - it learns action values not for the optimal policy, but for a near-optimal policy that still explores. A more straightforward approach is to use two policies, one that is learned about and that becomes the optimal policy, and one that is more exploratory and is used to generate behavior. The policy being learned about is called the target policy, and the policy used to generate behavior is called the behavior policy. In this case we say that learning is from data "" the target policy, and the overall process is termed "-policy learning".