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

Explainer base #38

Merged
merged 33 commits into from
Jun 21, 2024
Merged

Explainer base #38

merged 33 commits into from
Jun 21, 2024

Conversation

gumityolcu
Copy link
Collaborator

Hello @dilyabareeva

I have implemented the base explainer interface, and an interface for the captum base explanation class DataInfluence. It turns out that their subclasses have different names for the same parameters (module instead of model, influence_src_dataset instead of dataset etc.). CaptumSimilarityExplainer implements the Similarity explainer. Other explainers from captum should be similarly easily defined.

The base explainer's self_influence computes the full explanations for the training dataset and gets the diagonals.

IMPORTANT CHANGE: Our explainer_wrapper had a bug (torch.gather statement was not doing the correct thing). So I recreated the mnist_explanations_1 asset in the test assets folder.

I got rid of old implementations of explain_wrapper and self_influence.

I added functional versions for explainers and self_influence. These are bbuilt on a general interface funtion which takes an explainer class and makes it functional.

I also fixed the test according to all changes that I made. Randomization metric test uses the functional interface to use the stateful explainer. I seperately check that the functional, stateful and ground-truth self influences are correct. So I think all the code that I add here is covered in the tests.

Best ☮️

I think you will like most of it.

@gumityolcu gumityolcu requested a review from dilyabareeva June 18, 2024 10:36
@gumityolcu
Copy link
Collaborator Author

One thing to decide:

Currently, the user is supposed to pass a functional explainer to the Randomization metric. I think metrics should accept both functional and stateful explainers. (we also have an interface that makes the stateful into a functional explainer)

what do you think about this issue?

gumityolcu and others added 12 commits June 18, 2024 13:48
# Conflicts:
#	src/explainers/aggregators.py
#	src/explainers/base.py
#	src/explainers/captum/base.py
#	src/explainers/captum/captum_influence.py
#	src/explainers/captum/similarity.py
#	src/explainers/functional.py
#	tests/explainers/test_base_explainer.py
#	tests/explainers/test_explainers.py
#	tests/explainers/test_self_influence.py
@gumityolcu
Copy link
Collaborator Author

gumityolcu commented Jun 21, 2024

Dilya the PR saver!! 🙏🏼

Copy link
Owner

@dilyabareeva dilyabareeva left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ready to merge from my side @gumityolcu

@dilyabareeva dilyabareeva merged commit 42e8ac5 into main Jun 21, 2024
2 checks passed
@dilyabareeva dilyabareeva deleted the explainer_base branch July 2, 2024 07:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants