spd_learn.functional.bimap_transform#

spd_learn.functional.bimap_transform(X: Tensor, W: Tensor) → Tensor[source]#

Apply bilinear transformation to SPD matrices.

Computes the bilinear mapping:

\[Y = W^\top X W\]

where \(X\) is an SPD matrix and \(W\) is a (semi-)orthogonal weight matrix. When \(W\) has orthonormal columns, the transformation preserves the SPD property.

Parameters:
  • X (Tensor) – Input SPD matrices with shape (…, n, n).

  • W (Tensor) – Weight matrix with shape (…, n, k) where k <= n. Should have orthonormal columns for SPD preservation.

Returns:

Transformed SPD matrices with shape (…, k, k).

Return type:

Tensor

Notes

This operation is the core of spatial filtering methods like Common Spatial Patterns (CSP) and is used in SPD neural networks to reduce the dimensionality of covariance matrices while preserving geometric structure.

See also

bimap_increase_dim()

For dimension expansion.

BiMap

Module wrapper for this function.

Examples

>>> import torch
>>> from spd_learn.functional import bimap_transform
>>> X = torch.eye(8)  # 8x8 identity
>>> W = torch.eye(8, 4)  # Semi-orthogonal projection
>>> Y = bimap_transform(X, W)
>>> Y.shape
torch.Size([4, 4])