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.

Quickstart

pip install spd_learn
import torch
from spd_learn.models import SPDNet

# Create SPDNet for 22-channel EEG, 4 classes
model = SPDNet(n_chans=22, n_outputs=4)

# Input: (batch, channels, time)
X = torch.randn(32, 22, 500)
output = model(X)  # (32, 4)

Works with Python 3.11+ and PyTorch 2.0+

Why SPD Learn?

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

Pure PyTorch

Built entirely on PyTorch, with automatic differentiation, and GPU acceleration.

API Reference

Riemannian Geometry

Efficient exponential maps, logarithms, parallel transport, and geodesic distance computations on SPD manifolds.

Applied Examples

Model Zoo

Implementations of SPDNet, TensorCSPNet, EEGSPDNet, TSMNet, and more state-of-the-art architectures.

API Reference

Model Architectures

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

SPDNet
SPDNet Architecture

The cornerstone architecture for deep learning on non-Euclidean geometry of SPD manifolds. Performs dimension reduction while preserving the SPD structure.

AAAI 2017 BiMap ReEig LogEig
spd_learn.models.SPDNet
TensorCSPNet
TensorCSPNet Architecture

Filterbank SPDNet with Tensor Common Spatial Patterns for multi-band EEG feature extraction.

IEEE TNNLS 2022 Multi-band CSP BiMap
spd_learn.models.TensorCSPNet
TSMNet
TSMNet Architecture

Tangent Space Mapping Network (TSMNet) combining convolutional features with SPD batch normalization.

NeurIPS 2022 BatchNorm LogEig Transfer
spd_learn.models.TSMNet
MAtt
MAtt Architecture

Manifold Attention Network that applies attention mechanisms directly on the SPD manifold using Log-Euclidean distances for temporal weighting.

NeurIPS 2022 Attention LogEuclidean TraceNorm
spd_learn.models.MAtt
PhaseSPDNet
PhaseSPDNet Architecture

Phase-based SPDNet that leverages phase information from the signals.

J. Neural Eng. 2024 Phase Dynamic System BiMap
spd_learn.models.PhaseSPDNet
EEGSPDNet
EEGSPDNet Architecture

Specialized for EEG signal classification. Combines convolutional with covariance SPD network layers for Brain-Computer Interface applications.

Imaging Neuroscience 2025 Covariance BiMap ReEig
spd_learn.models.EEGSPDNet
Green
Green Architecture

Gabor Riemann EEGNet combining Gabor wavelets with Riemannian geometry for interpretable EEG decoding.

Patterns 2025 Gabor Wavelet Shrinkage
spd_learn.models.Green

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, with many tutorials provided.

Batch Normalization

SPD-specific batch normalization layers that respect the Riemannian geometry, enabling stable training of deep SPD networks.

Open Source

BSD-3-Clause licensed, for friendly for commercially applications, with actively maintained by experts from the field, and welcoming contributions.


Getting Started

Get up and running with SPD Learn in three steps.

Step 1 of 3

Install the library

Add SPD Learn to your Python environment with pip or from source.

pip install spd_learn

For development, clone the repo and install in editable mode:

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

Create your SPD model

Define an SPDNet with BiMap and ReEig layers in a few lines of code.

from spd_learn.models import SPDNet

model = SPDNet(
    n_chans=22,  # EEG channels
    n_outputs=4,  # Number of classes
    subspacedim=16,  # SPD subspace dimension
)

The model handles covariance computation, SPD projection, and classification end-to-end.

Step 3 of 3

Train with PyTorch

Use standard PyTorch training loops — no special APIs required.

optimizer = torch.optim.Adam(model.parameters(), lr=1e-3)
criterion = torch.nn.CrossEntropyLoss()

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

SPD Learn integrates with scikit-learn pipelines via skorch wrappers.


Ecosystem Integration

Works seamlessly with your favorite tools.

Python 3.11+

PyTorch

PyTorch

scikit-learn

scikit-learn

pyRiemann


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 Inria
CNRS CNRS
CEA CEA
Université Paris-Saclay Université Paris-Saclay
ATR ATR
UC San Diego UC San Diego
Yneuro Yneuro
Université Savoie Mont Blanc Université Savoie Mont Blanc

Citation

If you use SPD Learn in your research, please cite us.

Aristimunha, B., Ju, C., Collas, A., Bouchard, F., Mian, A., Thirion, B., Chevallier, S., & Kobler, R. (2026). SPDlearn: A geometric deep learning Python library for neural decoding through trivialization. To be submitted. https://github.com/spdlearn/spd_learn
@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 Mian, Ammar and Thirion, Bertrand and Chevallier, Sylvain and Kobler, Reinmar},
  journal = {to be submitted},
  year = {2026},
  url = {https://github.com/spdlearn/spd_learn}
}