spd_learn.functional.kernel_euclid#
- spd_learn.functional.kernel_euclid(X, Y=None, *, Cref=None, reg=1e-10)[source]#
Euclidean kernel between two sets of matrices.
Euclidean kernel matrix \(\mathbf{K}\) of two sets \(\mathbf{X}\) and \(\mathbf{Y}\) of matrices in \(\mathbb{R}^{n \times m}\) at \(\mathbf{C}_\text{ref}\) is calculated with pairwise inner products:
\[\mathbf{K}_{i,j} = \text{tr}( (\mathbf{X}_i - \mathbf{C}_\text{ref})^T (\mathbf{Y}_j - \mathbf{C}_\text{ref}) )\]If \(\mathbf{C}_\text{ref}\) is None [1]:
\[\mathbf{K}_{i,j} = \text{tr}(\mathbf{X}_i^T \mathbf{Y}_j)\]- Parameters:
X (ndarray, shape (n_matrices_X, n, m)) – First set of matrices.
Y (None | ndarray, shape (n_matrices_Y, n, m), default=None) – Second set of matrices. If None, Y is set to X.
Cref (None | ndarray, shape (n, m), default=None) –
Reference matrix. If None, Cref is defined as null matrix.
Added in version 0.8.
reg (float, default=1e-10) – When Y is None, regularization parameter to mitigate numerical errors in kernel matrix estimation, to provide a positive-definite kernel matrix.
- Returns:
K – Euclidean kernel matrix between X and Y.
- Return type:
ndarray, shape (n_matrices_X, n_matrices_Y)
Notes
Added in version 0.3.
Changed in version 0.8: Add parameter Cref to use a reference matrix.
Changed in version 0.12: Add support for NumPy and PyTorch.
See also
References
[1]A linear feature space for simultaneous learning of spatio-spectral filters in BCI J. Farquhar. Neural Networks, 2009