spd_learn.models.AttentionManifold#

class spd_learn.models.AttentionManifold(in_features, out_features)[source]#

Bases: Module

Manifold Attention Module.

This module implements an attention mechanism over a sequence of SPD matrices, where the operations are performed on the SPD manifold using the Log-Euclidean metric [Pan et al., 2022].

Parameters:
  • in_features (int) – Dimensionality of input SPD matrices.

  • out_features (int) – Dimensionality of the output features after mapping.

forward(x)[source]#

Forward pass of the manifold attention module.

Parameters:

x (torch.Tensor) – Input tensor with shape (batch, num_patch, …) where … represents the dimensions of the SPD matrices.

Returns:

Output tensor of shape (-1, out_features, out_features).

Return type:

torch.Tensor