Skip to content

Commit

Permalink
Add preprocessing before feature extraction
Browse files Browse the repository at this point in the history
Signed-off-by: Teodora Sechkova <[email protected]>
  • Loading branch information
sechkova committed Jun 22, 2023
1 parent 059b6bc commit 6995c8f
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion art/estimators/classification/pytorch.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

0 comments on commit 6995c8f

Please sign in to comment.