SPD Learn: A Geometric Deep Learning Python Library for Neural Decoding Through Trivialization

Bruno Aristimunha, Ce Ju, Antoine Collas, Florent Bouchard, Ammar Mian, Bertrand Thirion, Sylvain Chevallier, Andreas Schwarz

Abstract

Implementations of symmetric positive definite (SPD) matrix-based neural networks for neural decoding remain fragmented across research codebases and Python packages. Existing implementations often employ ad hoc handling of manifold constraints and non-unified training setups, which hinders reproducibility and integration into modern deep-learning workflows. To address this gap, we introduce SPD Learn, a unified and modular Python package for geometric deep learning with SPD matrices. SPD Learn provides core SPD operators and neural-network layers, including numerically stable spectral operators, and enforces Stiefel/SPD constraints via trivialization-based parameterizations. This design enables standard backpropagation and optimization in unconstrained Euclidean spaces while producing manifold-constrained parameters by construction. The package also offers reference implementations of representative SPDNet-based models and interfaces with widely used brain computer interface/neuroimaging toolkits and modern machine-learning libraries (e.g., MOABB, Braindecode, Nilearn, and SKADA), facilitating reproducible benchmarking and practical deployment.

Introduction

In fields such as brain-computer interfacing (BCI) and neuroimaging, data is frequently represented as covariance matrices. These matrices are Symmetric Positive Definite (SPD), meaning they reside on a curved mathematical "manifold" rather than a flat Euclidean space. Standard neural networks are ill-equipped for this geometry; a simple gradient update on an SPD matrix can result in a matrix that is no longer positive definite, effectively breaking the model.

Historically, researchers addressed this by using specialized Riemannian optimizers or fragmented, ad-hoc codebases. This fragmentation has significantly hindered reproducibility and complicated the integration of geometric deep learning into modern pipelines like PyTorch. SPDLearn addresses these challenges by providing a modular Python library that brings geometric deep learning into the mainstream.

Trivialization-Based Parameterization

The core innovation of SPDLearn is its systematic use of trivialization-based parameterizations. Rather than optimizing directly on a constrained manifold—a mathematically intensive process—the library constructs a smooth mapping ($\Phi$) from an unconstrained Euclidean space to the target manifold (e.g., the Stiefel manifold for orthogonal weights or the SPD manifold for covariance-like parameters).

This approach offers several key advantages:

  1. Standard Optimization: Researchers can utilize standard backpropagation and popular optimizers like Adam or SGD. The "trivialization" mapping ensures that parameters remain valid and constrained to the manifold by construction.
  2. Numerical Stability: The library implements custom forward and backward passes for spectral operators, such as matrix logarithms and powers. By employing the Loewner matrix formulation, SPDLearn ensures gradient stability even when eigenvalues are nearly identical—a frequent failure point in matrix-based deep learning.
  3. Modular Architecture: The library is organized into three layers: functional for low-level mathematics, module for reusable network layers (e.g., BiMap, SPDBatchNorm), and model for ready-to-use reference architectures.

A Unified Ecosystem for Neural Decoding

Before SPDLearn, models like TSMNet and Tensor-CSPNet existed in separate, often incompatible codebases. SPDLearn provides a unified platform for these models, enabling the first true "apples-to-apples" comparisons in the field.

Figure 1: Evolution and citation map of SPD-based neural decoding models.

The library includes reference implementations for several state-of-the-art neural decoding models, summarized in the table below:

Figure 3: Summary of neural decoding models implemented in SPDLearn.

To facilitate practical deployment, SPDLearn interfaces directly with "gold standard" datasets and toolkits, including:

  • MOABB: The Mother of All BCI Benchmarks for standard EEG datasets.
  • Braindecode: A library for deep learning with EEG.
  • Nilearn: For fMRI processing and analysis.
  • SKADA: For domain adaptation tasks.

Conclusion and Future Directions

By moving the complexity of manifold constraints into the architecture itself via trivialization, SPDLearn lowers the barrier to entry for geometric deep learning, making it feel like "regular" deep learning. While currently focused on BCI and fMRI, the underlying mathematics is applicable to other domains such as radar imaging and computer vision.

Future work will focus on scaling these SPD-based models to larger neuroimaging datasets and extending the library to support diverse learning paradigms beyond standard supervised decoding. The goal remains to provide a robust, unified ecosystem that fosters reproducible research and practical innovation in neural decoding.

Summary updated

BibTeX
@misc{aristimunha2026spd,
  author = {Bruno Aristimunha and Ce Ju and Antoine Collas and Florent Bouchard and Ammar Mian and Bertrand Thirion and Sylvain Chevallier and Andreas Schwarz},
  title = {{SPD Learn: A Geometric Deep Learning Python Library for Neural Decoding Through Trivialization}},
  year = {2026},
  eprint = {2602.22895},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2602.22895},
}
Figure