From 6995c8f3e4c272f0fffa118a5cf708ee7e536f25 Mon Sep 17 00:00:00 2001 From: Teodora Sechkova Date: Thu, 22 Jun 2023 11:48:39 +0300 Subject: [PATCH] Add preprocessing before feature extraction Signed-off-by: Teodora Sechkova --- art/estimators/classification/pytorch.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/art/estimators/classification/pytorch.py b/art/estimators/classification/pytorch.py index 13beb1e151..bf082975d8 100644 --- a/art/estimators/classification/pytorch.py +++ b/art/estimators/classification/pytorch.py @@ -1322,6 +1322,8 @@ def get_attention_weights(self, x: Union[np.ndarray, "torch.Tensor"]) -> "torch. ] feature_extractor = create_feature_extractor(new_model, return_nodes=return_nodes) - out = feature_extractor(x) + + x_preprocessed, _ = self._apply_preprocessing(x=x, y=None, no_grad=False) + out = feature_extractor(x_preprocessed) att_weights = [v[1] for v in out.values()] return torch.stack(att_weights, dim=1)