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

RISE returns different heatmap for same input #6

Open
bartmch opened this issue May 20, 2020 · 7 comments
Open

RISE returns different heatmap for same input #6

bartmch opened this issue May 20, 2020 · 7 comments

Comments

@bartmch
Copy link

bartmch commented May 20, 2020

Hey, after making your model torch>1.0 compatible I got the RISE "explainer" predictions for the covid-19 file "4-x-day1.jpg" twice. The predictions are the same:
image
image

but the heatmaps produced by RISE look totally different:
image
image

Does the same happen to your torch<1.0 model? If not, do you know what could be the issue?

@arpanmangal
Copy link
Owner

@SuryaKalia could you please look into this?

@SuryaKalia
Copy link
Collaborator

That behaviour is due to the randomly generated masks in the visualize function. Each call generates a new set of masks while the generate_new flag is true. Some solutions are:

  1. Set generate_new = False at line 36, visualize.py - This will use the previously saved masks.npy
  2. Set a random seed - That's redundant repetition of generating identical random masks over and over again.
  3. Increase the number of masks generated. This is currently set as N=1000 at line 39, visualize.py. Having a large number of random masks would generate more consistent results due to the large sampling, though at the cost of compute time.

@bartmch
Copy link
Author

bartmch commented May 20, 2020

Ok will do that now, quick side question: have you also looked into grad-cam visualization techniques?

@bartmch
Copy link
Author

bartmch commented May 20, 2020

On the first solution ("Set generate_new = False at line 36, visualize.py - This will use the previously saved masks.npy"), I'm getting the following error on line 59 of "explanations.py"
image

@bartmch
Copy link
Author

bartmch commented May 20, 2020

On the third solution ("Increase the number of masks generated"). I'm still getting totally different heatmaps. I changed from
explainer.generate_masks(N=1000, s=8, p1=0.1, savepath=maskspath)
to
explainer.generate_masks(N=10000, s=8, p1=0.1, savepath=maskspath)
and got the following heatmaps on the same data:
image
image
image
image

@bartmch
Copy link
Author

bartmch commented May 26, 2020

Hi! Any updates on this?

@SuryaKalia
Copy link
Collaborator

Hi, thanks for pointing out. I've fixed that issue. The first solution should work now.

The 3rd solution - increasing the number of masks is still bound to give different visualizations. This is an inherent limitation of the RISE visualization method.

Grad-CAM is a good alternative. However, that had an issue with images which had very high predictive confidence for a given class, causing gradient saturation. To eliminate those issues we used RISE visualizations.

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

No branches or pull requests

3 participants