GuidedGradCAMExplainer<T>
Models & Types · AiDotNet.Interpretability.Explainers
Guided GradCAM explainer combining GuidedBackprop with GradCAM for high-resolution explanations.
Implements: IGPUAcceleratedExplainer<T>, ILocalExplainer<T, GuidedGradCAMExplanation<T>>
For Beginners
Guided GradCAM is the best of both worlds - it combines:
- GradCAM: Tells you WHERE to look (coarse localization)
- GuidedBackprop: Tells you WHAT to look for (fine-grained details)
How it works:
- Compute GradCAM map (coarse localization of important regions)
- Upsample GradCAM to input resolution
- Compute Guided Backpropagation (fine-grained pixel-level importance)
- Element-wise multiply: GuidedGradCAM = GuidedBackprop * upsampled_GradCAM
Why this works:
- GradCAM alone is too coarse (can’t see fine details)
- GuidedBackprop alone highlights details everywhere (not localized)
- Multiplying them together keeps only important details in important regions
Result: High-resolution, class-discriminative visualizations that show both WHERE the model is looking AND WHAT features it sees there.
Use cases:
- Medical imaging (showing exactly what pixels indicate disease)
- Object detection debugging (why was this object detected?)
- Fine-grained classification (what distinguishes this bird species?)
Constructors
| Constructor | Summary |
|---|---|
GuidedGradCAMExplainer(GuidedBackpropExplainer<T> guidedBackpropExplainer, LayerGradCAMExplainer<T> gradcamExplainer, int[] inputShape) |
Initializes a Guided GradCAM explainer from component explainers. |
GuidedGradCAMExplainer(INeuralNetwork<T> network, Func<Vector<T>, Vector<T>> predictFunction, Func<Vector<T>, Vector<T>> layerActivationFunction, Func<Vector<T>, int, Vector<T>> layerGradientFunction, int[] inputShape, int layerHeight, int layerWidth, int numChannels) |
Initializes a Guided GradCAM explainer from a neural network. |
Properties
| Property | Summary |
|---|---|
bool IsGPUAccelerated { get; } |
|
bool SupportsGlobalExplanations { get; } |
|
bool SupportsLocalExplanations { get; } |
|
string MethodName { get; } |
Methods
| Method | Summary |
|---|---|
GuidedGradCAMExplanation<T> Explain(Vector<T> input, int? targetClass) |
Generates a Guided GradCAM explanation for an input. |
GuidedGradCAMExplanation<T> ExplainTensor(Tensor<T> input, int? targetClass) |
Explains a tensor input. |
GuidedGradCAMExplanation<T>[] ExplainBatch(Matrix<T> instances) |
|
void SetGPUHelper(GPUExplainerHelper<T> helper) |