Policies and rewards
The policy is a function that maps a given state 𝑠 to an action 𝑎.
The optimal policy (s) returns the maximum return from state s
Rewards received in future are worth less than immideate rewards because future rewards are uncertain and potentially delayed
The more further in future we look, more uncertain the outcomes become
Bellman optimality equation

Given a policy π the Q function computes how good it is to take action a in state s then follow the policy π
Bellman equation sums all discounted future rewards by considering infinite horizon (hyperparameter) of future states/episodes and actions
s: current state
a: current action
r(s): immideate reward after transitioning from state s
s': next state after taking action a from state s
a': future action to be taken from state s'
γ: discounting factor
Total expected return from any state-action pair can be decomposed into:
- Immideate reward r(s)
- Discounted value of best possible return from next state s'
Stochastic transitions

E: expectation operator, all possible states weighted by their probabilities


We want to predict Q(s, a) for all four actions possible
We pick the action a that maximizes Q(s, a)
Deep Q-learning
- Train a neural network to approximate Q-function which estimates the expected future rewards of taking action a in state s
- Network is trained to predict Q(s, a) using supervised learning
- Initilize the neural network with random weights
- replay by storing the most recent 10,000 tuples
- update the networks weights to minimize difference between predicted Q-values and target values y
- Continously update the policy gradient to maximise long-term rewards
Replay buffer stores agent's experiences in form of tuples (s, a, r, s')
The buffer has a fixed capacity (10,000 experiences). When the buffer is full, the oldest experiences are discarded to make room for new ones
How to choose actions while still learning?
Option 1:
Pick the action that maximizes Q(s, a)
Option 2: (E-greedy policy)
switch between two states;
With probability 0.95, pick the action a that maximizes Q(s, a) "Exploitation"
With probability 0.05, pick an action a randomly "Exploration"
(E = 0.05)
Mini batch gradient descent why needed?
Traditional gradient descent algorithms computes updates using entire dataset, which is computationally expensive
Instead of all data, mini batch gradient descent uses mini-batches of entire dataset to update the model
Makes each iteration faster as it processes fewer examples per step
Soft updates
Directly updating Q-function with new params can lead to instability
Instead of completely replacing old params with new ones, soft updates blend a small portion of new params with old ones

They prevent Q-function from being overly influenced by noisy updates