Generating CAMs
Imagine a scenario where you have built a model that is able to make good predictions. However, the stakeholder that you are presenting the model to wants to understand the reason why the model predictions are as they are. A CAM comes in handy in this scenario.
An example CAM is as follows, where we have the input image on the left and the pixels that were used to come up with the class prediction highlighted on the right:
Figure 6.1: Image (left) and corresponding CAM (right)
This way, if one wants to debug or understand model predictions, one can leverage CAMs to learn about the pixels that are influencing the output predictions the most.
Let’s understand how CAMs can be generated once a model is trained. Feature maps are intermediate activations that come after a convolution operation. Typically, the shape of these activation maps is n-channels x height x width
. If we take the mean of all these activations, they show the hotspots of...