Thomas Piacentini
← Workshop
← All concepts

Decide and learn

Concept 1 / 8

Change concept
01 · State, action and return

State, action and return

A decision is judged by future consequences as well as immediate reward.

Your turn

2
Immediate reward10.9 × V1.8+= 2.8
InputTransformationResult

Add2.8

The target combines present reward and discounted future value.

Build
Final result · Bellman target2.8

Understand the calculation, step by step

An MDP specifies states, actions, transitions and rewards. Discounted return is Gₜ=Σₖγᵏrₜ₊ₖ₊₁; a policy selects action distributions from state. Partial observations need not form a Markov state. Separate training from evaluation; increasing reward does not prove delivery succeeds.

Bellman target

r=1 ; γ=0.9 ; target = 1 + 0.9V (nonterminal)

Check my understanding

For Next value V = 3, what is the value of « Bellman target » ?

Keep a thought in my notebook
Read the source and go further

The extended record combines confirmed reading, interaction, correct answer and a note of at least 40 characters. You can continue at any time.

02 · Policy evaluation and improvement

Policy evaluation and improvement

With known rules, work backwards from the goal to evaluate decisions.

Your turn

90 %
γ = 0.900V=0.8101V=0.9+12V=13V=0endAdvance or stay · reward on entry
InputTransformationResult

Three backups(0.81 ; 0.9 ; 1 ; 0)

The third passes γ² to the initial state. This is value iteration, not an animated journey.

Build
Final result · initial-state value V(0)0.81

Understand the calculation, step by step

With known dynamics, Vπ(s)=Σₐπ(a|s)Σₛ′P(s′|s,a)[r+γVπ(s′)]. Evaluation approximates Vπ; improvement chooses actions with best predicted return. Value iteration directly uses a maximum over actions. Terminal states have no future continuation value. Compare with A* when movement becomes stochastic.

Four-state value iteration

states 0→1→2→3 terminal ; stay or advance ; reward 1 on arrival ; V←maxₐ(r+γV next)

Check my understanding

For Discount γ = 0.5, what is the value of « initial-state value V(0) » ?

Keep a thought in my notebook
Read the source and go further

The extended record combines confirmed reading, interaction, correct answer and a note of at least 40 characters. You can continue at any time.

03 · SARSA, Q-learning and exploration

SARSA, Q-learning and exploration

An agent updates what it expects from an action using what just happened.

Your turn

2
α = 0.21targetQ′ = 1.2
InputTransformationResult

Correct by 20%1.2

The new estimate moves 20% toward the target rather than replacing it entirely.

Build
Final result · new Q value1.2

Understand the calculation, step by step

TD corrects a value using a partly estimated target. SARSA uses the actual next action: r+γQ(s′,a′). Q-learning uses r+γmaxₐQ(s′,a), even if exploration chooses differently. Both update Q←Q+α(target−Q). An ε-greedy policy explores; also evaluate without exploration.

TD update

Q=1 ; α=0.2 ; Q′=1+0.2(y−1)

Check my understanding

For Target y = 3, what is the value of « new Q value » ?

Keep a thought in my notebook
Read the source and go further

The extended record combines confirmed reading, interaction, correct answer and a note of at least 40 characters. You can continue at any time.

04 · Eligibility traces and planning

Eligibility traces and planning

A delayed reward can update several recent decisions.

Your turn

2
α = 0.21targetQ′ = 1.2
InputTransformationResult

Correct by 20%1.2

The new estimate moves 20% toward the target rather than replacing it entirely.

Build
Final result · new Q value1.2

Understand the calculation, step by step

Eligibility e(s,a) records recent visits, typically decaying by γλ. A TD error can update several past pairs: Q←Q+αδe. Planning reuses a learned model for additional updates; priority can favour large errors. Off-policy traces require a suitable rule, such as cutting them in Watkins Q(λ).

TD update

Q=1 ; α=0.2 ; Q′=1+0.2(y−1)

Check my understanding

For Target y = 3, what is the value of « new Q value » ?

Keep a thought in my notebook
Read the source and go further

The extended record combines confirmed reading, interaction, correct answer and a note of at least 40 characters. You can continue at any time.

