Memory Lens: How Much Memory Does an Agent Use?

Christoph Dann, Katja Hofmann, Sebastian NowozinarXiv 2016

Abstract: We propose a new method to study the internal memory used by reinforcement learning policies. We estimate the amount of relevant past information by estimating mutual information between behavior histories and the current action of an agent. We perform this estimation in the passive setting, that is, we do not intervene but merely observe the natural behavior of the agent. Moreover, we provide a theoretical justification for our approach by showing that it yields an implementation-independent lower bound on the minimal memory capacity of any agent that implement the observed policy. We demonstrate our approach by estimating the use of memory of DQN policies on concatenated Atari frames, demonstrating sharply different use of memory across 49 games. The study of memory as information that flows from the past to the current action opens avenues to understand and improve successful reinforcement learning algorithms.

Introduction

In reinforcement learning (RL), environments are frequently partially observable (POMDPs). To navigate these effectively, agents require memory to track historical states. Common architectural solutions include stacking recent frames (as in standard DQN) or employing recurrent neural networks (LSTMs). However, a significant gap exists between the memory capacity provided to an agent and the memory it actually utilizes. Prior to this work, quantifying the active memory usage of a trained policy required intrusive analysis of its specific architecture. "Memory Lens" addresses this by providing a passive, black-box method to estimate memory complexity purely through observed behavior.

Methodology

Memory Lens treats the agent and environment as black boxes, observing trajectories of observations, actions, and rewards. The core technique involves calculating conditional mutual information metrics ($M_i$):

  • $M_0$: Mutual information between the current action and the current observation (zero memory).
  • $M_1$: Additional information about the action gained from the previous time step, given the current observation.
  • $M_i$: Generalization to $i$ steps back in time.

These metrics are computed using the Grassberger (2003) entropy estimator. To ensure statistical significance, the authors employ a permutation test. Crucially, the sum of these terms provides a formal, implementation-independent lower bound on the log-memory capacity required to reproduce the observed policy.

Experimental Setup

The method was evaluated using standard Deep Q-Networks (DQN) trained for 50 million steps on 49 classic Atari 2600 games. While the DQN architecture inherently receives a 4-frame stack (providing capacity for 4 steps of history), Memory Lens was used to determine how much of this historical data actually influenced the agents' decisions across 10,000 recorded trajectories per game.

Results and Discussion

The analysis revealed that memory utilization is highly task-dependent. Even with identical architectural capacities, agents only exploit memory when the environment's partial observability demands it.

Memory usage profiles across 49 Atari games, showing M0 (top) and additional information M1, M2, M3 (bottom rows).

As shown in the figure above, some games exhibit almost exclusive reliance on the most recent frame ($M_0$), indicating the policy is effectively Markovian. Conversely, other games show significant reliance on older frames ($M_1, M_2, M_3$), proving the agent is actively utilizing its historical buffer. This demonstrates that behavior implies complexity; one can lower-bound an agent's internal complexity without inspecting neural weights.

Limitations and Future Work

Currently, Memory Lens assumes discrete observation and action spaces. Extending this to continuous, high-dimensional spaces remains a computational challenge due to the difficulty of estimating mutual information in those domains. Future research may explore variational information maximization or active observation—where the environment is manipulated to trigger maximum memory usage—to further refine these complexity metrics. Additionally, these memory estimates could serve as an empirical measure of the inherent difficulty of sequential decision-making tasks.

Summary updated

BibTeX
@misc{dann2016memory,
  author = {Christoph Dann and Katja Hofmann and Sebastian Nowozin},
  title = {{Memory Lens: How Much Memory Does an Agent Use?}},
  year = {2016},
  eprint = {1611.06928},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/1611.06928},
}
Figure