Papers
Topics
Authors
Recent
Search
2000 character limit reached

Grad-CAM Entropy Loss

Updated 8 January 2026
  • The paper presents an auxiliary loss leveraging the Shannon entropy of normalized Grad-CAM maps to promote concentrated and interpretable activation regions.
  • It integrates the entropy term with standard cross-entropy loss using a hyperparameter to control the trade-off between classification accuracy and spatial localization.
  • Empirical results demonstrate improved Grad-CAM sharpness and contrast on CNN architectures with only a minor accuracy reduction, all without modifying the network structure.

A Grad-CAM-based Dice loss does not appear in the referenced literature. Instead, the relevant approach incorporates an auxiliary loss term based on the Shannon entropy of normalized Grad-CAM maps, aimed at enhancing the interpretability and localization properties of convolutional neural network (CNN) classifiers’ gradient-weighted class activation maps (Grad-CAMs). This entropy-regularized loss combines with the standard classification objective, does not require architectural modifications, and leverages second-order derivatives for optimization. The resulting method enables explicit control over the trade-off between classification accuracy and spatial concentration of explanation maps, facilitating deployment on both deep and embedded architectures without additional network layers (Schöttl, 2020).

1. Formulation of the Grad-CAM Entropy Loss

The technique introduces an auxiliary loss term defined as the spatial Shannon entropy of a normalized Grad-CAM map for the ground-truth class. Let LGC(c)L_{GC}^{(c)} denote the unnormalized Grad-CAM activation map for class cc:

M~ij=LGC,ij(c)k,LGC,k(c)\widetilde M_{ij} = \frac{L_{GC,ij}^{(c)}}{\sum_{k,\ell} L_{GC,k\ell}^{(c)}}

ce(LGC(c))=i,jM~ijlog ⁣(M~ij)c_e\bigl(L_{GC}^{(c)}\bigr) = -\sum_{i,j} \widetilde M_{ij}\log\!\left(\widetilde M_{ij}\right)

Here, M~ij\widetilde M_{ij} is a spatial probability distribution over map locations, ensuring i,jM~ij=1\sum_{i,j}\widetilde M_{ij}=1. The term cec_e acts as an “interpretability regularizer”, penalizing distributed (high-entropy) attention maps and favoring concentrated regions of activation.

2. Integration With Classification Objective

The total loss function combines standard cross-entropy on softmax outputs with the entropy term scaled by a new non-negative hyperparameter β\beta:

L=LCE(ytrue,ypred)+βce(LGC(c))\mathcal{L} = \mathcal{L}_{CE}\bigl(y_{\rm true}, y_{\rm pred}\bigr) + \beta\,c_e\left(L_{GC}^{(c)}\right)

where LCE(ytrue,ypred)=m=1Cytruemlogypredm\mathcal{L}_{CE}(y_{\rm true},y_{\rm pred}) = -\sum_{m=1}^C y_{\rm true}^m \log y_{\rm pred}^m. The hyperparameter cc0 governs the trade-off, with larger values enforcing greater localization in Grad-CAM maps at potential expense to classification accuracy. For cc1, the scheme reverts to conventional training.

3. Grad-CAM Map Computation and Second-Order Gradients

During training, the raw Grad-CAM map for class cc2 is constructed as follows. Let cc3 denote the cc4-th feature map from the final convolutional layer, and cc5 the pre-softmax logit for class cc6:

cc7

where cc8.

Since the loss involves entropy of the normalized Grad-CAM map, and cc9 in turn depends on gradients of the logit with respect to feature maps, the backward pass computes derivatives of derivatives (second-order gradients) with respect to the model parameters. In modern frameworks supporting higher-order differentiation, this is automatically handled, at the cost of increased computational overhead.

4. Definitions and Symbol Table

