Code Monkey home page Code Monkey logo

integrated-gradient-pytorch's People

Contributors

tianhongdai avatar vicayang avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

integrated-gradient-pytorch's Issues

Bugs in the calculation of integrated gradient

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.

Issue with gradient computation

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)

Error trace:

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.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.