Hi there! Maybe someone can help me with this problem:
I want to dive into CNN activation visualizations, eg GradCam. I tried to code along lesson 6 of fastai v3 part 1, and I tried to use the code from @quan.tran
However, I always get the following error (fastai 1.0.60, torch1.4.0)
Hi @johannesstutz! Firstly thanks for trying out my code I appreciate it!
So the problem is the library version. My gradcam code was tested using fastai 1.0.55 where denorm was a function of fastai Dataset(?) object. In version 1.0.66, I believe it has been integrated as function argument for function one_item. My guess is you can change these lines from:
I tried again today, and I’m a little confused but happy: your implementation is running fine now (still on fastai 1.0.60). Maybe I messed something else up the last time.
I’ll play around a little more. Do you know if there’s an easy way to visualize other layers than the last one? The goal being a higher res version of the heatmap.
In short, at least for resnet model, learn.model[0][-1][-1] (aka m[0][-1][-1] in the code) is the last pooling layer of the model’s body to perform the gradcam on, so the heatmap produced at this layer should highlight the best part of your image for classification task (though I am not sure if this is equivalent to having the higher res version). To visualize other layers, you can play with x and y in m[0][x][y]