Skip to main content

Deep Riemannian Learning for Symmetric Positive Definite matrices

Project description

SPD Learn Logo

Deep Learning on Symmetric Positive Definite Matrices

SPD Learn is a pure PyTorch library for geometric deep learning on Symmetric Positive Definite (SPD) matrices.
The library provides differentiable Riemannian operations, broadcast-compatible layers, and reference implementations of published neural network architectures for SPD data.

DocsInstallExamplesAPI

Python License PyTorch GitHub Stars


Why SPD Learn?

A PyTorch library providing differentiable Riemannian operations and neural network layers for SPD matrix-valued data.

🐍 Pure PyTorch 🌐 Riemannian Geometry 📦 Model Zoo
Built entirely on PyTorch for seamless integration, automatic differentiation, and GPU acceleration out of the box. Efficient exponential maps, logarithms, parallel transport, and geodesic distance computations on SPD manifolds. Implementations of SPDNet, TensorCSPNet, EEGSPDNet, TSMNet, and more state-of-the-art architectures.

Model Architectures

State-of-the-art deep learning models for SPD matrix data.

Model Description Tags
SPDNet The foundational architecture for deep learning on SPD manifolds. Performs dimension reduction while preserving the SPD structure. BiMap ReEig LogEig
EEGSPDNet Specialized for EEG signal classification. Combines covariance estimation with SPD network layers for BCI applications. Covariance BiMap ReEig
TSMNet Tangent Space Mapping Network combining convolutional features with SPD batch normalization. BatchNorm LogEig Transfer
TensorCSPNet SPDNet variant with Tensor Common Spatial Patterns for multi-band EEG feature extraction. Multi-band CSP BiMap
PhaseSPDNet Phase-based SPDNet that leverages instantaneous phase information from analytic signals. Phase Hilbert BiMap
GREEN Gabor Riemann EEGNet combining Gabor wavelets with Riemannian geometry for robust EEG decoding. Gabor Wavelet Shrinkage

Key Features

Core components for constructing and training geometric neural networks on SPD manifolds.

  • SPD Layers — Specialized neural network layers for SPD matrices: BiMap for bilinear mappings, ReEig for eigenvalue rectification, and LogEig for tangent space projection.
  • Riemannian Operations — Complete toolkit for SPD manifold computations: exponential/logarithmic maps, geodesic distances, Log-Euclidean mean, and geodesic interpolation.
  • GPU Accelerated — Full CUDA support with efficient batched operations. Leverage PyTorch's automatic differentiation for seamless gradient computation on manifolds.
  • scikit-learn Compatible — Seamlessly integrate with scikit-learn pipelines, cross-validation, and hyperparameter tuning via skorch/Braindecode wrappers.
  • Batch Normalization — SPD-specific batch normalization layers that respect the Riemannian geometry, enabling stable training of deep SPD networks.
  • Open Source — BSD-3 licensed, actively maintained, and welcoming contributions. Comprehensive documentation and examples to get you started quickly.

Getting Started

Three simple steps to start using SPD Learn.

1. Install

pip install spd_learn

Or install from source:

git clone https://github.com/spdlearn/spd_learn
cd spd_learn && pip install -e .

Works with Python 3.11+ and PyTorch 2.0+.

2. Import & Create

from spd_learn.models import SPDNet
from spd_learn.modules import BiMap, ReEig

# Create your model
model = SPDNet(n_chans=22, n_outputs=4, subspacedim=16)

3. Train & Evaluate

import torch

# Standard PyTorch training
optimizer = torch.optim.Adam(model.parameters(), lr=1e-4)

for epoch in range(100):
    output = model(X_train)
    loss = criterion(output, y_train)
    loss.backward()
    optimizer.step()

Ecosystem Integration

Works seamlessly with your favorite tools.

  • PyTorch — Built entirely on PyTorch 2.0+
  • scikit-learn — ML pipelines and cross-validation (via skorch/Braindecode wrappers)
  • Braindecode — Deep learning for EEG
  • MOABB — EEG benchmark datasets
  • pyRiemann — Riemannian geometry for BCI

Citation

If you use SPD Learn in your research, please cite:

@article{aristimunha2025spdlearn,
  title     = {SPDlearn: A Geometric Deep Learning Python Library for Neural
               Decoding Through Trivialization},
  author    = {Aristimunha, Bruno and Ju, Ce and Collas, Antoine and
               Bouchard, Florent and Thirion, Bertrand and
               Chevallier, Sylvain and Kobler, Reinmar},
  journal   = {To be submitted},
  year      = {2026},
  url       = {https://github.com/spdlearn/spd_learn}
}

Open Source & Community Driven

SPD Learn is an open-source project contributed by researchers for researchers. Join our community and help advance deep learning on Riemannian manifolds.

Supported by

Inria     CNRS     CEA     Université Paris-Saclay     ATR     USMB


License

This project is licensed under the BSD 3-Clause License, unless the header of the code section explicitly states otherwise. See LICENSE.txt for details.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

spd_learn-0.1.0.tar.gz (106.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

spd_learn-0.1.0-py3-none-any.whl (105.5 kB view details)

Uploaded Python 3

File details

Details for the file spd_learn-0.1.0.tar.gz.

File metadata

  • Download URL: spd_learn-0.1.0.tar.gz
  • Upload date:
  • Size: 106.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.12

File hashes

Hashes for spd_learn-0.1.0.tar.gz
Algorithm Hash digest
SHA256 034afc98d1e866f0d2a296fffa096874e2abc94be3a8b7117a54e6f0d85c683d
MD5 89ef03d9d2188b5583f30c8d4c4b43fe
BLAKE2b-256 372c28126082ec390aabac525543613ca14ec9f1a9a6adc1d1341b58b6804f8c

See more details on using hashes here.

File details

Details for the file spd_learn-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: spd_learn-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 105.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.12

File hashes

Hashes for spd_learn-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 c59ff13749405f1314c0c5cc454e326d20feff085febafd29faf88d9e3316b35
MD5 8d1500c13debfe75471247c613009d4d
BLAKE2b-256 0f4bb47be6f2602e42f2f64593b9977362d0c171e54704c85cdb77caa80973da

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page