Symbol/Term Meaning
M~ij=LGC,ij(c)k,LGC,k(c)\widetilde M_{ij} = \frac{L_{GC,ij}^{(c)}}{\sum_{k,\ell} L_{GC,k\ell}^{(c)}}0 Input image, M~ij=LGC,ij(c)k,LGC,k(c)\widetilde M_{ij} = \frac{L_{GC,ij}^{(c)}}{\sum_{k,\ell} L_{GC,k\ell}^{(c)}}1
M~ij=LGC,ij(c)k,LGC,k(c)\widetilde M_{ij} = \frac{L_{GC,ij}^{(c)}}{\sum_{k,\ell} L_{GC,k\ell}^{(c)}}2 M~ij=LGC,ij(c)k,LGC,k(c)\widetilde M_{ij} = \frac{L_{GC,ij}^{(c)}}{\sum_{k,\ell} L_{GC,k\ell}^{(c)}}3-th feature map in last conv layer, M~ij=LGC,ij(c)k,LGC,k(c)\widetilde M_{ij} = \frac{L_{GC,ij}^{(c)}}{\sum_{k,\ell} L_{GC,k\ell}^{(c)}}4
M~ij=LGC,ij(c)k,LGC,k(c)\widetilde M_{ij} = \frac{L_{GC,ij}^{(c)}}{\sum_{k,\ell} L_{GC,k\ell}^{(c)}}5 Logit (pre-softmax score) for class M~ij=LGC,ij(c)k,LGC,k(c)\widetilde M_{ij} = \frac{L_{GC,ij}^{(c)}}{\sum_{k,\ell} L_{GC,k\ell}^{(c)}}6
M~ij=LGC,ij(c)k,LGC,k(c)\widetilde M_{ij} = \frac{L_{GC,ij}^{(c)}}{\sum_{k,\ell} L_{GC,k\ell}^{(c)}}7 Prediction vector, M~ij=LGC,ij(c)k,LGC,k(c)\widetilde M_{ij} = \frac{L_{GC,ij}^{(c)}}{\sum_{k,\ell} L_{GC,k\ell}^{(c)}}8
M~ij=LGC,ij(c)k,LGC,k(c)\widetilde M_{ij} = \frac{L_{GC,ij}^{(c)}}{\sum_{k,\ell} L_{GC,k\ell}^{(c)}}9 One-hot ground truth
ce(LGC(c))=i,jM~ijlog ⁣(M~ij)c_e\bigl(L_{GC}^{(c)}\bigr) = -\sum_{i,j} \widetilde M_{ij}\log\!\left(\widetilde M_{ij}\right)0 Cross-entropy loss
ce(LGC(c))=i,jM~ijlog ⁣(M~ij)c_e\bigl(L_{GC}^{(c)}\bigr) = -\sum_{i,j} \widetilde M_{ij}\log\!\left(\widetilde M_{ij}\right)1 Grad-CAM scalar, global-average gradient over feature map ce(LGC(c))=i,jM~ijlog ⁣(M~ij)c_e\bigl(L_{GC}^{(c)}\bigr) = -\sum_{i,j} \widetilde M_{ij}\log\!\left(\widetilde M_{ij}\right)2
ce(LGC(c))=i,jM~ijlog ⁣(M~ij)c_e\bigl(L_{GC}^{(c)}\bigr) = -\sum_{i,j} \widetilde M_{ij}\log\!\left(\widetilde M_{ij}\right)3 Grad-CAM activation map (raw, unnormalized) for class ce(LGC(c))=i,jM~ijlog ⁣(M~ij)c_e\bigl(L_{GC}^{(c)}\bigr) = -\sum_{i,j} \widetilde M_{ij}\log\!\left(\widetilde M_{ij}\right)4
ce(LGC(c))=i,jM~ijlog ⁣(M~ij)c_e\bigl(L_{GC}^{(c)}\bigr) = -\sum_{i,j} \widetilde M_{ij}\log\!\left(\widetilde M_{ij}\right)5 Normalized Grad-CAM activation map
ce(LGC(c))=i,jM~ijlog ⁣(M~ij)c_e\bigl(L_{GC}^{(c)}\bigr) = -\sum_{i,j} \widetilde M_{ij}\log\!\left(\widetilde M_{ij}\right)6 Entropy of normalized Grad-CAM map
ce(LGC(c))=i,jM~ijlog ⁣(M~ij)c_e\bigl(L_{GC}^{(c)}\bigr) = -\sum_{i,j} \widetilde M_{ij}\log\!\left(\widetilde M_{ij}\right)7 Weight for Grad-CAM entropy term

