Coding Exercise on Class Activation Maps

Complete this coding exercise on class activation maps and the implementation of Ablation-CAM.

Ablation CAM: Gradient-free approach to GradCAM

Grad-CAM suffers from the problem of gradient saturation, which causes the backpropagated gradients to diminish and, therefore, adversely affects the quality of visualizations. Ablation-CAM is a gradient-free approach to GradCAM that avoids using gradients and, at the same time, produces high-quality CAMs.

Overview of GradCAM

Let’s assume that FlRh×w\mathcal{F}_l \in \R^{h \times w} is the lthl^{th} feature map obtained from the penultimate convolutional layer (hh and ww are the height and width of the feature map) and Fl(i,j)\mathcal{F}_l(i,j) represents the activation of the (i,j)th(i,j)^{th} neuron in the lthl^{th} feature map (total LL feature maps in F\mathcal{F}).

GradCAM computes the gradient Gl(i,j)=Fl(i,j)fk(X) \mathcal{G}_l(i,j) = \nabla_{\mathcal{F_l(i,j)}} f^{k^*}(X) of the prediction score fk(X)f^{k^*}(X) with respect to a feature Fl(i,j)\mathcal{F}_l(i,j). The gradient Gl(i,j)Rh×w\mathcal{G}_l(i,j) \in \R^{h \times w} is then average pooled across height and width to be used as weights in the CAM equation:

Get hands-on with 1200+ tech skills courses.