Skip to content
New
Latest News || 27 October 2026: Dr Soumava Mukherjee's invited talk at Queen's University Belfast joined device-level hardware innovation with channel-level control. || 22 October 2026: I received a Certificate of Appreciation for serving as a reviewer for IEEE IMAS 2026. || 15 October 2026: I presented a poster on beam-domain ML fingerprinting for RIS-aided mmWave localisation at the Centre for Wireless Innovation's annual symposium. || 15 October 2026: CWI's annual symposium brought research and industry perspectives on 6G, ISAC, optical wireless, AI, and future networks to Queen's University Belfast. || 14 October 2026: Erik Nordell of Ericsson visited our Keysight Lab for a live RIS-assisted video streaming demonstration.
Knowledge Hubmachine learning10. Reinforcement Learning and Deep RL

machine learning learning note

10. Reinforcement Learning and Deep RL

A clearer and deeper guide to reinforcement learning, value functions, policies, exploration, Q-learning, and deep RL.

At a glance

  • Actions change future observationsRL learns a policy through transitions and rewards; useful decisions may trade immediate reward for future return.
  • A Q update has a targetTabular Q-learning moves an action value toward reward plus discounted best next-state value, with no terminal bootstrap.
  • Evaluate the learned policy separatelyExploration affects training returns. Check greedy evaluation, several seeds and realistic scenarios before drawing conclusions.

What is Reinforcement Learning?

Reinforcement Learning (RL) is about learning how to act. An agent interacts with an environment, takes actions, receives rewards, and gradually learns a strategy that produces high long-term reward.

Unlike supervised learning, the agent is not given the correct answer for every situation. It must learn from consequences.

Examples:

  • A robot learns to walk.
  • A game agent learns to win.
  • A wireless controller learns channel access or power allocation.
  • A vehicle learns safe merging behavior in simulation.
References for this section3

The RL Loop

Every RL problem has a feedback loop:

  1. The agent observes the current state.
  2. The agent chooses an action.
  3. The environment changes.
  4. The agent receives a reward.
  5. The agent observes the next state.
References for this section3

Key Components

References for this section3

Agent

The learner or decision maker.

Examples: robot, game-playing AI, scheduler, radio resource controller.

References for this section3

Environment

The world the agent interacts with.

Examples: a game, a robot simulation, a wireless network, a traffic system.

References for this section3

State

The information available to the agent at a given time.

Examples: robot joint positions, channel state, queue length, game screen, or vehicle speed.

References for this section3

Action

The choice made by the agent.

Examples: move left, increase transmit power, select a beam, allocate a resource block.

References for this section3

Reward

The feedback signal.

Examples: +1 for success, -1 for collision, high reward for throughput, penalty for energy use.

References for this section3

Policy

The policy is the agent's behavior rule. It maps states to actions.

policy: state -> action

The goal of RL is to learn a policy that maximizes long-term reward.

References for this section3

Immediate Reward vs. Long-Term Return

RL is difficult because the best action now may not give the best immediate reward. The agent must think about future consequences.

Example:

  • A robot may take a slow step now to avoid falling later.
  • A network scheduler may serve a weaker user now to improve fairness over time.
  • A game agent may sacrifice a piece now to win later.

The discounted return is a common way to value future rewards:

Gt=∑k=0∞γkrt+k+1.G_t=\sum_{k=0}^{\infty}\gamma^k r_{t+k+1}.
  • rt+1r_{t+1}: reward received after action at step tt.
  • GtG_t: discounted future return from step tt.

A finite episode stops the sum at termination.

  • γ\gamma: discount factor.

A larger discount factor gives later rewards greater weight.

Immediate reward or long-term return? The discount factor decides

1. Formula and symbols
G0=∑k=0H−1γkrk=r0+γr1+γ2r2+⋯G_0=\sum_{k=0}^{H-1}\gamma^kr_k=r_0+\gamma r_1+\gamma^2r_2+\cdots
  • rkr_k: Reward received k steps from now
  • γ\gamma: Discount factor between 0 and 1: how much a reward one step later is worth
  • HH: Horizon (15 steps here)
  • G0G_0: Discounted return: the quantity an RL agent tries to maximise

γ = 0 makes the agent short-sighted (only r₀ counts); γ close to 1 makes it patient.

