Unexpected outcomes drive learning. RPE-PER uses this principle to decide which experiences should be replayed more often.
Reward Prediction Error Prioritised Experience Replay (RPE-PER) is a biologically motivated experience replay strategy for off-policy reinforcement learning. It prioritises transitions according to the discrepancy between predicted and observed rewards, allowing the agent to revisit experiences whose outcomes are not yet well predicted.
RPE-PER is implemented in PyTorch, integrated with TD3 and SAC, and evaluated on continuous-control tasks from the MuJoCo benchmark suite.
Paper: Reward Prediction Error Prioritisation in Experience Replay: The RPE-PER Method
Proceedings: ACRA 2024 Proceedings Paper
Presented at: Australasian Conference on Robotics and Automation (ACRA 2024)
Learning is strongly influenced by the difference between what we expect and what actually happens.
Consider visiting a familiar restaurant. Based on previous experiences, you already have an expectation of how rewarding the meal will be. If the experience is exactly as expected, there may be little reason to substantially revise that expectation. But if the outcome is far better or far worse than expected, the discrepancy can produce a stronger learning signal and have a greater influence on future decisions.
This difference between expected reward and received reward is known as Reward Prediction Error (RPE).
Conceptually, the signed reward prediction error can be written as
where
- Positive RPE: the outcome is better than expected.
- Near-zero RPE: the outcome matches expectation.
- Negative RPE: the outcome is worse than expected.
The key intuition is:
The greater the violation of expectation, the stronger the potential learning signal.
RPE-PER transfers this principle to experience replay by prioritising transitions whose rewards differ most from what the agent predicted.
Off-policy reinforcement-learning agents store interactions in a replay buffer as transitions
where
Standard Experience Replay samples stored transitions uniformly. However, not every experience is equally informative.
Prioritised Experience Replay (PER) addresses this by increasing the probability of replaying transitions with large temporal-difference (TD) errors.
TD error measures a discrepancy between a value estimate and its bootstrapped target. Although useful, it depends on value-function estimation and can be influenced by bootstrapping, function approximation, and changes in the learned policy.
RPE-PER takes a different perspective and focuses directly on the observed reward outcome:
How different was the received reward from the reward the agent predicted?
This provides a direct and interpretable signal for identifying experiences whose outcomes are still poorly predicted.
For each stored transition, the critic predicts the immediate reward associated with the state-action pair:
where
RPE-PER defines the reward prediction error used for prioritisation as
This is the squared discrepancy between predicted and observed reward.
Unlike the signed biological RPE introduced above, RPE-PER uses the magnitude of the reward-prediction mismatch for replay prioritisation. Squaring the discrepancy makes the prioritisation signal non-negative and gives greater emphasis to larger prediction errors.
Therefore:
- an outcome that is much better than expected can produce a large RPE;
- an outcome that is much worse than expected can also produce a large RPE;
- an outcome that closely matches expectation produces a small RPE.
In short:
Observed reward ≈ Predicted reward
│
▼
Small RPE
│
▼
Lower replay priority
Observed reward ≠ Predicted reward
│
▼
Large RPE
│
▼
Higher replay priority
│
▼
Replay more often
Experiences whose rewards violate the agent's expectations more strongly receive greater replay priority.
For each transition, replay priority is defined as
where
The probability of sampling transition
where
-
$\alpha = 0$ corresponds to uniform sampling. - Larger
$\alpha$ places greater emphasis on transitions with high RPE.
To compensate for the bias introduced by non-uniform sampling, importance-sampling weights are applied:
where
The replay process can therefore be summarised as:
Reward prediction → Reward prediction error → Replay priority → Prioritised sampling → Learning update
To enable reward-based prioritisation, RPE-PER introduces an Enhanced Model Critic Network (EMCN).
A conventional critic primarily estimates the action value associated with a state-action pair. EMCN extends this architecture by jointly predicting the action value, immediate reward, and next state.
For a state-action pair
where:
-
$Q_{\theta}(s,a)$ estimates the action value; -
$R_{\theta}(s,a)$ predicts the immediate reward; -
$T_{\theta}(s,a)$ predicts the next state or its representation.
The reward-prediction component provides the expected reward required to compute RPE. For transition
This RPE value is then used to determine replay priority.
Importantly, predicted rewards do not replace observed rewards in value learning. TD3 and SAC continue to use the actual environment reward
Reward prediction serves a separate purpose: identifying which stored experiences should receive greater attention during replay.
The underlying RL algorithm determines how the agent learns; RPE-PER determines which experiences are replayed more often.
At a high level, the RPE-PER learning process is:
Environment Interaction
│
▼
Transition (s, a, r, s')
│
▼
Replay Buffer
│
▼
Enhanced Model Critic
│
┌─────────────┼─────────────┐
│ │ │
▼ ▼ ▼
Q-value Reward Next-state
estimate prediction prediction
│
▼
Predicted reward
│
▼
Compare with observed reward
│
▼
Reward Prediction Error
│
▼
Replay Priority
│
▼
Prioritised Sampling
│
▼
TD3 / SAC Update
RPE-PER is built around a simple idea: not all experiences deserve equal replay attention.
Compared with conventional TD-error-based prioritisation, RPE provides several useful properties:
- Reward-grounded — priority is directly related to the discrepancy between predicted and observed reward.
- Interpretable — a large RPE means that the observed outcome was poorly predicted.
- Independent of TD error for prioritisation — replay priority does not directly rely on bootstrapped value discrepancies.
- Biologically motivated — inspired by the role of reward prediction error in learning and memory.
- Simple to integrate — the underlying TD3 and SAC objectives remain unchanged.
- Applicable across actor-critic settings — evaluated with both deterministic and stochastic off-policy algorithms.
RPE-PER is integrated with two off-policy continuous-control algorithms:
- TD3 — Twin Delayed Deep Deterministic Policy Gradient
- SAC — Soft Actor-Critic
This allows RPE-based replay to be evaluated under both deterministic and stochastic policy-learning settings.
RPE-PER is evaluated on six continuous-control environments from the MuJoCo benchmark suite:
Ant-v4HalfCheetah-v4Hopper-v4Humanoid-v4Swimmer-v4Walker2d-v4
The method is compared against several replay strategies:
- Uniform Replay
- PER — Prioritised Experience Replay
- LAP — Loss-Adjusted Prioritisation
- LA3P — Loss-Adjusted Approximate Actor Prioritised Experience Replay
- MaPER — Model-Augmented Prioritised Experience Replay
Experiments are conducted with both TD3 and SAC to evaluate RPE-based prioritisation across deterministic and stochastic policy-learning settings.
Across the evaluated tasks, RPE-PER demonstrates strong overall performance with both algorithms, with particularly consistent improvements in the TD3 experiments.
| Library | Version |
|---|---|
pydantic |
1.10.10 |
MuJoCo |
2.3.3 |
Clone the repository and install the required dependencies before running the experiments.
python3 training_loop_TD3.pypython3 training_loop_SAC.pyReplay the experiences that violate the agent's reward expectations.
If an outcome is already well predicted, its RPE is small and it receives lower replay priority.
If the observed reward differs substantially from what the agent expected, its RPE is large and the experience is replayed more frequently.
Reward Prediction Error Prioritisation in Experience Replay: The RPE-PER Method Hoda Yamani, Yuning Xing, Lee Violet C. Ong, Bruce A. MacDonald, and Henry Williams
Published in the The Australasian Conference on Robotics and Automation (ACRA 2024), Auckland, New Zealand.
Paper: ACRA 2024 Proceedings arXiv: arXiv:2501.18093
If you use RPE-PER or this repository in your research, please cite:
@inproceedings{yamani2024reward,
title = {Reward Prediction Error Prioritisation in Experience Replay: The RPE-PER Method},
author = {Yamani, Hoda and Xing, Yuning and Ong, Lee Violet C. and MacDonald, Bruce A. and Williams, Henry},
booktitle = {Proceedings of the Australasian Conference on Robotics and Automation (ACRA 2024)},
pages = {154--163},
year = {2024},
address = {Auckland, New Zealand},
publisher = {Australian Robotics and Automation Association}
}
