tianhongdai / integrated-gradient-pytorch Goto Github PK
View Code? Open in Web Editor NEWThis is the pytorch implementation of the paper - Axiomatic Attribution for Deep Networks.
License: MIT License
This is the pytorch implementation of the paper - Axiomatic Attribution for Deep Networks.
License: MIT License
The sum of the integrated gradients should be the change of the prediction score (F(x)-F(x')), which is also Proposition 1 in the paper. However, the integrated gradients calculated in this repo is wrong so that this proposition is not hold.
After checking the code and comparing it with the code provided by the authors, I found that you used the wrong (x-x') in the calculation, which should be the inputs that are calculating gradients.
I make a pull request to tackle this issue.
On running the following line of code in main.py, i am getting RuntimeError:
gradients, label_index = calculate_outputs_and_gradients([img], model, None, args.cuda)
RuntimeError Traceback (most recent call last)
in ()
5 img = img[:, :, (2, 1, 0)]
6 # calculate the gradient and the label index
----> 7 gradients, label_index = calculate_outputs_and_gradients([img], model, None, args.cuda)
/dccstor/cssblr/anirban/integrated-gradient-pytorch/utils.pyc in calculate_outputs_and_gradients(inputs, model, target_label_idx, cuda)
21 # clear grad
22 model.zero_grad()
---> 23 output.backward()
24 gradient = input.grad.detach().cpu().numpy()[0]
25 gradients.append(gradient)
/dccstor/anirlaha1/deep/apr2018/lib/python2.7/site-packages/torch/tensor.pyc in backward(self, gradient, retain_graph, create_graph)
100 products. Defaults to False
.
101 """
--> 102 torch.autograd.backward(self, gradient, retain_graph, create_graph)
103
104 def register_hook(self, hook):
/dccstor/anirlaha1/deep/apr2018/lib/python2.7/site-packages/torch/autograd/init.pyc in backward(tensors, grad_tensors, retain_graph, create_graph, grad_variables)
88 Variable._execution_engine.run_backward(
89 tensors, grad_tensors, retain_graph, create_graph,
---> 90 allow_unreachable=True) # allow_unreachable flag
91
92
RuntimeError: one of the variables needed for gradient computation has been modified by an inplace operation
Please help. Thanks.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.