spd_learn.modules.GBWPatchCovariance#

class spd_learn.modules.GBWPatchCovariance(n_patches=3, epsilon=1e-05, trace_normalize=True)[source]#

Bases: Module

Estimate chronological covariance tokens from learned time series.

See [Jin et al., 2026].

Parameters:
  • n_patches (int, default=3) – Number of chronological patches.

  • epsilon (float, default=1e-05) – Positive absolute diagonal loading after optional trace normalization.

  • trace_normalize (bool, default=True) – Normalize each covariance by its trace before diagonal loading.

Notes

Sample covariance uses divisor T-1. All samples are retained; earlier patches receive the remainder. Each patch needs at least two samples.

forward(x)[source]#

Estimate regularized covariance tokens.

Parameters:

x (torch.Tensor) – Features of shape (batch, features, time).

Returns:

SPD tokens of shape (batch, n_patches, features, features).

Return type:

torch.Tensor