Agent (policy)Environmentactionstate,rewardA: grab reward now · G = 3.50 ✓k = 0k = 14B: move to a better spot first · G = -1.25k = 0k = 14The RL loop runs once per time step koutline: reward rₖ · filled: γᵏrₖ (worth today)
2. Work with the current inputs
GA=2(1+γ+γ2)=3.500G_A=2(1+\gamma+\gamma^2)=3.500
GB=−(1+γ+γ2)+2∑k=314γk=−1.250G_B=-(1+\gamma+\gamma^2)+2\sum_{k=3}^{14}\gamma^k=-1.250
GA=GB at γ≈0.864G_A=G_B\ \text{at}\ \gamma\approx0.864
3. Result
Return of A3.50
Return of B-1.25
Agent prefersA (short-term)switch point γ ≈ 0.86
Left: the agent–environment loop (action out, new state and reward back, every step). Right: two possible behaviours. A takes +2 for three steps, then nothing. B pays −1 for three steps (e.g. steering a beam or moving), then earns +2 every step. Bar outlines are the raw rewards; the filled part is what each reward is worth today, γᵏ rᵏ. Raise γ and the patient behaviour wins.
References for this section3

Exploration vs. Exploitation

The agent must balance two behaviors:

  • Exploration: Try new actions to discover better strategies.
  • Exploitation: Use the best-known action to collect reward.

If the agent only exploits, it may get stuck with a mediocre strategy. If it only explores, it may never use what it has learned.

Common exploration methods:

  • Epsilon-greedy action selection.
  • Softmax action selection.
  • Upper confidence bound.
  • Entropy bonuses in policy-gradient methods.

Exploration vs exploitation: picking the best beam by trial

