From 2fd39ba79ac8956c3efe16066c64147c987e63d7 Mon Sep 17 00:00:00 2001 From: cofri Date: Sun, 28 Apr 2024 17:33:31 +0200 Subject: [PATCH 1/2] fix(Mahalanobis): mean covariance computation len(features) is a list and here equals 1. Expected value is: len(features[0]) --- oodeel/methods/mahalanobis.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/oodeel/methods/mahalanobis.py b/oodeel/methods/mahalanobis.py index e32d2158..3b29ca72 100644 --- a/oodeel/methods/mahalanobis.py +++ b/oodeel/methods/mahalanobis.py @@ -74,9 +74,9 @@ def _fit_to_dataset(self, fit_dataset: DatasetType) -> None: / _zero_f_cls.shape[0] ) if mean_cov is None: - mean_cov = (len(_features_cls) / len(features)) * cov_cls + mean_cov = (len(_features_cls) / len(features[0])) * cov_cls else: - mean_cov += (len(_features_cls) / len(features)) * cov_cls + mean_cov += (len(_features_cls) / len(features[0])) * cov_cls # pseudo-inverse of the mean covariance matrix self._pinv_cov = self.op.pinv(mean_cov) From c13da98d903abb97ef7ea1ab2fc72b0b07bf4cb6 Mon Sep 17 00:00:00 2001 From: cofri Date: Fri, 26 Apr 2024 18:04:47 +0200 Subject: [PATCH 2/2] fix(RMDS): sign error fixed --- oodeel/methods/rmds.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/oodeel/methods/rmds.py b/oodeel/methods/rmds.py index c0f5b2ff..b08ecf88 100644 --- a/oodeel/methods/rmds.py +++ b/oodeel/methods/rmds.py @@ -96,7 +96,7 @@ def _score_tensor(self, inputs: TensorType) -> Tuple[np.ndarray]: # take the highest score for each sample gaussian_score_corrected = self.op.max( - gaussian_score_bg - gaussian_score_p, dim=1 + gaussian_score_p - gaussian_score_bg, dim=1 ) return -self.op.convert_to_numpy(gaussian_score_corrected)