GuidedBackpropExplainer<T>
Models & Types · AiDotNet.Interpretability.Explainers
Guided Backpropagation explainer for neural network visualization.
Implements: IGPUAcceleratedExplainer<T>, ILocalExplainer<T, GuidedBackpropExplanation<T>>
For Beginners
Guided Backpropagation is a gradient-based visualization technique that shows which parts of an input most strongly activate a particular output.
Key Insight: Regular backpropagation can produce noisy gradients because it propagates both positive and negative values through ReLU activations. Guided Backprop only propagates gradients where BOTH the input to ReLU was positive AND the gradient flowing back is positive.
How it works:
- Do a forward pass to get activations
- During backpropagation, at each ReLU:
- Regular backprop: gradient flows if input > 0
- Guided backprop: gradient flows if input > 0 AND gradient > 0
- The result highlights features that positively contribute to the output
Use cases:
- Visualizing what a CNN “sees” in an image
- Understanding which pixels matter for a classification
- Debugging models (are they looking at the right features?)
Compared to other methods:
- Regular gradient: Noisy, can have negative attributions
- Guided backprop: Cleaner, only positive attributions
- DeconvNet: Only considers forward activations, not gradients
- GradCAM: Coarse localization (good with Guided Backprop = Guided GradCAM)
Constructors
| Constructor | Summary |
|---|---|
GuidedBackpropExplainer(Func<Vector<T>, Vector<T>> predictFunction, Func<Tensor<T>, Tensor<T>> tensorPredictFunction, int[] inputShape) |
Initializes a Guided Backpropagation explainer from prediction functions. |
GuidedBackpropExplainer(INeuralNetwork<T> network, int[] inputShape) |
Initializes a Guided Backpropagation explainer from a neural network. |
Properties
| Property | Summary |
|---|---|
bool IsGPUAccelerated { get; } |
|
bool SupportsGlobalExplanations { get; } |
|
bool SupportsLocalExplanations { get; } |
|
string MethodName { get; } |
Methods
| Method | Summary |
|---|---|
GuidedBackpropExplanation<T> Explain(Vector<T> input, int? targetClass) |
Explains a single input using Guided Backpropagation. |
GuidedBackpropExplanation<T> ExplainTensor(Tensor<T> input, int? targetClass) |
Explains a tensor input (e.g., image). |
GuidedBackpropExplanation<T>[] ExplainBatch(Matrix<T> instances) |
|
void SetGPUHelper(GPUExplainerHelper<T> helper) |