sqfa.distances
Distances between Symmetric Positive Definite matrices.
Functions
|
Compute the affine invariant distance between SPD matrices. |
|
Compute the squared affine invariant distance between SPD matrices. |
|
Compute the Calvo & Oller lower bound of the Fisher-Rao squared distance between Gaussians. |
|
Compute the log-Euclidean distance between SPD matrices. |
|
Compute the squared log-Euclidean distance between SPD matrices. |
- sqfa.distances.affine_invariant(A, B)
Compute the affine invariant distance between SPD matrices. A small epsilon is added inside the square root to avoid gradient instabilities.
- Parameters:
A (torch.Tensor) – Shape (n_batch_A, n_dim, n_dim), the first SPD matrix.
B (torch.Tensor) – Shape (n_batch_B, n_dim, n_dim), the second SPD matrix.
- Returns:
distance – Shape (n_batch_A, n_batch_B), the affine invariant distance.
- Return type:
torch.Tensor
- sqfa.distances.affine_invariant_sq(A, B)
Compute the squared affine invariant distance between SPD matrices.
- Parameters:
A (torch.Tensor) – Shape (n_batch_A, n_dim, n_dim), the first SPD matrix.
B (torch.Tensor) – Shape (n_batch_B, n_dim, n_dim), the second SPD matrix.
- Returns:
distance_squared – Shape (n_batch_A, n_batch_B), the squared affine invariant distance.
- Return type:
torch.Tensor
- sqfa.distances.fisher_rao_lower_bound(statistics_A, statistics_B)
Compute the Calvo & Oller lower bound of the Fisher-Rao squared distance between Gaussians.
- Parameters:
statistics_A (dict) –
Dictionary containing the means and covariances of the first Gaussian distribution, with keys “means” and “covariances”. - The means are a torch.Tensor of shape (n_classes, n_filters) - The covariances are a torch.Tensor of
shape (n_classes, n_filters, n_filters).
statistics_B (dict) –
Dictionary containing the means and covariances of the second Gaussian distribution, with keys “means” and “covariances”. - The means are a torch.Tensor of shape (n_classes, n_filters) - The covariances are a torch.Tensor of
shape (n_classes, n_filters, n_filters).
- Returns:
distance – Shape (n_classes, n_classes), the lower bound of the Fisher-Rao distance.
- Return type:
torch.Tensor
- sqfa.distances.log_euclidean(A, B)
Compute the log-Euclidean distance between SPD matrices. A small epsilon is added inside the square root to avoid gradient instabilities.
- Parameters:
A (torch.Tensor) – Shape (n_batch_A, n_dim, n_dim), the first SPD matrix.
B (torch.Tensor) – Shape (n_batch_B, n_dim, n_dim), the second SPD matrix.
- Returns:
distance – Shape (n_batch_A, n_batch_B), the log-Euclidean distance.
- Return type:
torch.Tensor
- sqfa.distances.log_euclidean_sq(A, B)
Compute the squared log-Euclidean distance between SPD matrices.
- Parameters:
A (torch.Tensor) – Shape (n_batch_A, n_dim, n_dim), the first SPD matrix.
B (torch.Tensor) – Shape (n_batch_B, n_dim, n_dim), the second SPD matrix.
- Returns:
distance_squared – Shape (n_batch_A, n_batch_B), the squared log-Euclidean distance.
- Return type:
torch.Tensor