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)