Interpretability, attribution, and explanation audits · Interpretability, explanations, and model-mechanism analysis · EXP005 · Algorithm
DeepLIFT
Propagate activation differences relative to a reference through a neural computation, assigning input contributions to the difference in a chosen output.
In CodeSplash
A CodeSplash method runs this entry in Python and R. Set it up from the method's page. The methods that run it are Experimental.
- Gradient attributions for a saved model Experimental
Do it in CodeSplash Run it on your own data. It's in the Experimental lane in the app.
- Availability
- Runs in CodeSplash (Experimental)
- Code example
- Complete calculation
- Who ran it
- CodeSplash's run and the reference's record
- CodeSplash's run
- Verified in Python and R through explain.gradients. The reference's example ran in Python and R here, and they agree.
- The reference's record
- Python: Ran in the reference's review, on this exact code. R: Reviewed but not run: R wasn't available to the reference's authors.
Purpose
Propagate activation differences relative to a reference through a neural computation, assigning input contributions to the difference in a chosen output.
Question / hypotheses
Which input changes account for the output difference under the selected DeepLIFT propagation rules and reference?
Architecture / computational structure
A reference and explained input are passed through the network. Difference multipliers are propagated backward with rules such as Rescale or RevealCancel. These rules differ from ordinary local derivatives; supported operations and propagation conventions matter.
Assumptions
Each operation needs a valid attribution rule and compatible reference activations. The Rescale rule for a scalar nonlinearity uses a finite activation difference. Behavior at zero differences and complex nonlinear operations must be specified; implementation invariance is not automatic for arbitrary rules.
Formula / computational definition
Parameters and notation
Network parameters remain fixed. Explanation settings include reference input(s), output, propagation rule, stabilization near zero denominators, supported nonlinear operations, and any background averaging. Multipliers are explanation quantities rather than newly learned weights. A delta denotes an activation difference from its reference activation. C is a contribution, m a contribution multiplier, t the selected output, and z and y the pre- and post-nonlinearity activations. A zero denominator requires an appropriate limiting rule.
Fitting, fine-tuning, and adaptation
Refresh references and recompute after model adaptation, stating whether reference distributions were held fixed. For architecture changes, verify that every new operation has a supported propagation rule; a silent gradient fallback may alter the method.
How to use and calibrate
Check summation to the reference-output difference and compare carefully against IG on simple networks. Test equivalent computational graphs and inspect differences. Record whether Rescale, RevealCancel, or a library-specific variant was used.
Example application
Attribute a one-ReLU unit whose activation crosses zero between baseline and input, where an endpoint derivative alone would not describe the full change.
Interpretation / pitfalls
Watch out
Completeness does not establish that a reference represents feature absence. Different graph decompositions or nonlinear interaction rules can change contributions. A toy Rescale calculation does not implement every DeepLIFT rule for a modern transformer.
Python and R code examples
Scope: Complete Rescale attribution for one affine-ReLU unit. Python: NumPy; R: base R.
Validation: Python executed successfully on the supplied fixture; R reviewed but unexecuted. Full implementations and supported operation details are provided in the linked primary/official sources.
Python and R
The reference's own programs, shown as written. A component demo shows one central piece of the method; it doesn't train a full model.
Complete calculation — Complete Rescale attribution for one affine-ReLU unit. Python: NumPy; R: base R. · needs numpy
import numpy as np
x=np.array([2.,1.]);b=np.zeros(2);w=np.array([1.,-.5]);bias=-.5
z0=w@b+bias;z=w@x+bias;delta=max(z,0)-max(z0,0)
mult=delta/(z-z0);contrib=(x-b)*w*mult
assert np.isclose(contrib.sum(),delta);print(contrib)
Complete calculation — Complete Rescale attribution for one affine-ReLU unit. Python: NumPy; R: base R.
x<-c(2,1);b<-c(0,0);w<-c(1,-.5);bias<--.5
z0<-sum(w*b)+bias;z<-sum(w*x)+bias;delta<-max(z,0)-max(z0,0)
mult<-delta/(z-z0);contrib<-(x-b)*w*mult
stopifnot(abs(sum(contrib)-delta)<1e-12);print(contrib)
Sources
- Source 1arxiv.org
- Source 2github.com
From the CodeSplash reference, entry EXP005.