Safe Reinforcement Learning From Pixels Using a Stochastic Latent Representation

Yannick Hogewind, Thiago D. Simão, Tal Kachman, Nils Jansen

Executive Summary

Researchers have developed Safe SLAC, an algorithm that enables robots to learn complex tasks from raw pixel data while strictly adhering to safety constraints. By combining a stochastic latent variable model with a safety-focused critic and Lagrangian optimization, the approach achieves state-of-the-art performance in partially observable environments. Notably, it does so with significantly lower computational overhead than previous methods.

The Challenge of Safe RL in the Real World

Reinforcement Learning (RL) has seen massive success in simulations, but deploying it in the real world introduces two major hurdles: high-dimensional observations (like raw camera feeds) and safety.

Most "Safe RL" algorithms assume the agent has perfect information about its state (Full Observability). In reality, sensors are noisy, and a robot’s camera might not see a hazard behind it, leading to Partial Observability. Furthermore, learning directly from pixels is notoriously sample-inefficient. If an agent has to crash a thousand times to learn that "red zones are bad," the algorithm cannot be considered safe.

The authors formalize this problem as a Constrained Partially Observable Markov Decision Process (CPOMDP). The objective is to maximize rewards (e.g., reaching a goal) while ensuring the expected cost (e.g., hitting an obstacle) stays below a specific budget, all while only "seeing" the world through a limited, first-person camera lens.

Methods: Introducing Safe SLAC

The authors build upon the Stochastic Latent Actor-Critic (SLAC) framework. SLAC is powerful because it avoids learning a policy directly from high-dimensional pixels; instead, it first learns a compact, "latent" representation of the world’s dynamics.

The paper introduces Safe SLAC through three key extensions:

  1. Safety-Aware Latent Model: The world model is modified to predict not just the next image and reward, but also the probability of a safety violation (cost).
  2. The Safety Critic: In addition to the standard reward critic, the authors introduce a "Safety Critic" ($Q^c$). This network estimates the long-term discounted cost of taking a specific action in a specific latent state.
  3. Lagrangian Optimization: To balance the trade-off between reward and safety, they use a Lagrange multiplier ($\lambda$). Think of $\lambda$ as a dynamic "penalty weight." If the agent becomes too reckless and violates the cost budget, $\lambda$ increases, forcing the policy to prioritize safety over rewards. Crucially, the authors found that updating $\lambda$ based on the actual undiscounted cost incurred during training episodes was much more stable than relying on the Safety Critic's predictions, which suffered from estimation bias.

Datasets and Environments

The researchers evaluated their approach on the SafetyGym benchmark, specifically the SG6 suite.

First-person and third-person views of the SafetyGym environments.

This suite includes six distinct environments:

  • PointGoal1 & 2: A simple robot navigating to a goal.
  • CarGoal1: A more complex "car" robot reaching a goal.
  • DoggoGoal1: A quadruped robot (the most difficult to control).
  • PointPush1: The agent must push a box to a goal.
  • PointButton1: The agent must press a specific button.

In all cases, the agent only receives first-person pixel observations (what the robot sees), making these tasks significantly harder than versions using internal "sensor" data.

Key Insights

  • Latent States Outperform Truncated History: While the original SLAC paper suggested using a short history of observations for the actor, this paper found that using the inferred latent state directly led to much better performance. The latent state acts as a "memory" that filters out noise and focuses on task-relevant features.
  • Computational Efficiency: Unlike the current state-of-the-art (LAMBDA), Safe SLAC doesn't require complex Bayesian sampling or generating massive amounts of synthetic data. This makes it faster to train—taking roughly 10 hours for a million steps compared to LAMBDA's 13+ hours on the same hardware.
  • The "Pessimism" Trade-off: Many safe RL agents are overly cautious, resulting in very low rewards. Safe SLAC allows for a more nuanced balance, often reaching the allowed cost budget exactly to maximize the reward return.

Key Results

Safe SLAC matched or outperformed the state-of-the-art (LAMBDA) in most environments.

Reward and cost return curves during training.
  • Safety Adherence: In nearly all tests, Safe SLAC successfully kept the average cost below the predefined budget of 25.
  • Competitive Performance: In PointGoal2, it achieved higher rewards while remaining safe, though it required more environment steps to converge.
  • Robustness to Complexity: Even with the difficult Doggo robot, the agent learned to navigate hazards. However, the authors noted that the safety-reward trade-off here is particularly sensitive to the learning rate of the Lagrange multiplier.

Limitations and Future Work

The most significant limitation occurred in the PointPush1 environment. Because the agent's view is first-person, the box it is pushing often blocks its view of the goal. This creates a severe level of partial observability that Safe SLAC couldn't yet overcome—the agent simply didn't know where to go once it started pushing.

Future work aims to:

  • Incorporate distributed critics to better model the uncertainty of safety violations.
  • Improve the Lagrange multiplier optimization to make the algorithm less sensitive to hyperparameter tuning, particularly in high-torque environments like DoggoGoal.

Summary updated

BibTeX
@inproceedings{hogewind2023safe,
  author = {Yannick Hogewind and Thiago D. Simão and Tal Kachman and Nils Jansen},
  title = {{Safe Reinforcement Learning From Pixels Using a Stochastic Latent Representation}},
  booktitle = {International Conference on Learning Representations},
  year = {2023},
  url = {https://openreview.net/forum?id=b39dQt_uffW},
}
Figure