deeplift
Public facing deeplift repo
view repo
The purported "black box"' nature of neural networks is a barrier to adoption in applications where interpretability is essential. Here we present DeepLIFT (Deep Learning Important FeaTures), a method for decomposing the output prediction of a neural network on a specific input by backpropagating the contributions of all neurons in the network to every feature of the input. DeepLIFT compares the activation of each neuron to its 'reference activation' and assigns contribution scores according to the difference. By optionally giving separate consideration to positive and negative contributions, DeepLIFT can also reveal dependencies which are missed by other approaches. Scores can be computed efficiently in a single backward pass. We apply DeepLIFT to models trained on MNIST and simulated genomic data, and show significant advantages over gradient-based methods. A detailed video tutorial on the method is at http://goo.gl/qKb7pL and code is at http://goo.gl/RM8jvH.
READ FULL TEXT VIEW PDF
Note: This paper describes an older version of DeepLIFT. See
https://arx...
read it
Attributing the output of a neural network to the contribution of given ...
read it
The predictive power of neural networks often costs model interpretabili...
read it
Gaining insight into how deep convolutional neural network models perfor...
read it
Deep learning is increasingly used in decision-making tasks. However,
un...
read it
Creativity, a process that generates novel and valuable ideas, involves
...
read it
As Deep Neural Networks (DNNs) have demonstrated superhuman performance ...
read it
Public facing deeplift repo
As neural networks become increasingly popular, their “black box” reputation is a barrier to adoption when interpretability is paramount. Here, we present DeepLIFT (Deep Learning Important FeaTures), a novel algorithm to assign importance score to the inputs for a given output. Our approach is unique in two regards: first, it frames the question of importance in terms of differences from a ‘reference’ state, where the ‘reference’ is chosen by the user according to what is appropriate for the problem at hand. In contrast to most gradient-based methods, using a difference-from-reference allows DeepLIFT to propagate an importance signal even in situations where the gradient is zero and avoids artifacts caused by discontinuities in the gradient. Second, by optionally giving separate consideration to the effects of positive and negative contributions at nonlinearities, DeepLIFT can reveal dependencies missed by other approaches. As DeepLIFT scores are computed using a backpropagation-like algorithm, they can be obtained efficiently in a single backward pass through the network after a prediction has been made.
This section provides a review of existing approaches to assign importance scores for a given task and input example.
These approaches make perturbations to individual inputs or neurons and observe the impact on later neurons in the network. Zeiler & Fergus (Zeiler & Fergus, 2013) occluded different segments of an input image and visualized the change in the activations of later layers. “In-silico mutagenesis” (Zhou & Troyanskaya, 2015) introduced virtual mutations at individual positions in a genomic sequence and quantified the their impact on the output. Zintgraf et al. (Zintgraf et al., 2017) proposed a clever strategy for analyzing the difference in a prediction after marginalizing over each input patch. However, such methods can be computationally inefficient as each perturbation requires a separate forward propagation through the network. They may also underestimate the importance of features that have saturated their contribution to the output (Fig. 1).
In contrast to perturbation methods, backpropagation approaches are computationally efficient as they propagate an importance signal from the output neuron backwards through the layers towards the input in a single pass. DeepLIFT belongs to this family of approaches.
Simonyan et al. (Simonyan et al., 2013) proposed using the gradient of the output w.r.t. pixels of an input image to compute a “saliency map” of the image in the context of image classification tasks. The authors showed that this was similar to deconvolutional networks (Zeiler & Fergus, 2013)
except for the handling of the nonlinearity at rectified linear units (ReLUs). When backpropagating importance using gradients, the gradient coming into a ReLU during the backward pass is zero’d out if the input to the ReLU during the forward pass is negative. By contrast, when backpropagating an importance signal in deconvolutional networks, the importance signal coming into a ReLU during the backward pass is zero’d out if and only if it is negative, with no regard to sign of the input to the ReLU during the forward pass. Springenberg et al.,
(Springenberg et al., 2014) combined these two approaches into Guided Backpropagation, which zero’s out the importance signal at a ReLU if either the input to the ReLU during the forward pass is negative or the importance signal during the backward pass is negative. Guided Backpropagation can be thought of as equivalent to computing gradients, with the caveat that any gradients that become negative during the backward pass are discarded at ReLUs. Due to the zero-ing out of negative gradients, both guided backpropagation and deconvolutional networks can fail to highlight inputs that contribute negatively to the output. Additionally, none of the three approaches would address the saturation problem illustrated in Fig. 1, as the gradient of w.r.t. is negative (causing Guided Backprop and deconvolutional networks to assign zero importance), and the gradient of w.r.t both and is zero when (causing both gradients and Guided Backprop to be zero). Discontinuities in the gradients can also cause undesirable artifacts (Fig. 2).Bach et al. (Bach et al., 2015) proposed an approach for propagating importance scores called Layerwise Relevance Propagation (LRP). Shrikumar et al. and Kindermans et al. (Shrikumar et al., 2016; Kindermans et al., 2016) showed that absent modifications to deal with numerical stability, the original LRP rules were equivalent within a scaling factor to an elementwise product between the saliency maps of Simonyan et al. and the input (in other words, gradient input). In our experiments, we compare DeepLIFT to gradient input as the latter is easily implemented on a GPU, whereas LRP does not currently have GPU implementations available to our knowledge.
While gradient input is often preferable to gradients alone as it leverages the sign and strength of the input, it still does not address the saturation problem in Fig. 1 or the thresholding artifact in Fig. 2.
Instead of computing the gradients at only the current value of the input, one can integrate the gradients as the inputs are scaled up from some starting value (eg: all zeros) to their current value (Sundararajan et al., 2016). This addressess the saturation and thresholding problems of Fig. 1 and Fig. 2, but numerically obtaining high-quality integrals adds computational overhead. Further, this approach can still give highly misleading results (see Section 3.4.3).
Grad-CAM (Selvaraju et al., 2016)
computes a coarse-grained feature-importance map by associating the feature maps in the final convolutional layer with particular classes based on the gradients of each class w.r.t. each feature map, and then using the weighted activations of the feature maps as an indication of which inputs are most important. To obtain more fine-grained feature importance, the authors proposed performing an elementwise product between the scores obtained from Grad-CAM and the scores obtained from Guided Backpropagation, termed Guided Grad-CAM. However, this strategy inherits the limitations of Guided Backpropagation caused by zero-ing out negative gradients during backpropagation. It is also specific to convolutional neural networks.
DeepLIFT explains the difference in output from some ‘reference’ output in terms of the difference of the input from some ‘reference’ input. The ‘reference’ input represents some default or ‘neutral’ input that is chosen according to what is appropriate for the problem at hand (see Section 3.3 for more details). Formally, let
represent some target output neuron of interest and let
represent some neurons in some intermediate layer or set of layers that are necessary and sufficient to compute . Let represent the reference activation of . We define the quantity to be the difference-from-reference, that is . DeepLIFT assigns contribution scores to s.t.:(1) |
We call Eq. 1 the summation-to-delta property. can be thought of as the amount of difference-from-reference in that is attributed to or ‘blamed’ on the difference-from-reference of . Note that when a neuron’s transfer function is well-behaved, the output is locally linear in its inputs, providing additional motivation for Eq. 1.
can be non-zero even when is zero. This allows DeepLIFT to address a fundamental limitation of gradients because, as illustrated in Fig. 1, a neuron can be signaling meaningful information even in the regime where its gradient is zero. Another drawback of gradients addressed by DeepLIFT is illustrated in Fig. 2, where the discontinuous nature of gradients causes sudden jumps in the importance score over infinitesimal changes in the input. By contrast, the difference-from-reference is continuous, allowing DeepLIFT to avoid discontinuities caused by bias terms.
For a given input neuron with difference-from-reference , and target neuron with difference-from-reference that we wish to compute the contribution to, we define the multiplier as:
(2) |
In other words, the multiplier is the contribution of to divided by . Note the close analogy to the idea of partial derivatives: the partial derivative is the infinitesimal change in caused by an infinitesimal change in , divided by the infinitesimal change in . The multiplier is similar in spirit to a partial derivative, but over finite differences instead of infinitesimal ones.
Assume we have an input layer with neurons , a hidden layer with neurons , and some target output neuron . Given values for and , the following definition of is consistent with the summation-to-delta property in Eq. 1 (see Appendix A for the proof):
(3) |
We refer to Eq. 3 as the chain rule for multipliers
. Given the multipliers for each neuron to its immediate successors, we can compute the multipliers for any neuron to a given target neuron efficiently via backpropagation - analogous to how the chain rule for partial derivatives allows us to compute the gradient w.r.t. the output via backpropagation.
When formulating the DeepLIFT rules described in Section 3.5, we assume that the reference of a neuron is its activation on the reference input. Formally, say we have a neuron with inputs such that . Given the reference activations of the inputs, we can calculate the reference activation of the output as:
(4) |
i.e. references for all neurons can be found by choosing a reference input and propagating activations through the net.
The choice of a reference input is critical for obtaining insightful results from DeepLIFT. In practice, choosing a good reference would rely on domain-specific knowledge, and in some cases it may be best to compute DeepLIFT scores against multiple different references. As a guiding principle, we can ask ourselves “what am I interested in measuring differences against?”. For MNIST, we use a reference input of all-zeros as this is the background of the images. For the binary classification tasks on DNA sequence inputs (strings over the alphabet {A,C,G,T}), we obtain sensible results using either a reference input containing the expected frequencies of ACGT in the background (Fig. 5), or by averaging the results over multiple reference inputs for each sequence that are generated by shuffling each original sequence (Appendix J).
It is important to note that gradientinput implicitly uses a reference of all-zeros (it is equivalent to a first-order Taylor approximation of gradientinput where is measured w.r.t. an input of zeros). Similary, integrated gradients (Section 2.2.3) requires the user to specify a starting point for the integral, which is conceptually similar to specifying a reference for DeepLIFT. While Guided Backprop and pure gradients don’t use a reference, we argue that this is a limitation as these methods only describe the local behaviour of the output at the specific input value, without considering how the output behaves over a range of inputs.
We will see in Section 3.5.3 that, in some situations, it is essential to treat positive and negative contributions differently. To do this, for every neuron , we will introduce and that represent the positive and negative components of , such that:
The importance of this will become apparent when discussing the RevealCancel rule (Section 3.5.3), where we find that and may be different. However, for the Linear and Rescale rules (Section 3.5.1 and Section 3.5.2), we have .
We present the rules for assigning contribution scores for each neuron to its immediate inputs. In conjunction with the chain rule for multipliers (Section 3.2), these rules can be used to find the contributions of any input (not just the immediate inputs) to a target output via backpropagation.
This applies to Dense and Convolutional layers (excluding nonlinearities). Let be a linear function of its inputs such that . We have . We define the positive and negative parts of as:
Which leads to the following choice for the contributions:
We can then find multipliers using the definition in Section 3.2.1, which gives and .
What about when ? While setting multipliers to 0 in this case would be consistent with summation-to-delta, it is possible that and are nonzero (and cancel each other out), in which case setting the multiplier to 0 would fail to propagate importance to them. To avoid this, we set when is 0 (similarly for ). See Appendix B for how to compute these multipliers using standard neural network ops.
This rule applies to nonlinear transformations that take a single input, such as the ReLU, tanh or sigmoid operations. Let neuron be a nonlinear transformation of its input such that . Because has only one input, we have by summation-to-delta that , and consequently . For the Rescale rule, we set and proportional to and as follows:
Based on this, we get:
In the case where , we have and . The definition of the multiplier approaches the derivative, i.e. , where the is evaluated at . We can thus use the gradient instead of the multiplier when is close to its reference to avoid numerical instability issues caused by having a small denominator.
Note that the Rescale rule addresses both the saturation and the thresholding problems illustrated in Fig. 1 and Fig. 2. In the case of Fig. 1, if , then at we have and , giving even though (in other words, using difference-from-reference allows information to flow even when the gradient is zero). In the case of Fig. 2, assuming , at we have , giving and . By contrast, gradientinput assigns a contribution of to and to the bias term (DeepLIFT never assigns importance to bias terms).
As revealed in previous work (Lundberg & Lee, 2016), there is a connection between DeepLIFT and Shapely values. Briefly, the Shapely values measure the average marginal effect of including an input over all possible orderings in which inputs can be included. If we define “including” an input as setting it to its actual value instead of its reference value, DeepLIFT can be thought of as a fast approximation of the Shapely values. At the time, Lundberg & Lee cited a preprint of DeepLIFT which described only the Linear and Rescale rules with no separate treatment of positive and negative contributions.
While the Rescale rule improves upon simply using gradients, there are still some situations where it can provide misleading results. Consider the operation depicted in Fig. 3, with reference values of and . Using the Rescale rule, all importance would be assigned either to or to (whichever is smaller). This can obscure the fact that both inputs are relevant for the operation.
To understand why this occurs, consider the case when . We have and . By the Linear rule, we calculate that and . By the Rescale rule, the multiplier is , and thus and . The total contribution of to the output becomes , and the total contribution of to is . This calculation is misleading as it discounts the fact that would be if were 0 - in other words, it ignores a dependency induced between and that comes from canceling out in the nonlinear neuron . A similar failure occurs when ; the Rescale rule results in and . Note that gradients, gradientinput, Guided Backpropagation and integrated gradients would also assign all importance to either or , because for any given input the gradient is zero for one of or (see Appendix C for a detailed calculation).
One way to address this is by treating the positive and negative contributions separately. We again consider the nonlinear neuron . Instead of assuming that and are proportional to and and that (as is done for the Rescale rule), we define them as follows:
In other words, we set to the average impact of after no terms have been added and after has been added, and we set to the average impact of after no terms have been added and after has been added. This can be thought of as the Shapely values of and contributing to .
By considering the impact of the positive terms in the absence of negative terms, and the impact of negative terms in the absence of positive terms, we alleviate some of the issues that arise from positive and negative terms canceling each other out. In the case of Fig. 3, RevealCancel would assign a contribution of to both inputs (see Appendix C for a detailed calculation).
While the RevealCancel rule also avoids the saturation and thresholding pitfalls illustrated in Fig. 1 and Fig. 2, there are some circumstances where we might prefer to use the Rescale rule. Specifically, consider a thresholded ReLU where . If merely indicates noise, we would want to assign contributions of 0 to both and (as done by the Rescale rule) to mitigate the noise. RevealCancel may assign nonzero contributions by considering in the absence of and vice versa.
In the case of softmax or sigmoid outputs, we may prefer to compute contributions to the linear layer preceding the final nonlinearity rather than the final nonlinearity itself. This would be to avoid an attentuation caused by the summation-to-delta property described in Section 3.1. For example, consider a sigmoid output , where
is the logit of the sigmoid function. Assume
, where . When and , the output saturates at very close to and the contributions of and are and respectively. However, when and , the output is still very close to , but the contributions of and are now both . This can be misleading when comparing scores across different inputs because a stronger contribution to the logit would not always translate into a higher DeepLIFT score. To avoid this, we compute contributions to rather than .Adjustments for softmax layers
If we compute contributions to the linear layer preceding the softmax rather than the softmax output, an issue that could arise is that the final softmax output involves a normalization over all classes, but the linear layer before the softmax does not. To address this, we can normalize the contributions to the linear layer by subtracting the mean contribution to all classes. Formally, if is the number of classes, represents the unnormalized contribution to class in the linear layer and represents the normalized contribution, we have:
(5) |
As a justification for this normalization, we note that subtracting a fixed value from all the inputs to the softmax leaves the output of the softmax unchanged.
We train a convolutional neural network on MNIST (LeCun et al., 1999)
using Keras
(Chollet, 2015) to perform digit classification and obtain 99.2% test-set accuracy. The architecture consists of two convolutional layers, followed by a fully connected layer, followed by the softmax output layer (see Appendix Dfor full details on model architecture and training). We used convolutions with stride
instead of pooling layers, which did not result in a drop in performance as is consistent with previous work (Springenberg et al., 2014). For DeepLIFT and integrated gradients, we used a reference input of all zeros.To evaluate importance scores obtained by different methods, we design the following task: given an image that originally belongs to class , we identify which pixels to erase to convert the image to some target class . We do this by finding (where is the score for pixel and class ) and erasing up to 157 pixels (20% of the image) ranked in descending order of for which
. We then evaluate the change in the log-odds score between classes
and for the original image and the image with the pixels erased.As shown in Fig. 4, DeepLIFT with the RevealCancel rule outperformed the other backpropagation-based methods. Integrated gradients (Section 2.2.3) computed numerically over either 5 or 10 intervals produced results comparable to each other, suggesting that adding more intervals would not change the result. Integrated gradients also performed comparably to gradient*input, suggesting that saturation and thresholding failure modes are not common on MNIST data. Guided Backprop discards negative gradients during backpropagation, perhaps explaining its poor performance at discriminating between classes. We also explored using the Rescale rule instead of RevealCancel on various layers and found that it degraded performance (Appendix E).
Next, we compared the importance scoring methods when applied to classification tasks on DNA sequence inputs (strings over the alphabet {A,C,G,T}). The human genome has millions of DNA sequence elements ( 200-1000 in length) containing specific combinations of short functional words to which regulatory proteins (RPs) bind to regulate gene activity. Each RP (e.g. GATA1) has binding affinity to specific collections of short DNA words (motifs) (e.g. GATAA and GATTA). A key problem in computational genomics is the discovery of motifs in regulatory DNA elements that give rise to distinct molecular signatures (labels) which can be measured experimentally. Here, in order to benchmark DeepLIFT and competing methods to uncover predictive patterns in DNA sequences, we design a simple simulation that captures the essence of the motif discovery problem described above.
Background DNA sequences of length 200 were generated by sampling the letters ACGT at each position with probabilities
and respectively. Motif instances were randomly sampled from previously known probabilistic motif models (See Appendix F) of two RPs named GATA1 and TAL1 (Fig. 6a)(Kheradpour & Kellis, 2014), and 0-3 instances of a given motif were inserted at random non-overlapping positions in the DNA sequences. We trained a multi-task neural network with two convolutional layers, global average pooling and one fully-connected layer on 3 binary classification tasks. Positive labeled sequences in task 1 represented “both GATA1 and TAL1 present”, task 2 represented “GATA1 present” and in task 3 represented “TAL1 present”. of sequences had both GATA1 and TAL1 motifs (labeled 111), had only GATA1 (labeled 010), had only TAL1 (labeled 001), and had no motifs (labeled 000). Details of the simulation, network architecture and predictive performance are given in Appendix F. For DeepLIFT and integrated gradients, we used a reference input that had the expected frequencies of ACGT at each position (i.e. we set the ACGT channel axis to ; see Appendix J for results using shuffled sequences as a reference). For fair comparison, this reference was also used for gradientinput and Guided Backpropinput (“input” is more accurately called input where measured w.r.t the reference). For DNA sequence inputs, we found Guided Backpropinput performed better than vanilla Guided Backprop; thus, we used the former.Given a particular subsequence, it is possible to compute the log-odds score that the subsequence was sampled from a particular motif vs. originating from the background distribution of ACGT. To evaluate different importance-scoring methods, we found the top 5 matches (as ranked by their log-odds score) to each motif for each sequence from the test set, as well as the total importance allocated to the match by different importance-scoring methods for each task. The results are shown in Fig. 5 (for TAL1) and Appendix E (for GATA1). Ideally, we expect an importance scoring method to show the following properties: (1) high scores for TAL1 motifs on task 2 and (2) low scores for TAL1 on task 1, with (3) higher scores corresponding to stronger log-odds matches; analogous pattern for GATA1 motifs (high for task 1, low for task 2); (4) high scores for both TAL1 and GATA1 motifs for task 0, with (5) higher scores on sequences containing both kinds of motifs vs. sequences containing only one kind (revealing cooperativity; corresponds to red dots lying above green dots in Fig. 5).
We observe Guided Backpropinput fails (2) by assigning positive importance to TAL1 on task 1 (see Appendix H for an example sequence). It fails property (4) by failing to identify cooperativity in task 0 (red dots overlay green dots). Both Guided Backpropinput and gradientinput show suboptimal behavior regarding property (3), in that there is a sudden increase in importance when the log-odds score is around 7, but little differentiation at higher log-odds scores (by contrast, the other methods show a more gradual increase). As a result, Guided Backpropinput and gradientinput can assign unduly high importance to weak motif matches (Fig. 6). This is a practical consequence of the thresholding problem from Fig. 2. The large discontinuous jumps in gradient also result in inflated scores (note the scale on the y-axes) relative to other methods.
We explored three versions of DeepLIFT: Rescale rule at all nonlinearities (DeepLIFT-Rescale), RevealCancel at all nonlinearities (DeepLIFT-RevealCancel), and Rescale rule at the two convolutional layers with RevealCancel at the fully connected layer (DeepLIFT-fc-RC-conv-RS). In contrast to the results on MNIST, we found that DeepLIFT-fc-RC-conv-RS reduced noise relative to pure RevealCancel. We think this is because of the noise-suppression property discussed at the end of Section 3.5.3; if the convolutional layers act like motif detectors, the input to convolutional neurons that do not fire may just represent noise and importance should not be propagated to them (see Fig. 6 for an example sequence).
Gradientinp, integrated gradients and DeepLIFT-Rescale occasionally miss relevance of TAL1 for Task 0 (Fig. 5b), which is corrected by using RevealCancel on the fully connected layer (see example sequence in Fig. 6). Note that the RevealCancel scores seem to be tiered. As illustrated in Appendix I, this is related to having multiple instances of a given motif in a sequence (eg: when there are multiple TAL1 motifs, the importance assigned to the presence of TAL1 is distributed across all the motifs).
We have presented DeepLIFT, a novel approach for computing importance scores based on explaining the difference of the output from some ‘reference’ output in terms of differences of the inputs from their ‘reference’ inputs. Using the difference-from-reference allows information to propagate even when the gradient is zero (Fig. 1
), which could prove especially useful in Recurrent Neural Networks where saturating activations like sigmoid or tanh are popular. DeepLIFT avoids placing potentially misleading importance on bias terms (in contrast to gradient*input - see
Fig. 2). By allowing separate treatment of positive and negative contributions, the DeepLIFT-RevealCancel rule can identify dependencies missed by other methods (Fig. 3). Open questions include how to apply DeepLIFT to RNNs, how to compute a good reference empirically from the data, and how best to propagate importance through ‘max’ operations (as in Maxout or Maxpooling neurons) beyond simply using the gradients.The appendix can be downloaded at:
https://goo.gl/T114x4
AS & PG conceptualized DeepLIFT. AS implemented DeepLIFT. AS ran experiments on MNIST. AS & PG ran experiments on genomic data. AK provided guidance and feedback. AS, PG and AK wrote the manuscript.
We thank Anna Shcherbina for early experiments applying DeepLIFT to image data and beta-testing.
On Pixel-Wise explanations for Non-Linear classifier decisions by Layer-Wise relevance propagation.
PLoS One, 10(7):e0130140, 10 July 2015.The mnist database of handwritten digits.
http://yann.lecun.com/exdb/mnist/, 1999.
Comments
There are no comments yet.