zhoubolei / CAM

Class Activation Mapping
http://cnnlocalization.csail.mit.edu/
MIT License
1.85k stars 467 forks source link

Is values of heatmap plane comparable? #24

Open mrgloom opened 6 years ago

mrgloom commented 6 years ago

For example I have 2 classes and for single image I have heatmap with shape [H,W,N_CLASSES]. I train my model with sigmoid + binary crossentropy. At prediction time when I use larger image as network input, at each pixel I want my classes to be exclusive, so I need to compare heatmap values with np.argmax to get 'best' class, so my questions is values in heatmaps are really comparable?

I tried to dump min, max values of heatmap for single image:

i 0
np.min(heatmap[:,:,i]),np.max(heatmap[:,:,i]) -38.4533 19.9384
i 1
np.min(heatmap[:,:,i]),np.max(heatmap[:,:,i]) -20.2977 34.8101 

As I can see range of values are different and heatmaps are not normalized.

Is there a way to normalize all planes of heatmap to [0,1] range and make them comparable?

linzhiqiu commented 6 years ago

Hey @mrgloom are you able to solve this question? I actually have a related question: Is the values of heat map inter-comparable? I.e. if the max value of heat map 1 is 34, and the max value of heat map 2 is 19, can we see that the max value cell of heat map 1 contribute more to the final class score than heat map 2?

I feel like the answer is yes, but was having a hard time justifying this. Let me know your thoughts on this!