05 · Approximate Q with a network

Approximate Q with a network

A network can estimate action values when a simple table becomes too large.

Your turn

1
L(q) = (q−3)²/2y = 3 · ∂L/∂q = -2
InputTransformationResult

Loss gradient-2

The gradient is q−3. This is not a full DQN training simulation.

Build
Final result · loss gradient-2

Understand the calculation, step by step

DQN replaces the table with Qθ(s,a), one output per discrete action. A transition provides a Bellman target detached from gradients; backpropagation adjusts the prediction. Replay mixes transitions, reducing temporal correlation. A separate target network is a common stabilization, not assumed in every historical version. This exercise isolates a squared-loss gradient.

DQN loss and gradient

detached target y=3 ; L=(q−3)²/2 ; ∂L/∂q=q−3

Check my understanding

For Network prediction q = 2, what is the value of « loss gradient » ?

Keep a thought in my notebook
Read the source and go further

The extended record combines confirmed reading, interaction, correct answer and a note of at least 40 characters. You can continue at any time.

06 · PuckWorld: continuous state, discrete actions

PuckWorld: continuous state, discrete actions

Describing position with numbers lets an agent learn actions in continuous space.

Your turn

1
L(q) = (q−3)²/2y = 3 · ∂L/∂q = -2
InputTransformationResult

Loss gradient-2

The gradient is q−3. This is not a full DQN training simulation.

Build
Final result · loss gradient-2

Understand the calculation, step by step

Continuous position and velocity yield too many states for a small table. A network can interpolate inputs while choosing a few discrete pushes. Normalize coordinates and distinguish learned performance from simple target chasing. The original demo shows full training; the local calculation handles one transition rather than training PuckWorld.

DQN loss and gradient

detached target y=3 ; L=(q−3)²/2 ; ∂L/∂q=q−3

Check my understanding

For Network prediction q = 2, what is the value of « loss gradient » ?

Keep a thought in my notebook
Read the source and go further

The extended record combines confirmed reading, interaction, correct answer and a note of at least 40 characters. You can continue at any time.

07 · WaterWorld: perception and reward

WaterWorld: perception and reward

What an agent perceives limits what it can learn to avoid or seek.

Your turn

2
Immediate reward10.9 × V1.8+= 2.8
InputTransformationResult

Add2.8

The target combines present reward and discounted future value.

Build
Final result · Bellman target2.8

Understand the calculation, step by step

Perception rays encode nearby objects and distances in an observation vector. Reward can favour food and avoid hazards, but performance depends on visible information and reward design. Hidden state outside the rays may make the task partially observable. Compare with exact position in our grid.

Bellman target

r=1 ; γ=0.9 ; target = 1 + 0.9V (nonterminal)

Check my understanding

For Next value V = 3, what is the value of « Bellman target » ?

Keep a thought in my notebook
Read the source and go further

The extended record combines confirmed reading, interaction, correct answer and a note of at least 40 characters. You can continue at any time.

08 · REINFORCE, baseline and recurrence

REINFORCE, baseline and recurrence

Action-selection probabilities can be adjusted directly from outcomes.

Your turn

0
θ0Other action050 %50 %A = 2 · ∂J/∂θ = 1
InputTransformationResult

Policy gradient1

The gradient is 2(1−p): its effect shrinks when this action is already likely.

Build
Final result · policy gradient1

Understand the calculation, step by step

Stochastic policy gradients use ∇log πθ(a|s)(G−b). An action-independent baseline reduces variance without changing expectation; an actor chooses and a critic estimates value. An LSTM can retain observation history. Deterministic gradients chain ∂Q/∂a with ∂μθ/∂θ. The author flags these implementations as unstable: study the ideas without treating them as reliable training.

Policy gradient

p=sigmoid(θ) ; chosen action=1 ; advantage=2 ; ∂J/∂θ=2(1−p)

Check my understanding

For Binary action logit θ = 1, what is the value of « policy gradient » ?

Keep a thought in my notebook
Read the source and go further

The extended record combines confirmed reading, interaction, correct answer and a note of at least 40 characters. You can continue at any time.

Take this further

atomsh / lab