Giter VIP home page Giter VIP logo

dasp's Introduction

Deep Approximate Shapley Propagation

This repository contains the Keras implementation for Deep Approximate Shapley Propagation (DASP), "Explaining Deep Neural Networks with a Polynomial Time Algorithm for Shapley Values Approximation", ICML 2019.

The problem of explaining the behavior of deep neural networks has gained a lot of attention over the last years. Shapley values as a unique way of assigning relevance scores such that certain desirable properties are satisfied. Unfortunately, the exact evaluation of Shapley values is prohibitively expensive, exponential in the number of input features. DASP is a polynomial-time approximation of Shapley values designed for deep neural networks. It relies on uncertainty propagation using Lightweight Probabilistic Deep Networks (LPDN) to approximate Shapley values. This libraries relies on a Keras implementation of such probabilistic framework.

Install

In your Python 3 environment run:

pip install git+https://github.com/marcoancona/DASP

We recommand using a virtual environment. This will install the required LPDN dependency but will assume tensorflow, keras and numpy are already available.

How to use

Please see the example folder for practical usage example and results. Notice that to run the example notebooks in a virtual environment you need to activate the correct kernel.

Citation

@InProceedings{ancona19a,
  title = 	 {Explaining Deep Neural Networks with a Polynomial Time Algorithm for Shapley Value Approximation},
  author = 	 {Ancona, Marco and Oztireli, Cengiz and Gross, Markus},
  booktitle = 	 {Proceedings of the 36th International Conference on Machine Learning},
  pages = 	 {272--281},
  year = 	 {2019},
  editor = 	 {Chaudhuri, Kamalika and Salakhutdinov, Ruslan},
  volume = 	 {97},
  series = 	 {Proceedings of Machine Learning Research},
  address = 	 {Long Beach, California, USA},
  month = 	 {09--15 Jun},
  publisher = 	 {PMLR},
  pdf = 	 {http://proceedings.mlr.press/v97/ancona19a/ancona19a.pdf},
  url = 	 {http://proceedings.mlr.press/v97/ancona19a.html},
  abstract = 	 {The problem of explaining the behavior of deep neural networks has recently gained a lot of attention. While several attribution methods have been proposed, most come without strong theoretical foundations, which raises questions about their reliability. On the other hand, the literature on cooperative game theory suggests Shapley values as a unique way of assigning relevance scores such that certain desirable properties are satisfied. Unfortunately, the exact evaluation of Shapley values is prohibitively expensive, exponential in the number of input features. In this work, by leveraging recent results on uncertainty propagation, we propose a novel, polynomial-time approximation of Shapley values in deep neural networks. We show that our method produces significantly better approximations of Shapley values than existing state-of-the-art attribution methods.}
}

License

MIT

dasp's People

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

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

dasp's Issues

Outputs are `nan` given a big window shape in iterator

When I run DASP on a convolutional neural network (mnist dataset), I found something weird.
If I use a ImagePlayerIterator with a big window_shape (like 1/4 of the image size), then y1 and y2 will produce nan.

y1, y2 = self.dasp_model.predict(inputs, batch_size=batch_size)
y1 = y1.reshape(len(ks), x.shape[0], -1, 2)
y2 = y2.reshape(len(ks), x.shape[0], -1, 2)

I tried to check if something like delta (0.0001) is missing in denominator or divisor, but it seems like no problem in codes of all lpdn or dasp layers.
Have you any idea about this? Thanks in advance.

ValueError

Hello,

thank you for providing your code!
I tried running the provided example (without changes) for the parkinson dataset and there seems to be an error. So the training is fine but wenn dasp = DASP(model) is executed, I get the following message:

ValueError: Layer dense_1 expects 1 input(s), but it received 3 input tensors. Inputs received: [<tf.Tensor 'Placeholder:0' shape=(None, 18) dtype=float32>, <tf.Tensor 'Placeholder_1:0' shape=(None, 18) dtype=float32>, <tf.Tensor 'Placeholder_2:0' shape=(None, 1) dtype=float32>]

The problem appears to be while executing the line:

first_layer_output = ProbDenseInput(l.units, activation=l.activation, name=l.name)(self.inputs)

from the dasp.py file. Do you know, what might be the problem? Thanks in advance!

Pytorch Version

Hi,
Thanks a lot for your great work, do you have a pytorch version of DASP?

Error in ProbDenseInput

First of all, thank you very much for making your code available online.

I experimented with your example for Parkinson and realized that approximated Shapley values are getting worse when increasing the batch size in the predict call.

After further inspecting the code, I realized that ProbDenseInput only used the first element of the k vector passed to it (which accounts of the coalition size). Thus, results would only be correct if all elements in one batch have the same coalition size. With the default batch size of 32, this is mostly true, and errors aren't very obvious, but if increasing batch size to thousands, the approximation becomes strikingly bad. Therefore, I believe instead of multiplying by k[0,0] in ProbDenseInput.call, values should be multiplied by the whole vector k instead.

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.