1. Formula and symbols
at={random beamwith probability εarg⁡max⁡aQ^(a)otherwisea_t=\begin{cases}\text{random beam}&\text{with probability }\varepsilon\\\arg\max_a\widehat Q(a)&\text{otherwise}\end{cases}
Q^(a)←Q^(a)+1N(a)(rt−Q^(a)),regret=∑t(μ⋆−μat)\widehat Q(a)\leftarrow\widehat Q(a)+\frac{1}{N(a)}\big(r_t-\widehat Q(a)\big),\qquad\text{regret}=\sum_t\big(\mu^\star-\mu_{a_t}\big)
  • ata_t: Beam chosen at step t
  • ε\varepsilon: Exploration rate
  • Q^(a)\widehat Q(a): Average throughput measured so far on beam a
  • N(a)N(a): How many times beam a has been tried
  • rtr_t: Measured throughput (true mean plus unit-variance noise)
  • μa, μ⋆\mu_a,\ \mu^\star: True mean of beam a and of the best beam

This is a multi-armed bandit: the simplest RL problem, with actions and rewards but no state changes.

BS12345Beam length: estimate · opacity: how often used0123estimate (filled) vs true mean (dashed)beam 19×beam 21×beam 3180×beam 47×beam 53×time slotcumulative regret
2. Work with the current inputs
Q^=(1.64, −0.49, 2.22, 0.54, 1.01),μ=(1, 1.6, 2.2, 0.6, 1.3)\widehat Q=(1.64,\ -0.49,\ 2.22,\ 0.54,\ 1.01),\quad\mu=(1,\ 1.6,\ 2.2,\ 0.6,\ 1.3)
N=(9, 1, 180, 7, 3),regret=25.3N=(9,\ 1,\ 180,\ 7,\ 3),\quad\text{regret}=25.3
3. Result
Agent’s favourite beamBeam 3correct: the best beam
Slots on the best beam90.0%
Total regret25.3
A base station must choose one of five beams each slot; it only learns a beam’s throughput by using it. Filled bars are the agent’s estimates, outlines the true means (hidden from the agent). With ε = 0 it exploits its first lucky guess forever and never finds beam 3. A little exploration finds the best beam; too much wastes slots on bad beams. Bottom: regret, the throughput lost versus always using the best beam.
References for this section3

Value Functions

A value function estimates how good a state or action is.

References for this section3

State Value

The state value estimates the expected future reward from a state if the agent follows a policy.

Vπ(s)=Eπ[Gt∣St=s].V^{\pi}(s)=\mathbb E_{\pi}[G_t\mid S_t=s].

StS_t is state at step tt, π\pi the followed policy, and Eπ\mathbb E_\pi its expectation.

References for this section3

Action Value

The action value estimates the expected future reward after taking action a in state s.

Qπ(s,a)=Eπ[Gt∣St=s,At=a].Q^{\pi}(s,a)=\mathbb E_{\pi}[G_t\mid S_t=s,A_t=a].

AtA_t is the action at step tt. Policy-specific values differ from the optimal action values sought by Q-learning.

Q-values are central to Q-learning and Deep Q-Networks.

References for this section3

Q-Learning

Q-learning is a classic value-based RL algorithm. It learns a table of action values.

For each state-action pair, the agent updates its estimate using the reward received and the estimated value of the next state.

For a transition (s,a,r,s′)(s,a,r,s'), update:

y=r+γmax⁡a′Q(s′,a′),Q(s,a)←Q(s,a)+α[y−Q(s,a)].\begin{aligned} y&=r+\gamma\max_{a'}Q(s',a'),\\ Q(s,a)&\leftarrow Q(s,a)+\alpha[y-Q(s,a)]. \end{aligned}
  • α\alpha: learning rate.
  • γ\gamma: discount factor.
  • yy: Q-learning update target.
  • rr: reward for the observed transition.
  • ss: current state.
  • aa: current action.
  • s′s': next state.

At a true terminal state use y=ry=r. An external time-limit truncation ends a rollout but can still require bootstrapping for an ongoing task. In the lab, ε\varepsilon is the probability of drawing a random training action; the displayed greedy route uses the largest learned Q instead.

Can a table learn a route from rewards?

1. Formula and symbols
y=r+γmax⁡a′Q(s′,a′)y=r+\gamma\max_{a'}Q(s',a')
Q(s,a)←Q(s,a)+α[y−Q(s,a)]Q(s,a)\leftarrow Q(s,a)+\alpha[y-Q(s,a)]
y=rat true terminationy=r\quad\text{at true termination}
  • ss: Current state
  • aa: Chosen action
  • s′s': next state
  • rr: reward
  • QQ: action-value estimate
  • α\alpha: step size
  • γ\gamma: discount
  • yy: update target. ε controls random exploration during training

greedy evaluation uses the maximum Q.

S0.43→0.10→0.29↓0.55↓0.52×→-0.02↓0.79→0.62↓0.73×↓0.99→0.73→0.86→1.00G0.00S: start · G: goal · ×: wall · Orange line: greedy routeArrows show policy; values estimate discounted return.
2. Work with the current inputs
Q(s,a)←Q(s,a)+α[r+γmax⁡a′Q(s′,a′)−Q(s,a)]Q(s,a)\leftarrow Q(s,a)+\alpha[r+\gamma\max_{a'}Q(s',a')-Q(s,a)]
Qlast=1.000+0.3(1.000−1.000)=1.000Q_{\rm last}=1.000+0.3(1.000-1.000)=1.000
s=14,a=1,r=1,γ=0.9s=14,\quad a=1,\quad r=1,\quad\gamma=0.9
3. Result
Training episodes reaching goal119 / 120
Current greedy route6 steps to goal
Learned max Q at start0.427
Deterministic 4×4 grid, start S=0, goal G=15, blocked cells 5 and 10. Every nonterminal step costs −0.04; reaching the goal gives +1. Q starts at zero; epsilon-greedy exploration uses a fixed random seed, with first-action tie breaking. Episodes stop after 80 steps; terminal targets do not bootstrap. The displayed greedy route stops on a loop. This is tabular Q-learning, not a DRL benchmark.
References for this section3

Intuition

If an action leads to good future rewards, increase its Q-value. If it leads to bad outcomes, decrease its Q-value.

References for this section3

Limitation

Q-learning works well when the state and action spaces are small. It becomes impractical when states are huge, such as raw images or continuous sensor readings.

References for this section3

Policy Gradient Methods

Policy gradient methods learn the policy directly. Their updates increase the probability of actions associated with better return, rather than applying the tabular Q-learning update above.

References for this section3

Intuition

If an action leads to high reward, make that action more likely in similar situations. If it leads to poor reward, make it less likely.

These methods are useful for continuous action spaces, such as robot control or power-control problems.

References for this section3

Deep Reinforcement Learning

Deep Reinforcement Learning (DRL) combines neural networks with RL. The neural network approximates a policy, a value function, or both.

The breakthrough result from DeepMind showed that a Deep Q-Network could learn to play Atari games directly from raw pixels. This connected representation learning with reinforcement learning at scale.

References for this section3

Deep Q-Network

A Deep Q-Network (DQN) replaces the Q-table with a neural network.

Deep Q-Network: replay buffer and target network

1. Formula and symbols
y=r+γmax⁡a′Q(s′,a′;θ−)y=r+\gamma\max_{a'}Q(s',a';\theta^-)
L(θ)=(y−Q(s,a;θ))2,Q←Q+α (y−Q)\mathcal L(\theta)=\big(y-Q(s,a;\theta)\big)^2,\qquad Q\leftarrow Q+\alpha\,(y-Q)
  • Q(s,a;θ)Q(s,a;\theta): Online network’s estimate of the return for action a in state s
  • θ−\theta^-: Frozen copy of the weights (target network), refreshed every C steps
  • yy: TD target built from the reward and the target network
  • r, γr,\ \gamma: Reward and discount factor
  • α\alpha: Learning-rate-like step (0.1 here, as one tabular-style update)

The replay buffer breaks the correlation between consecutive samples; the frozen target network stops the target from moving every time θ changes.

store (s, a, r, s′)minibatchs′Q(s, a)y = r + γ max Q⁻copy every C stepsEnvironmentReplay bufferOnline Q-network θTarget network θ⁻Loss (y − Q)²This transition: y = 4.60, Q(s, a) = 3 → loss 2.56Q-values come from a neural network in DQN; the same arithmetic happens for every sample in the minibatch.
Architecture
2. Work with the current inputs
y=1+0.9×4=4.600y=1+0.9\times4=4.600
L=(4.600−3)2=2.560,Qnew=3+0.1(1.600)=3.160\mathcal L=(4.600-3)^2=2.560,\quad Q_{\rm new}=3+0.1(1.600)=3.160
3. Result
TD target y4.60
Squared TD error2.560
Q(s, a) after one step3.160
Data flow of DQN (the moving dot follows one cycle). Experience goes into a replay buffer; random minibatches train the online network towards a target computed with a frozen target network. The sliders set one sampled transition so you can compute its target and loss.
References for this section3

Key Ideas

  • Experience replay: Store past transitions and sample them randomly during training.
  • Target network: Use a slowly updated copy of the network to stabilize targets.
  • CNN feature extraction: Learn useful representations from game images or other high-dimensional observations.

These ideas made value-based deep RL much more stable.

References for this section3

Actor-Critic Methods

Actor-critic methods combine two models:

  • Actor: Chooses actions.
  • Critic: Estimates how good those actions are.

The critic helps the actor learn more efficiently. Many modern DRL methods are actor-critic variants.

Actor–critic: one network acts, one judges

1. Formula and symbols
δ=r+γV(s′)−V(s)\delta=r+\gamma V(s')-V(s)
V(s)←V(s)+αδ,θa←θa+α δ (1[a=at]−π(a∣s))V(s)\leftarrow V(s)+\alpha\delta,\qquad\theta_a\leftarrow\theta_a+\alpha\,\delta\,\big(\mathbf1[a=a_t]-\pi(a|s)\big)
  • V(s)V(s): Critic’s estimate of the return from state s
  • δ\delta: TD error: better (δ > 0) or worse than the critic expected
  • π(a∣s)\pi(a|s): Actor’s softmax probability of action a
  • θa\theta_a: Actor’s preference (logit) for action a
  • ata_t: Action actually taken (action 1 here)
  • α\alpha: Step size (0.1 here)

The critic judges, the actor acts. Using δ instead of the raw return lowers the variance of policy-gradient updates.

state saction ar, s′V(s), V(s′)δraise π(a|s) if δ > 0EnvironmentActor π(a|s)Critic V(s)TD error δUpdate bothThis transition: δ = 1.60 → critic V(s) 3 → 3.16Actor: P(action 1) 0.506 → 0.537 because δ is positive.
Architecture
2. Work with the current inputs
δ=1+0.9×4−3=1.600,Vnew(s)=3.160\delta=1+0.9\times4-3=1.600,\quad V_{\rm new}(s)=3.160
π(⋅∣s):(0.506, 0.307, 0.186)→(0.537, 0.286, 0.177)\pi(\cdot|s):(0.506,\ 0.307,\ 0.186)\rightarrow(0.537,\ 0.286,\ 0.177)
3. Result
TD error δ1.600better than expected
π(action 1 | s)0.506 → 0.537
Data flow of an actor–critic method. The actor chooses actions; the critic estimates values and turns each reward into a TD error δ. A positive δ means ‘better than expected’, so the actor makes that action more likely. The sliders set one transition.
References for this section3

RL in Wireless and Communication Systems

RL is attractive in communication systems because many problems involve sequential decisions under uncertainty.

Examples:

  • Beam selection.
  • Power control.
  • Spectrum access.
  • Handover decisions.
  • Edge computing offloading.
  • RIS phase configuration.
  • Resource allocation under changing traffic.

However, RL must be used carefully. Real wireless systems have safety, latency, sample-efficiency, and explainability constraints. Simulation-to-reality mismatch is also a major issue.

References for this section3

Practical Challenges

  • Sample inefficiency: RL may need many interactions.
  • Reward design: A poorly designed reward can produce unwanted behavior.
  • Stability: Training can be noisy or unstable.
  • Safety: Exploration can be risky in real systems.
  • Generalization: A policy trained in one environment may fail in another.
  • Evaluation: Results should be tested across many random seeds and scenarios.
References for this section3

Python: Minimal Q-Learning Table

This tiny example shows the skeleton of tabular Q-learning. It uses Gymnasium FrozenLake with deterministic movement. A true terminal transition has no bootstrap; an external truncation ends the rollout while retaining its next-state value.

import numpy as np
import gymnasium as gym

env = gym.make("FrozenLake-v1", is_slippery=False)
env.reset(seed=42)
n_states = env.observation_space.n
n_actions = env.action_space.n
q = np.zeros((n_states, n_actions))

alpha = 0.1
gamma = 0.99
epsilon = 0.1
rng = np.random.default_rng(42)

for episode in range(1000):
    state = env.reset()[0]
    done = False

    while not done:
        if rng.random() < epsilon:
            action = rng.integers(n_actions)
        else:
            action = np.argmax(q[state])

        next_state, reward, terminated, truncated, info = env.step(action)
        done = terminated or truncated

        best_next = 0.0 if terminated else np.max(q[next_state])
        q[state, action] += alpha * (
            reward + gamma * best_next - q[state, action]
        )

        state = next_state
References for this section3

Python: Load a DRL Agent with Stable-Baselines3

For practical DRL, it is better to start with a tested library. Stable-Baselines3 provides implementations of DQN, PPO, A2C, SAC, TD3, and other algorithms.

# pip install stable-baselines3 gymnasium

import gymnasium as gym
from stable_baselines3 import DQN

env = gym.make("CartPole-v1")

model = DQN(
    "MlpPolicy",
    env,
    learning_rate=1e-3,
    buffer_size=50_000,
    learning_starts=1_000,
    batch_size=32,
    gamma=0.99,
    verbose=1,
)

model.learn(total_timesteps=20_000)
model.save("dqn_cartpole")

loaded_model = DQN.load("dqn_cartpole", env=env)
obs, info = env.reset()

for _ in range(500):
    action, _ = loaded_model.predict(obs, deterministic=True)
    obs, reward, terminated, truncated, info = env.step(action)
    if terminated or truncated:
        obs, info = env.reset()
References for this section3

Python: PPO for Continuous or More Stable Control

PPO is often a strong first choice because it is relatively stable across many environments.

import gymnasium as gym
from stable_baselines3 import PPO

env = gym.make("CartPole-v1")

agent = PPO("MlpPolicy", env, verbose=1)
agent.learn(total_timesteps=20_000)

agent.save("ppo_cartpole")

For wireless-system research, the main work is usually not calling DQN() or PPO(). The hard part is designing the environment: state representation, action space, reward function, constraints, and realistic channel/network dynamics.

References for this section3

Takeaway

  • Reinforcement learning: choose actions using feedback from rewards.
  • Value-based method: estimate how useful each action is.
  • Policy-gradient method: learn action preferences directly.
  • Deep RL: uses neural networks for larger state spaces; reward design and reliable evaluation remain essential.

Continue with Transfer Learning to build on this note.

References for this section3

Check your understanding

0 of 4 answered

  1. With rewards 1 now and 2 next step, γ=0.5 and no later rewards, what is return?

  2. Q=0.2, target=0.8 and α=0.5. What is the updated Q?

  3. A transition truly terminates with reward +1. What is its Q-learning target?

  4. In ε-greedy training with ε=0.2, what fraction of choices are drawn from the random-action branch in expectation?

Complete references and further reading