🧠Algorithm Families
Overview
Algorithm classes implement RL algorithms: network architecture, action selection, and gradient updates. SLM Lab's algorithms use a taxonomy-based inheritance design where each algorithm extends its parent by adding only its distinguishing features.
Code: slm_lab/agent/algorithm
Algorithm Taxonomy
Algorithm (base class)
├── SARSA (tabular-like Q-learning)
│ └── VanillaDQN → DQNBase → DQN → DoubleDQN
└── Reinforce (policy gradient)
└── ActorCritic (adds value function, GAE/n-step)
├── PPO (adds clipped objective)
└── SoftActorCritic (adds entropy regularization)
└── CrossQ (eliminates target networks via cross batch norm)Each level adds only its distinguishing features. For example, PPO inherits everything from ActorCritic and only overrides the policy loss calculation. Note: ActorCritic is A2C—there's no separate A2C class.
See Class Inheritance: A2C > PPO for a detailed example.
Implemented Algorithms
SARSA
Value-based
Discrete
On-policy TD learning
VanillaDQN
Value-based
Discrete
Basic Q-learning with neural network
DQN
Value-based
Discrete
+ Target network
DoubleDQN
Value-based
Discrete
+ Double Q-learning
REINFORCE
Policy gradient
Both
Monte Carlo policy gradient
ActorCritic
Actor-Critic
Both
Separate actor and critic
A2C
Actor-Critic
Both
+ Synchronized updates
PPO
Actor-Critic
Both
+ Clipped surrogate objective
SAC
Actor-Critic
Both
+ Maximum entropy RL, auto-tuned temperature
CrossQ
Actor-Critic
Both
+ No target networks, cross batch norm
Algorithm Interface
All algorithms implement this interface:
Algorithm Spec
Configure algorithms in the agent spec:
Key Parameters
Common Parameters
gamma
Discount factor (how much to value future rewards)
0.99 (long-horizon), 0.9 (short-horizon)
action_pdtype
Probability distribution for actions
"default" (auto-select), "Categorical", "Normal"
action_policy
How to select actions
"default", "epsilon_greedy", "boltzmann"
Policy Gradient Parameters (A2C, PPO)
lam
GAE lambda (bias-variance tradeoff)
0.95 (balanced), 0.99 (high variance), 0.7 (low variance)
entropy_coef_spec
Entropy bonus for exploration
0.01 (typical), 0.001 (less exploration)
val_loss_coef
Value loss weight
1.0 (default)
PPO-Specific Parameters
time_horizon
Steps collected before each update
128 (typical), 2048 (MuJoCo)
minibatch_size
Samples per gradient step
64-256
training_epoch
Passes through collected data
4-10
clip_eps_spec
Clipping parameter
0.1-0.2
DQN-Specific Parameters
explore_var_spec
Epsilon schedule
Start 1.0, end 0.01
training_frequency
Steps between updates
1-4
training_start_step
Steps before training starts
1000-10000
Exploration Schedules
Many parameters use schedules for decay during training:
Available schedules:
"no_decay"- Constant value"linear_decay"- Linear interpolation"rate_decay"- Exponential decay
Example Specs
PPO for CartPole (Discrete)
DQN for LunarLander (Discrete)
SAC for MuJoCo (Continuous)
Adding a New Algorithm
Create
slm_lab/agent/algorithm/your_algo.pyInherit from the appropriate base class
Override only the methods that differ
Register in
slm_lab/agent/algorithm/__init__.py
Example: Custom DQN Variant
See Architecture for more on extending SLM Lab.
Algorithm Performance Notes
Based on v5 benchmark results, here's guidance on algorithm selection:
Recommended by Environment
Classic Control
PPO, SAC
Fast convergence, reliable
Box2D Discrete
DDQN+PER
Better than DQN, PPO close second
Box2D Continuous
SAC, CrossQ
SAC reliable, CrossQ 2–7x faster
MuJoCo
PPO, SAC, CrossQ
All validated on 11 envs; CrossQ fastest
Atari
PPO
Validated on 57 games; SAC on 48 games
Known Limitations
These algorithm-environment combinations underperform:
DQN
CartPole
Slow convergence (188 vs 499 PPO)
Use DDQN+PER or PPO
A2C
LunarLander
Fails discrete (9.5) and continuous (-38)
Use PPO or SAC
A2C
Pendulum
Poor performance (-553 vs -168 PPO)
Use PPO or SAC
CrossQ
Atari
Experimental; underperforms SAC/PPO on most games
Use PPO or SAC
Lambda Tuning for Atari
Different games benefit from different GAE lambda values:
0.95
Strategic games
Qbert, BeamRider, Seaquest
0.85
Mixed games
Pong, MsPacman, Enduro
0.70
Action games
Breakout, KungFuMaster
See Atari Benchmark for per-game results.
Learning Resources
For deep dives into these algorithms:
Deep RL Resources - Recommended papers and courses
Foundations of Deep RL - The companion book
Algorithm Taxonomy - Visual overview
Last updated
Was this helpful?