Course contentsShow
← Machine Learning and Deep Learning
Lesson 2246 of 3,53848. Deep Reinforcement Learning: Value-BasedFree lesson

State Preprocessing for Atari

Implement frame stacking, grayscale conversion, and resizing to create appropriate state representations for visual inputs.

State Preprocessing for Atari

What you'll learn: How to transform raw Atari game frames into efficient, learnable state representations through stacking, grayscaling, and resizing.

Why Preprocess Atari Frames?

Raw Atari frames are 210×160 RGB images—large, redundant, and computationally expensive. Training a DQN directly on these would be slow and inefficient. More critically, a single frame doesn't capture motion or velocity information (is the ball moving left or right?). Preprocessing solves both problems.

The Three Core Transformations

Grayscale Conversion

Convert RGB (3 channels) to single-channel grayscale. Most Atari games don't rely on color for gameplay decisions, so this reduces input dimensionality by 3× without losing critical information.

Resizing

Downscale frames from 210×160 to 84×84 pixels. This smaller resolution preserves spatial relationships while drastically reducing the number of pixels the network must process (from ~100K to ~7K per frame).

Frame Stacking

Stack the last 4 consecutive frames into a single state representation. This creates a "motion history" that lets the network infer velocity and direction. Think of it like flip-book animation: one picture shows a static scene, but four consecutive pictures reveal movement.

The Pipeline

Each observation goes through: Raw frame → Grayscale → Resize → Stack with 3 previous frames → Feed to DQN

The result is a 4×84×84 tensor: four grayscale frames of 84×84 pixels each. This compact representation gives the network both spatial awareness and temporal dynamics.

Practical Impact

Without preprocessing, DQNs struggle to learn even simple Atari games. With it, the same architecture achieves human-level performance across dozens of games—all because the state representation became learnable.

Key Takeaway: State preprocessing transforms unwieldy visual inputs into compact, informative representations by converting to grayscale, resizing to 84×84, and stacking 4 frames to capture motion—essential for DQN success on Atari games.