From 63b89ef7623501925ac6a49eca351e0af9790f01 Mon Sep 17 00:00:00 2001 From: Prem Kiran Laknaboina Date: Tue, 19 Nov 2024 20:59:46 +0530 Subject: [PATCH] Update randomized_smoothing.py Signed-off-by: Prem Kiran Laknaboina --- .../randomized_smoothing/randomized_smoothing.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/art/estimators/certification/randomized_smoothing/randomized_smoothing.py b/art/estimators/certification/randomized_smoothing/randomized_smoothing.py index 50f0b4322d..6ce339c6cf 100644 --- a/art/estimators/certification/randomized_smoothing/randomized_smoothing.py +++ b/art/estimators/certification/randomized_smoothing/randomized_smoothing.py @@ -100,13 +100,13 @@ def predict(self, x: np.ndarray, batch_size: int = 128, verbose: bool = False, * # get class counts counts_pred = self._prediction_counts(x_i, batch_size=batch_size) top = counts_pred.argsort()[::-1] - # Conersion to int + # conversion to int count1 = int(np.max(counts_pred)) count2 = int(counts_pred[top[1]]) # predict or abstain smooth_prediction = np.zeros(counts_pred.shape) - #Get p value from BinomTestResult object + # get p value from BinomTestResult object p_value = binomtest(count1, count1 + count2, p=0.5).pvalue if (not is_abstain) or (p_value <= self.alpha): smooth_prediction[np.argmax(counts_pred)] = 1