fchollet / deep-learning-with-python-notebooks

Jupyter notebooks for the code samples of the book "Deep Learning with Python"
MIT License
18.17k stars 8.53k forks source link

5.4-visualizing-what-convnets-learn: Is grad-cam the only way to visualize heatmaps of class activation? #95

Open jszgz opened 5 years ago

jszgz commented 5 years ago

Hi Mr Chollet. As I was looking over your ipynb against my code, I realised that there is another way to visualize heatmaps of class activation if the network only has one global average pooling layer between the last convolution layer and the output layer。Beside the way you mentioned in your code called “Grad-CAM”, I can use this way to get similar heatmap as your's: Multiply the feature map of the last convolution layer(which is the shape of (7, 7, 1280 ) in MobileNetV2) by the most-confident index array of the weights of the output layer (which is (1280, ) of (1280, 1000)). Finally you can get a 7x7 map. Is this a right way to visualize heatmap? The map I get is different from your's.