Grad-CAM Result
Educational tensor modeOriginal image
Raw heatmap
Heatmap overlay
Thresholded regions
Activation histogram
Channel importance weights
Interpretation and Diagnostics
| Measure | Value | Meaning |
|---|
Formula Used
Channel weight: αₖᶜ = (1 / Z) Σᵢ Σⱼ ∂yᶜ / ∂Aᵏᵢⱼ Heatmap: LᶜGrad-CAM = ReLU(Σₖ αₖᶜ Aᵏ) Normalized heatmap: H = (L - min(L)) / (max(L) - min(L))
Grad-CAM pools gradients into channel importance weights. Weighted activation maps are summed into one class-specific explanation. ReLU keeps evidence that supports the selected class.
How to Use
- Upload an image or load the sample image.
- Select a model, target class, layer, and CAM method.
- Enter matching activation and gradient tensors.
- Adjust normalization, colour, overlay, and threshold controls.
- Run the calculator and inspect the generated explanation.
- Export the overlay, values, report, or comparison package.
Use educational mode for transparent matrix calculations. Use API mode when a backend produces real tensors. Always validate explanations with model and data knowledge.
Example Data
| Setting | Example | Purpose |
|---|---|---|
| Model | ResNet50-compatible | Defines the CNN family. |
| Target class | Golden retriever | Selects the class score being explained. |
| Layer | conv5_block3_out | Provides spatial convolution activations. |
| Method | Grad-CAM | Defines the weighting approach. |
| Tensor shape | 3 × 4 × 4 | Contains three activation channels. |
| Threshold | 60% | Highlights strongly activated regions. |
Understanding Grad-CAM
Grad-CAM shows where a convolutional model looked. It combines activations with target-class gradients. Brighter areas usually contribute more strongly.
Deep layers provide semantic but coarse explanations. Earlier layers retain finer spatial detail. Layer comparisons can reveal changing feature focus.
Heatmaps are explanations, not causal proof. Different methods may produce different visual emphasis. Sanity checks improve interpretation confidence.
Frequently Asked Questions
What does a red region mean?
It usually indicates stronger class-supporting activation. Meaning depends on the chosen colour map. Always check the legend and threshold.
Which layer should I choose?
The final convolution layer is a common starting point. Earlier layers provide finer details. Compare layers when explanations look too coarse.
Why is my heatmap blank?
Gradients may be near zero or negative. The selected layer may be unsuitable. Disabling ReLU can reveal negative evidence.
What is Grad-CAM++?
Grad-CAM++ uses refined pixel-wise gradient weighting. It can separate multiple object instances better. Results still depend on model behavior.
Can this page run any uploaded model?
Arbitrary models need compatible browser graph access. They may also use a server endpoint. Educational tensors work without a model runtime.
What tensor format is expected?
Each blank-line block represents one channel. Rows use commas or spaces. Activation and gradient shapes must match.
Does Grad-CAM prove model causation?
No, it visualizes sensitivity and feature emphasis. It does not prove causal reasoning. Occlusion and randomization checks are recommended.
Why compare multiple CAM methods?
Methods use different weighting assumptions. Agreement can increase interpretation confidence. Disagreement identifies explanations needing closer review.
How is activated area calculated?
The calculator counts normalized cells above threshold. It divides that count by total cells. The result is shown as percentage.