Latent Space Perturbations Improve Visual Generalization in Reinforcement Learning

Daniil Zelezetsky, Egor Cherepanov, Aleksandr Panov, Alexey KovalevarXiv 2026

TL;DR

Reinforcement learning (RL) agents often fall apart when the scenery changes—even if the game's rules and physics stay identical. This paper discovers why: out-of-distribution (OOD) visual shifts don't scramble an encoder's latent space into brand-new directions; they mostly just push and stretch embeddings along the existing top principal components. Armed with this insight, the authors propose Latent Space Perturbation (LSP), a lightweight trick that injects variance-scaled Gaussian noise along those dominant directions during training, boosting generalization without touching the encoder or augmenting pixels.

What Problem Does This Paper Address?

Imagine teaching a robot to navigate a room, and it masters the task—until someone swaps the wallpaper or changes the lighting. Humans barely blink at this, because the physics and goals haven't changed. Vision-based RL agents, however, often suffer a dramatic drop in performance, a failure known as poor visual generalization.

Usually, researchers tackle this by augmenting training images (cropping, color jittering) or forcing the encoder to learn invariant representations. But these approaches treat the symptom without diagnosing the disease: how do unseen visuals actually deform the encoder's latent space?

Methods

To find out, the authors first freeze a trained convolutional neural network (CNN) encoder and compare its latent representations on in-distribution training frames versus OOD evaluation frames. Using Principal Component Analysis (PCA) on the training latents, they map out the dominant directions of variation.

What they find is striking: OOD visuals don't create new, orthogonal latent dimensions. Instead, they cause mean shifts and variance changes along the same top principal components already learned during training.

This geometric insight leads directly to Latent Space Perturbation (LSP):

  • Periodically during training, compute PCA on a batch of training latents to find the top-$q$ principal directions and their variances ($\lambda_i$).
  • During each forward pass, inject Gaussian noise $\varepsilon \sim \mathcal{N}(0, I)$ into the encoder's output only along those top principal directions, scaled by their standard deviation ($\sqrt{\lambda_i}$) and a scheduled "distraction power" $p_i(t)$.
  • Crucially, the encoder architecture and pixel inputs remain untouched—only the policy head sees the perturbed latents, learning to tolerate shifts along the exact axes where OOD visuals push it.
Geometric intuition for Latent Space Perturbation

Datasets

The authors evaluate their diagnosis and method across three benchmarks:

  • LSP-Env (newly introduced): A lightweight 2D platformer diagnostic suite where the agent moves right while avoiding obstacles. It isolates three specific visual shifts while keeping task dynamics fixed: background changes (Protocol 1), agent-like distractors (Protocol 2), and agent appearance/texture changes (Protocol 3).
  • Procgen: Five procedurally generated environments (Bigfish, Dodgeball, Heist, Jumper, Plunder) testing uncontrolled visual diversity at scale.
  • RL-ViGen: Continuous-control robotic manipulation tasks (Robosuite Door and Lift) to test whether the gains transfer beyond 2D games.

Key Insights and Ideas

  • Latents are low-rank: Encoders trained in fixed visual settings concentrate their variability into a small number of leading principal components.
  • OOD shifts stay in-subspace: Across all three LSP-Env protocols, the top 10 training PCs capture 85%–96% of the mean-shift energy and over 99% of the variance-shift energy. Eval latents remain tightly aligned with the training subspace (with principal angle cosines near 1.0 for leading components).
  • Structure matters, not just noise: Injecting naive, isotropic Gaussian noise $\mathcal{N}(0, I)$ into the full latent vector actually degrades performance. The magic of LSP comes from scaling the noise by the training variance along the dominant PCA directions.
Latent Space Perturbation pipeline

Key Results

  • LSP-Env: Adding LSP to PPO improves peak average episodic return by up to 20% across the three visual shift protocols, with optimal noise strength peaking around $p_{\max} \approx 0.8\text{--}0.9$.
  • Procgen: PPO+LSP outperforms vanilla PPO on all five tasks at the end of training and shrinks the visual generalization gap across the board. It also beats the pixel-augmentation baseline RAD on 4 of 5 tasks and matches or exceeds IBAC-SNI on 4 of 5 tasks.
  • RL-ViGen (Robotics): On Robosuite Door, SAC+LSP reaches an average reward near 20 (after ~520k steps), compared to roughly 13 for vanilla SAC. On Lift, LSP substantially boosts OOD performance while vanilla SAC degrades after an early peak.
  • Overhead: LSP is lightweight, reducing throughput by only ~9% and increasing GPU memory by ~11.5% on LSP-Bench.

Limitations and Future Work

LSP's core assumption is that OOD visual shifts stay mostly within the dominant training subspace—which holds for naturalistic changes in backgrounds, lighting, and distractors. To probe the method's breaking point, the authors test extreme shifts like color inversion ($c \mapsto 255 - c$) and combined simultaneous shifts (background + distractors + appearance). These extreme perturbations do rotate the latent subspace and introduce variation outside the training basis. While LSP still outperforms vanilla SAC there, its advantage shrinks as subspace mismatch grows, marking the natural boundary of the approach.

Summary updated

BibTeX
@misc{zelezetsky2026latent,
  author = {Daniil Zelezetsky and Egor Cherepanov and Aleksandr Panov and Alexey Kovalev},
  title = {{Latent Space Perturbations Improve Visual Generalization in Reinforcement Learning}},
  year = {2026},
  eprint = {2611.40903},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2611.40903},
}
Figure