Extract `heatmap` as a top-level `ClassificationInterpretation` method?

ClassificationInterpretation.plot_top_losses contains a block of code to generate a heatmap (https://github.com/fastai/fastai/blob/master/fastai/vision/learner.py#L151-L164). It would be useful to be able to run this code on any image and not just for the images that happened to generate the top losses. Is there any reason not to extract heatmap as a top-level ClassificationInterpretation method, or something along those lines?


It could definitely be a function that plot_top_losses calls. Feel free to suggest a PR with that change!

1 Like

What do mean by “suggest a PR?”

Suggest a pull request to the fastai repo with that change.

He is suggesting that you look at the code pertinent to plot_top_losses(), read and understand the function which generates the heatmaps, extract and adapt its code for the use case you mentioned, and then submit your work via a pull request on github.

I’d like to pull out the heatmap method, but I’m waiting for the 1.1 release.

In the meantime, is the heatmap implementation in plot_top_losses correct? It is giving me results that look wrong and don’t match what I get from the code in the course notebook.

plot_top_losses output from a model that’s trained on clothing categories:


Output from course notebook code using the same model:


1 Like