Created
September 24, 2024 20:30
-
-
Save blackpearl006/5794b65f974a1b763f1525d730ff6b32 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from captum.attr import * | |
def getInputAttributions(model, input_tensor,target): | |
ig = IntegratedGradients(model) | |
input_tensor.requires_grad_() | |
attr, delta = ig.attribute(input_tensor, target=target, return_convergence_delta=True) | |
attr = attr.cpu().detach().numpy() | |
return attr |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment