Abstract
Many important tasks are defined in terms of objects. To generalize across these tasks, a reinforcement learning (RL) agent needs to exploit the structure that the objects induce. Prior work has either hard-coded object-centric features, used complex object-centric generative models, or updated state using local spatial features. However, these approaches have had limited success in enabling general RL agents. Motivated by this, we introduce Feature-Attending Recurrent Modules (FARM), an architecture for learning state representations that relies on simple, broadly applicable inductive biases for capturing spatial and temporal regularities. FARM learns a state representation that is distributed across multiple modules that each attend to spatiotemporal features with an expressive feature attention mechanism. We show that this improves an RL agent’s ability to generalize across object-centric tasks. We study task suites in both 2D and 3D environments and find that FARM better generalizes compared to competing architectures that leverage attention or multiple modules.
Introduction: The Challenge of Generalization
Generalization remains a "holy grail" in Reinforcement Learning (RL). While humans intuitively understand that a "key" functions identically in a small room or a vast mansion, RL agents often fail when task scale or complexity increases. Most current approaches attempt to capture "object-centric" structure using spatial attention—directing the agent to focus on specific $(x, y)$ coordinates. However, spatial attention can be brittle; if an object moves or the environment expands, spatial priors often collapse.
The core challenge is building an agent that captures the essence of objects and their behaviors (like motion or purpose) in a flexible way that transfers to novel scenarios.
Feature-Attending Recurrent Modules (FARM)
To address these limitations, we propose FARM, an architecture defined by three key design principles:
- Modular State: Instead of a monolithic recurrent unit, FARM employs $n$ smaller recurrent modules. This modularity encourages different units to specialize in distinct task aspects.
- Spatiotemporal Features: A recurrent encoder generates features describing not just static frames, but how elements evolve over time.
- Dynamic Feature Attention: Unlike standard spatial attention, each FARM module predicts a mask for the channels of the feature map. This allows a module to focus on a specific "type" of information (e.g., "all clockwise-moving objects") regardless of their spatial coordinates.
- Information Sharing: Modules coordinate via a transformer-style attention mechanism, allowing for the integration of specialized knowledge.
Experimental Environments
We evaluated FARM across three diverse suites designed to test specific generalization capabilities:
- Ballet (2D): Tests memory of spatiotemporal patterns. The agent must observe "dancers" (random shapes), remember their motions, and navigate to the one specified by a language instruction.
- 3D Place (Unity): Tests navigation and 3D object manipulation. In a first-person view, the agent must pick up and place objects (e.g., "place toothbrush on table") in rooms significantly larger than those seen during training.
- KeyBox (2D/3D Hybrid): Tests long-horizon reasoning and robustness to clutter. The agent must navigate a hallway, avoid distractors, and match keys to boxes over extended sequences.
Key Insights and Results
Our experiments revealed that feature attention is often superior to spatial attention for RL generalization. In the Ballet task, agents relying on spatial attention (such as RIMs or AAA) failed to generalize as the number of dancers increased. In contrast, FARM’s feature-based approach scaled effectively.
FARM consistently outperformed standard LSTMs and state-of-the-art attention-based agents in out-of-distribution tests:
- Ballet: FARM was the only architecture to maintain performance when the number of dancers doubled from training (4) to testing (8).
- 3D Place: In expanded environments with more distractors, FARM achieved a 60-80% success rate, whereas baselines struggled with the increased spatial scale.
- KeyBox: In dense settings with numerous obstacles, FARM outperformed the next best attention-based agent by approximately 20% when task length tripled.
The success of FARM stems from the synergy between modularity and feature attention. Multiple modules allow the agent to decouple regularities—such as "obstacle avoidance" versus "goal tracking"—making it easier to recombine these skills in novel, longer-horizon tasks.
Conclusion and Future Directions
FARM demonstrates that distributed, feature-attending representations provide a robust path toward generalizable RL. While FARM handles longer tasks better than LSTMs, future work could integrate it with Transformers to extend the temporal horizon further. Additionally, exploring "spatially invariant" feature attention could further enhance the agent's ability to ignore absolute positions in favor of pure object properties.
Summary updated