Skip to content

Frozen Vision Encoders for Deep RL in VizDoom

Trained agent (500k steps). Return: 5.
Best recorded episode. Return: 9.

Overview

This project trains a Double DQN agent to play first-person shooter scenarios in VizDoom, an RL research platform built on the Doom engine. The agent observes raw RGB frames, encodes them with a frozen pretrained vision transformer, and learns Q-values over a small discrete action space.

The design rests on one idea: the agent should not have to learn to see and to act at once. Large self-supervised vision models (AIMv2, V-JEPA 2) already turn raw pixels into good features. Freeze one, train a small MLP Q-network on top, and training comes out fast, stable, and light on memory.

Key Findings

Encoder Comparison: AIMv2 vs V-JEPA 2

AIMv2-Large beats V-JEPA 2-Large outright, and neither V-JEPA 2 pooling variant ever leaves zero return. The mean-pool run crashed at 83k steps with Q-values already running away (mean above 60, max above 400). The last-pool run survived all 500k steps and diverged completely: mean Q past 3,000, max past 6,000, returns drifting below zero. The likely cause is the frame rate. V-JEPA 2 was pretrained on video; with frame skip 4, the eight-frame clips it sees here have frames far apart in time, and the smooth motion it expects is gone.

Mean evaluation return: AIMv2 climbs to about 6 while both V-JEPA 2 pooling variants stay at zero
Mean evaluation return on DefendTheCenter. AIMv2 climbs to ~6; both V-JEPA 2 pooling variants stay at zero — the mean-pool run crashed at 83k steps, the last-pool run completed 500k with Q-values diverging past 3,000.

Vision Encoders

The code supports two pretrained encoders:

EncoderSourceInputPatch tokensHidden dim
AIMv2-LargeAppleSingle 224x224 image256 spatial1024
V-JEPA 2-LargeMeta8-frame 256x256 clipSpatiotemporal1024

Both come from HuggingFace Transformers and stay frozen throughout. AIMv2 encodes each frame on its own. V-JEPA 2 reads a sliding window of the last 8 frames; the pipeline averages its spatiotemporal patch tokens over time, then over space, leaving one 1024-dimensional vector per observation.

Feature Pipeline

Raw encoder outputs are 1024-dimensional and unwhitened. Before training, a calibration phase collects observations from a random policy, encodes them in batches, and fits a PCA whitening transform: 1024 dimensions down to d=256d = 256, decorrelated, variance normalized. The whitened features then pass through LayerNorm and L2 normalization, and the replay buffer stores the result — 256-dimensional unit vectors.

Q-Network

The Q-network is a 2-layer MLP with hidden size 256, one output per action. An optional dueling variant splits state value from action advantage:

Q(s,a)=V(s)+A(s,a)1AaA(s,a)Q(s, a) = V(s) + A(s, a) - \frac{1}{|\mathcal{A}|}\sum_{a'} A(s, a')

Training

The agent uses Double DQN: the online network picks the action, the target network scores it. After each gradient step, Polyak averaging nudges the target network toward the online one (θτθ+(1τ)θ\theta^- \leftarrow \tau \, \theta + (1 - \tau) \, \theta^-). Epsilon-greedy exploration, annealed linearly, fills a replay buffer of 100k transitions.

Environment

Training uses VizDoom's DefendTheCenter scenario through a Gymnasium wrapper: the agent stands at the center of a circular room, ammunition limited, and shoots enemies as they close in.

VizDoom DefendTheCenter scenario screenshot
The DefendTheCenter scenario.

Results

All experiments use DefendTheCenter with frame skip 4, a 100k-transition replay buffer, batch size 256, and 500k training steps. Evaluation runs 20 greedy episodes every 5k steps.


Training Curves

Evaluation return over 500k training steps on DefendTheCenter with AIMv2-Large encoder, two seeds
The best configuration (AIMv2-Large, τ = 0.001), two seeds. Line: mean return over 20 greedy evaluation episodes; band: ±1σ across those episodes.

Ablation: Target Update Rate

Slower target updates (τ=0.001\tau = 0.001) give slightly higher, steadier evaluation returns than the default (τ=0.005\tau = 0.005).

Evaluation return comparison between tau=0.005 and tau=0.001
Target update rate ablation (AIMv2, seed 1). τ = 0.001 ends slightly higher — 6.5 vs 6.1 over the last ten evaluations — and holds its peak mean Q at 8 where the baseline reaches 23.

Standard vs Dueling Q-Network

The dueling runs never reached 500k steps — they crashed at 66k and 178k. Up to those points the standard Q-network with τ=0.005\tau = 0.005 stayed ahead of both dueling variants (4.9 vs 3.9 at 178k) — though the dueling curves were still rising when they stopped.

Mean evaluation return for standard vs dueling Q-networks; dueling runs crashed at 66k and 178k steps
Standard vs dueling Q-network, mean evaluation return. The ×s mark where the dueling runs crashed. The standard network led at both crash points, but neither dueling curve had converged.

Hyperparameters

ParameterValue
EncoderAIMv2-Large
Feature dim (after PCA)256
Q-network hidden size256
Q-network layers2
Learning rate1×1041 \times 10^{-4}
Discount γ\gamma0.99
Replay capacity100,000
Batch size256
Target update τ\tau0.001
ϵ\epsilon schedule1.0 \to 0.05 over 50k steps
Warmup steps1,000
PCA calibration steps2,000
Frame skip4
Total training steps500,000