Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Gradients*Inputs #90

Closed
29 of 30 tasks
RaphaelMeudec opened this issue Sep 27, 2019 · 0 comments · Fixed by #94
Closed
29 of 30 tasks

Gradients*Inputs #90

RaphaelMeudec opened this issue Sep 27, 2019 · 0 comments · Fixed by #94
Assignees
Labels
enhancement New feature or request good first issue Good for newcomers

Comments

@RaphaelMeudec
Copy link
Collaborator

RaphaelMeudec commented Sep 27, 2019

Explanation

This issue aims at implementing the Gradients*Inputs method.

At the moment, there is only the Vanilla Gradients which is implemented. The difference between Vanilla Gradients (VG) and GradientsInputs (GI) is that instead of returning the pure gradients for a given inputs, it returns the gradients ponderated by the input values.

The operation to perform is to take the input (shape HW3) and the gradients (shape HW3), and multiple each of the 3 channels to obtain the ponderated gradients (shape HW3). From there, we create a visualization (either HW3 or HW1).

How

Part 1: Create the core algorithm

  • Create a gradients_inputs.py file
  • Create a GradientsInputs class
  • Implement the .explain method
    • Signature should be (validation_data, model, class_index)
    • Complete docstring
    • Decompose images, _ = validation_data
    • Add a compute_gradients_dot_inputs() method in the class
    • This method should look familiar to the pure gradients one
    • Instead of returning the gradient.tape, multiply it by the inputs
    • Add the tf.function decorator
  • Implement the save method (check this PR)
  • Add unit test
  • Black / Linter
  • Add the method to tf_explain.core.__init__

Part 2: Add the corresponding callback

  • Add a tf_explain.callbacks.gradients_inputs
  • Implementation should be nearly the same as tf_explain.callbacks.gradients
  • Add it to tf_explain.callbacks.__init__
  • Unit test
  • Add the callback in tests/integration/test_keras_api.py
  • Black / Linter

Part 3: Examples, Docs

  • In examples.mnist, add the implemented callback
  • Run the mnist example and load Tensorboard. Make sure that the outputs seem relevant in the Images section of Tensorboard
  • Add a examples.core file for this method
  • Run the example and put the output image in docs/assets
  • Add the method in the README.md (follow the existing scheme)
  • Add the method in docs/source/methods

Checks

  • Test coverage is 100%
  • CI is running on Python 3.6 & 3.7
  • Docs build locally (cd docs/ & make html, then open build/html/index.html)
  • Screenshot of Tensorboard on the PR
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants