Learnable-DeepKoopFormer Makes Transformer Forecasting Stable and Mathematically Interpretable
A new family of learnable Koopman operators plugs into PatchTST, Autoformer, and Informer to give transformer forecasters spectrally stable, interpretable latent dynamics.
ProTakeaways
- New framework adds learnable Koopman operators with spectral control to PatchTST, Autoformer, and Informer backbones.
- Four operator variants (scalar-gated, per-mode gated, MLP-shaped, low-rank) interpolate between strict stability and full expressiveness.
- Orthogonal-diagonal-orthogonal factorization plus Lyapunov regularization guarantees contractive, invertible latent dynamics.
- Evaluated on CMIP6 wind, ERA5, pressure surface, cryptocurrency, and energy datasets against LSTM, DLinear, and SSM baselines.
- Constrained Koopman variants give the tightest error distributions; learned eigenvalues sit in a stable 0.3-0.8 range.
- Code available at GitHub with full PyTorch implementation and benchmark pipeline.
Transformer forecasters have gotten frighteningly good, but they still behave like black boxes: nobody quite knows what the latent state is doing between the encoder and the output head, and long-horizon rollouts can drift in ways that are hard to diagnose. A new paper on Learnable-DeepKoopFormer tries to fix that by dropping a small, mathematically constrained linear layer, a learnable Koopman operator, into the middle of standard transformer backbones and letting you shape its spectrum directly.
The result is a family of models where the latent dynamics are provably stable, invertible, and interpretable through classical eigenvalue analysis, while the outer transformer keeps doing what transformers are good at.
Why linear algebra keeps sneaking back into forecasting
Koopman theory is a trick from dynamical systems: instead of modeling a nonlinear system directly, you lift it into a space of observables where its evolution becomes linear. Formally, it is an infinite-dimensional linear operator acting on functions of the state, enabling the use of linear spectral tools in settings that may be nonlinear, nonstationary, or even chaotic. In deep learning, this usually means an encoder maps your input window into a latent vector, a linear operator advances it one step, and a decoder produces the forecast.
The problem the authors flag is that existing Koopman-neural models typically combine nonlinear feature encoders with a latent linear operator, but the operator itself is usually learned without explicit spectral parameterization: it is fitted as an unconstrained linear layer or least-squares estimator, providing no mechanism to shape contraction, oscillation, or multi-scale temporal behavior. You get the linearity, but none of the guarantees. Meanwhile, popular transformer forecasters like PatchTST, Autoformer, and Informer rarely use Koopman structure at all, so they inherit no dynamical interpretability.
Four ways to shape a spectrum
The core idea is to parameterize the Koopman operator through an orthogonal-diagonal-orthogonal (ODO) factorization: K = U diag(Sigma) V^T, where U and V have orthonormal columns and all the expressiveness lives in the diagonal spectrum Sigma. A squashing function forces each spectral coefficient to stay strictly below some radius rho_max less than 1, which mathematically guarantees the latent dynamics contract rather than blow up.
Within that skeleton, the paper introduces four ways to generate the spectrum:
- Scalar-gated: two global trainable parameters shift and scale the entire spectrum, giving you tunable damping.
- Per-mode gated: each latent direction gets its own gate, so different modes can decay or oscillate at different rates.
- MLP-shaped spectral mapping: a small neural network reshapes raw spectral parameters before squashing them, allowing flexible nonlinear spectra.
- Low-rank Koopman: the operator is restricted to rank r much smaller than d, capturing dominant modes while cutting parameters.
These operators sit between two extremes: a strictly stable constrained Koopman and a fully free dense matrix with no guarantees. Training combines standard mean squared error with a Lyapunov-style penalty that punishes the latent energy from growing step to step, biasing the model toward genuinely contractive dynamics rather than just numerically low loss.
Where it plugs in
The framework is backbone-agnostic. The authors embed the Koopman layer into PatchTST, Autoformer, and Informer, giving a full family of DeepKoopFormer models. The encoder produces a latent vector, the Koopman operator advances it once, and a linear decoder emits the entire H-step forecast in a single forward pass, no autoregressive rollout needed.
Theoretically, the paper walks through the guarantees this buys you: the spectral radius stays bounded, iterates contract exponentially, the operator is invertible when the spectrum is kept away from zero, and satisfying the Lyapunov penalty implies a discrete Lyapunov certificate of stability. There's even a small theorem showing that unconstrained state-space models can achieve the same finite-horizon loss with arbitrarily unstable transition matrices, which is exactly the pathology spectral control is designed to prevent.
How it actually performs
The benchmark is unusually broad. The authors evaluate across five datasets spanning distinct dynamical regimes: CMIP6 climate projections and ERA5 reanalysis data focusing on wind speed and surface pressure forecasting over Germany, a financial time series dataset for cryptocurrency market analysis, and an electricity generation dataset for modeling energy supply dynamics. They sweep patch lengths in {80, 100, 120, 140} and horizons in {4, 8, 12, 16}, comparing against LSTM, DLinear, and diagonal state-space model baselines alongside the Koopman variants.

The consistent story across datasets: Koopman-enhanced transformers produce tightly concentrated, low error distributions, while recurrent and linear baselines show visibly broader spread and more sensitivity to configuration. The constrained variant tends to have the most compact violins, and the learnable variants trade a bit of spread for expressiveness. Unconstrained operators sometimes match median accuracy but have heavier tails, which is exactly what the theory predicts.
The energy systems dataset is a nice stress test. Autoformer performs poorly there, and LSTM overfits, showing low training error but wide test spread. Koopman variants, especially the constrained one, maintain reliable mid-centered violins, prioritizing stable generalization over lucky configurations.
Reading the spectra

Because the Koopman layer is explicit, you can just look at where its eigenvalues land. Across every dataset, constrained variants populate a mid-range band between roughly 0.3 and 0.8, safely below the unit circle. Learnable variants occupy a similar range with slightly wider support. Unconstrained variants collapse toward the origin, producing over-damped dynamics that lose information. The SSM baseline mostly sits near zero but has a thin tail extending past 1, meaning occasional genuinely unstable modes, the failure mode the theory warned about.
The authors argue this is the real payoff of learnability: eigenvalues that neither collapse to zero (degenerate) nor exceed 1 (unstable) give you invertible, non-degenerate latent dynamics with enough variability to capture both fast and slow modes.
Getting your hands on it
Code and datasets are available. The framework is accessible at Github and Zenodo. The entire implementation is written in Python and builds upon standard scientific computing libraries, including PyTorch, NumPy, and SciPy. The repository lives at Ali-Forootani/Learnable-DeepKoopFormer.
The honest limitations: this is a benchmark paper, not a leaderboard-topping SOTA claim. On some individual test configurations, DLinear or SSM edge out the Koopman variants on mean error, but with much wider spread. If your application cares about long-horizon stability, interpretability of latent dynamics, or provable contraction, the Koopman layer is a small, principled addition to an existing backbone. If you just want the lowest possible MSE on a specific horizon, a tuned linear model may still win.