quanda.utils.functions package¶
Util funcitons.
- quanda.utils.functions.cosine_similarity(test, train, replace_nan=0) Tensor[source]¶
Compute cosine similarity between test and train activations.
- Parameters:
test (torch.Tensor) – The test activations.
train (torch.Tensor) – The train activations.
replace_nan (int, optional) – The value to replace NaN values with. Default is 0.
- Returns:
The cosine similarity between the test and train activations.
- Return type:
torch.Tensor
- quanda.utils.functions.dot_product_similarity(test, train, replace_nan=0) Tensor[source]¶
Compute cosine similarity between test and train activations.
- Parameters:
test (torch.Tensor) – The test activations.
train (torch.Tensor) – The train activations.
replace_nan (int, optional) – The value to replace NaN values with. Default is 0.
- Returns:
The dot product similarity between the test and train activations.
- Return type:
torch.Tensor
- quanda.utils.functions.kendall_rank_corr(tensor1, tensor2)[source]¶
Calculate torchmetrics kendall_corrcoef function.
The difference is that the input tensors are transposed before passing to the function.
- Parameters:
tensor1 (torch.Tensor) – The input tensors to compute the correlation coefficient.
tensor2 (torch.Tensor) – The input tensors to compute the correlation coefficient.
- Returns:
The Kendall Rank correlation coefficient between the two tensors.
- Return type:
torch.Tensor
- quanda.utils.functions.spearman_rank_corr(tensor1, tensor2)[source]¶
Calculate torchmetrics spearman_corrcoef function.
The difference is that the input tensors are transposed before passing to the function.
- Parameters:
tensor1 (torch.Tensor) – The input tensors to compute the correlation coefficient.
tensor2 (torch.Tensor) – The input tensors to compute the correlation coefficient.
- Returns:
The Spearman correlation coefficient between the two tensors.
- Return type:
torch.Tensor