Switching Linear Dynamics for Variational Bayes Filtering

Philip Becker-Ehmck, Jan Peters, Patrick van der Smagt

Introduction

Modeling the dynamics of complex, nonlinear systems—such as a robot arm or multiple bouncing balls—is a cornerstone of model-based reinforcement learning and control. While deep neural networks are powerful function approximators, they often act as "black boxes" that struggle to generalize or provide insight into the underlying physics. Standard recurrent models don't explicitly represent the "modes" of a system (e.g., "moving freely" vs. "colliding with a wall"), and many existing Variational Autoencoder (VAE)-based dynamics models treat the transition between states deterministically.

This paper introduces a method to model these complex systems by combining Switching Linear Dynamical Systems (SLDS) with Variational Autoencoders (VAEs). By using a stochastic approach to infer discrete "switching" variables, the model learns a highly interpretable latent space that explicitly captures physical constraints, leading to significantly more accurate long-term trajectory predictions.

Proposed Method: SLDS meets VAEs

The authors propose a recurrent VAE framework that incorporates the structure of an SLDS to better capture distinct physical regimes.

Generative Model Comparison
  • The Generative Model: Instead of one giant nonlinear transition function, the model maintains a set of $M$ linear dynamical systems. At each time step, a discrete switching variable ($s_t$) chooses which linear system to apply to the continuous latent state ($z_t$).
  • Concrete Relaxations: Since discrete variables are notoriously hard to optimize via backpropagation, the authors use the Concrete distribution (also known as Gumbel-Softmax) to create a continuous, differentiable approximation of the switching variables.
  • Hierarchical Reinterpretation: They also explore a version where the switching variables are normally distributed rather than discrete, allowing the model to "blend" linear systems more fluidly.

Structured Inference

The inference network is carefully designed to mimic a Bayesian update.

Inference Model Overview

It combines a "transition model" (the prior prediction of the next state) with an "inverse measurement model" (information from the current observation) to produce the posterior latent state. This ensures that the gradient of the reconstruction loss flows directly through the dynamics model, forcing it to learn robust transition dynamics.

Experimental Validation

The model was evaluated on several physics-based simulations, including a 3-Ball Maze (Box2D), the Roboschool Reacher robotic arm, a bouncing Ball in a Box (image data), and the FitzHugh-Nagumo (FHN) nonlinear oscillator.

Key Insights

  • Switching Variables as Semantic Features: The most striking finding is that the switching variables $s_t$ naturally align with physical events. In the maze task, specific switching variables "turned on" only when an agent hit a horizontal wall, while others activated for vertical walls.
  • Stochasticity is Vital: Moving from a deterministic transition (like in previous "Deep Kalman Filter" variants) to a stochastic one significantly improved the richness of the learned latent space.
  • The "Normal" Advantage: Interestingly, modeling switching variables as continuous Gaussian variables often outperformed the discrete Concrete distribution, particularly when the time-step discretization ($\Delta t$) was large. This suggests that "blending" linear regimes is often more robust than "switching" between them in discretized time.

Performance Highlights

  • State Recovery: In the maze task, the model recovered unobserved velocities from position data with an $R^2$ score of 0.92.
  • Collision Detection: A simple classifier trained on the learned switching variables could predict wall collisions with an F1 score of 0.46 (significant given that low-velocity "grazing" is nearly indistinguishable from no collision).
  • Prediction Accuracy: The proposed model consistently achieved lower Mean Squared Error (MSE) for future state prediction compared to baselines like LSTMs, the Kalman VAE (KVAE), and Deep Variational Bayes Filters (DVBF). For example, in the 3-Ball Maze (10 steps ahead), the "Normal" variant achieved an MSE of 1.38E-02, compared to 1.82E-01 for standard DVBF.

Limitations and Future Work

While the model learns meaningful features, "disentangling" these latent spaces—ensuring that one variable only represents velocity and another only represents collisions—remains an open challenge. Furthermore, the discrete (Concrete) version of the model is highly sensitive to the choice of $\Delta t$; if time steps are too large, the "hard" switching of the SLDS fails to capture the dynamics accurately. The authors suggest that applying this framework to real-world robotic hardware for model-based control is the next logical step.

Summary updated

BibTeX
@inproceedings{beckerehmck2019switching,
  author = {Philip Becker-Ehmck and Jan Peters and Patrick van der Smagt},
  title = {{Switching Linear Dynamics for Variational Bayes Filtering}},
  booktitle = {International Conference on Machine Learning},
  year = {2019},
  url = {https://openreview.net/forum?id=r14rY3ZOWS},
}
Figure