5. Training Procedure and Workflow

A condensed outline of the training loop integrating the Grad-CAM entropy term:

  1. Initialize network parameters ce(LGC(c))=i,jM~ijlog ⁣(M~ij)c_e\bigl(L_{GC}^{(c)}\bigr) = -\sum_{i,j} \widetilde M_{ij}\log\!\left(\widetilde M_{ij}\right)8; select ce(LGC(c))=i,jM~ijlog ⁣(M~ij)c_e\bigl(L_{GC}^{(c)}\bigr) = -\sum_{i,j} \widetilde M_{ij}\log\!\left(\widetilde M_{ij}\right)9.
  2. For each epoch and mini-batch:
    • Perform forward pass to compute feature maps M~ij\widetilde M_{ij}0, logits M~ij\widetilde M_{ij}1, and predictions.
    • Compute standard cross-entropy loss.
    • Retain gradients of logits with respect to feature maps.
    • Calculate Grad-CAM weights and construct the activation map.
    • Normalize M~ij\widetilde M_{ij}2 to obtain M~ij\widetilde M_{ij}3.
    • Evaluate the entropy M~ij\widetilde M_{ij}4.
    • Form the combined loss M~ij\widetilde M_{ij}5.
    • Backpropagate (including required second-order gradients) and update parameters.

The key computational cost arises in the backward pass, where second-order derivatives are necessary due to the dependency of M~ij\widetilde M_{ij}6 on M~ij\widetilde M_{ij}7, which itself is a function of gradients.

6. Empirical Findings on Interpretability and Classification

Experiments conducted on a ResNet-50 backbone with additional dense layers, using PASCAL VOC 2012 object crops, illustrate the quantitative effect of the entropy penalty:

  • With M~ij\widetilde M_{ij}8 (no penalty), test accuracy stabilized at ≈0.94 with relatively high-entropy, diffuse Grad-CAM maps.
  • For M~ij\widetilde M_{ij}9, test accuracy decreased marginally to ≈0.92; however, CAM entropy dropped from ≈0.99 to ≈0.92, “ellipsoidal area” ca contracted by ≈20%, and “dispersion” cd increased six-fold, indicating more decisive, sharply focused attention maps.
  • In a class “dog” example, Grad-CAM contrast increased by 114%, highlighting significantly improved localization on relevant regions.
  • A trade-off was observed in training speed: higher i,jM~ij=1\sum_{i,j}\widetilde M_{ij}=10 values approximately doubled backward pass duration due to second-order gradient tracing.

7. Applicability and Limitations

The approach can be incorporated into any standard CNN classifier without structural modification and generalizes across deep and embedded platforms. The hyperparameter i,jM~ij=1\sum_{i,j}\widetilde M_{ij}=11 permits continuous adjustment between interpretability and prediction performance, with only minor degradation in classification accuracy for substantial gains in map localization and dispersion. There is no introduction of a Dice-style overlap loss; instead, the method targets reduction of spatial entropy in the Grad-CAM explanation itself. This suggests that entropy penalization is a lightweight and effective means to encourage more interpretable, user-tractable explanations from standard CNN-based image classifiers (Schöttl, 2020).

Definition Search Book Streamline Icon: https://streamlinehq.com
References (1)

Topic to Video (Beta)

No one has generated a video about this topic yet.

Whiteboard

No one has generated a whiteboard explanation for this topic yet.

Follow Topic

Get notified by email when new papers are published related to Grad-CAM-Based Dice Loss.