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.
Riemannian Geometry
Efficient exponential maps, logarithms, parallel transport, and geodesic distance computations on SPD manifolds.
Model Zoo
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.
The cornerstone architecture for deep learning on non-Euclidean geometry of SPD manifolds. Performs dimension reduction while preserving the SPD structure.
Filterbank SPDNet with Tensor Common Spatial Patterns for multi-band EEG feature extraction.
Tangent Space Mapping Network (TSMNet) combining convolutional features with SPD batch normalization.
Manifold Attention Network that applies attention mechanisms directly on the SPD manifold using Log-Euclidean distances for temporal weighting.
Phase-based SPDNet that leverages phase information from the signals.
Specialized for EEG signal classification. Combines convolutional with covariance SPD network layers for Brain-Computer Interface applications.
Gabor Riemann EEGNet combining Gabor wavelets with Riemannian geometry for interpretable EEG decoding.
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.
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 .
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.
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
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
Citation
If you use SPD Learn in your research, please cite us.
@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}
}