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

Update Benchmarking Notebook & Refactor Training Pipeline #12

Open
wants to merge 10 commits into
base: master
Choose a base branch
from

Conversation

JensRahnfeld
Copy link

@JensRahnfeld JensRahnfeld commented Jul 19, 2024

As a token of gratitude for the great work, some updates to help people reading & running the code 🤗.

Below a list of all the changes. In addition to the committed changes, there were some potential changes that i could imagine improving the experimental setup. These are left as unchecked boxes. I separated changes to the training pipeline and the benchmarking notebook into 2 branches, just in case.

Training Pipeline

  • Load Pets dataset through fastai api removing need to specify dataset location manually
  • Remove code duplicates by merging classifier, surrogate & explainer backbone init & loading into a base module
  • Fix checkpointing
  • Add conda environment.yaml for all the 🐍 enjoyers
  • Set default precision to 32-bit (this fixed nan encounters due to numerical issues on ImageNette for me)

Benchmarking Notebook

  • fix import (there seemed to be some rename vitmedical.modules.explainer -> vit_shapley.modules.explainer)
  • fix checkpointing upon LRP initialization
  • cd into parent directory (vit-shapley) only upon first cell execution (otherwise it would keep cd'ing "../")
  • automatically create result folders for experiments
  • clean up unused code / cells
  • Evaluate Attention Rollout with Residuals (set to False which degrades performance metric-wise)
  • Sample Rise masks using generate_mask instead of binomial distribution as done for the surrogate model

Sanity Check

To make sure, refactoring the training pipeline didn't mess up the semantics, i re-ran the experiments on the Pets dataset. Here are the learning curves i got:

image
image
image

To save compute, i refrained from retraining on ImageNette and re-used the weights i got from back then. In both cases, evaluating Insertion, Deletion & Faithfulness did reproduce the results of the paper for vit_base_patch16_224.

Please let me know if you like it or have additional suggestions.

- create experiment's result directories automatically
- import explainer from existing module
- dynamic state dict loading when initializing LRP
- add option to specfiy number of masks per rise batch
…e corresponding cell was executed regardless of dataset leading to an exception when running it with pets
@JensRahnfeld JensRahnfeld mentioned this pull request Jul 22, 2024
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.

1 participant