Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
L
LRP tutorial
Manage
Activity
Members
Labels
Plan
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Gregoire Montavon
LRP tutorial
Commits
47491350
Commit
47491350
authored
4 years ago
by
Gregoire Montavon
Browse files
Options
Downloads
Patches
Plain Diff
...
parent
0e211fd1
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
README.md
+26
-27
26 additions, 27 deletions
README.md
with
26 additions
and
27 deletions
README.md
+
26
−
27
View file @
47491350
...
...
@@ -137,30 +137,29 @@ only the evidence for the actual class.</p>
R = [None]*L + [A[L]*(T[:,None]==numpy.arange(10))]
<p>
The LRP-0, LRP-$
\e
psilon$, and LRP-$
\g
amma$ rules described in the <a
href="">LRP overview paper
</a>
(Section 10.2.1) for propagating relevance on the
lower layers are special cases of the more general propagation rule
</p>
<p>
The LRP-0, LRP-ϵ, and LRP-γ rules described in the <a
href="https://link.springer.com/chapter/10.1007/978-3-030-28954-6_10">LRP
overview paper
</a>
(Section 10.2.1) for propagating relevance on the lower
layers are special cases of the more general propagation rule
</p>
<img src="http://latex.codecogs.com/svg.latex?R_j =
\s
um_k
\f
rac{a_j
\r
ho(w_{jk})}{
\e
psilon +
\s
um_{0,j} a_j
\r
ho(w_{jk})} R_k">
<p>
(cf. Section 10.2.2), where $
\r
ho$ is a function that transform the weights,
and $
\e
psilon$ is a small positive increment. We define below two helper
functions that perform the weight transformation and the incrementation. In
practice, we would like to apply different rules at different layers (cf.
Section 10.3). Therefore, we also give the layer index "
<code>
l
</code>
" as
argument to these functions.
</p>
<p>
(cf. Section 10.2.2), where ρ is a function that transform the weights, and ϵ
is a small positive increment. We define below two helper functions that perform
the weight transformation and the incrementation. In practice, we would like to
apply different rules at different layers (cf. Section 10.3). Therefore, we also
give the layer index "
<code>
l
</code>
" as argument to these functions.
</p>
def rho(w,l): return w + [None,0.1,0.0,0.0][l] * numpy.maximum(0,w)
def incr(z,l): return z + [None,0.0,0.1,0.0][l] * (z**2).mean()**.5+1e-9
<p>
In particular, these functions and the layer they receive as a parameter let
us reduce the general rule to LRP-0 for the top-layer, to LRP-$
\e
psilon$ with
$
\e
psilon = 0.1
\,\t
ext{std}$ for the layer just below, and to LRP-$
\g
amma$ with
$
\g
amma=0.1$ for the layer before. We now come to the practical implementation
of this general rule. It can be decomposed as a sequence of four
computations:
</p>
us reduce the general rule to LRP-0 for the top-layer, to LRP-ϵ with ϵ = 0.1std
for the layer just below, and to LRP-γ with γ=0.1 for the layer before. We now
come to the practical implementation of this general rule. It can be decomposed
as a sequence of four computations:
</p>
<p>
<img src="http://latex.codecogs.com/svg.latex?
...
...
@@ -192,20 +191,21 @@ layers, and at each layer, applying this sequence of computations.</p>
<p>
Note that the loop above stops one layer before reaching the pixels. To
propagate relevance scores until the pixels, we need to apply an alternate
propagation rule that properly handles pixel values received as input (cf.
Section 10.3.2). In particular, we apply for this layer the
$z^
\m
athcal{B}$-rule
given
by:
</p>
Section 10.3.2). In particular, we apply for this layer the
zB-rule given
by:
</p>
<img src="http://latex.codecogs.com/svg.latex?
R_i =
\s
um_j
\f
rac{a_i w_{ij} - l_i w_{ij}^+ - h_i w_{ij}^-}{
\s
um_{i} a_i w_{ij}
-
l_i w_{ij}^+ - h_i w_{ij}^-} R_j
">
<p>
In this rule, $l_i$ and $h_i$ are the lower and upper bounds of pixel values,
i.e. "-1" and "+1", and $(
\c
dot)^+$ and $(
\c
dot)^-$ are shortcut notations for
$
\m
ax(0,
\c
dot)$ and $
\m
in(0,
\c
dot)$. The $z^
\m
athcal{B}$-rule can again be
implemented with a four-step procedure similar to the one used in the layers
above. Here, we need to create two copies of the weights, and also create arrays
of pixel values set to $l_i$ and $h_i$ respectively:
</p>
<p>
In this rule,
<i>
l
<sub>
i
</sub></i>
and
<i>
h
<sub>
i
</sub></i>
are the lower and
upper bounds of pixel values, i.e. "-1" and "+1", and (·)
<sup>
+
</sup>
and
(·)
<sup>
–
</sup>
are shortcut notations for max(0,·) and min(0,·). The zB-rule
can again be implemented with a four-step procedure similar to the one used in
the layers above. Here, we need to create two copies of the weights, and also
create arrays of pixel values set to
<i>
l
<sub>
i
</sub></i>
and
<i>
h
<sub>
i
</sub></i>
respectively:
</p>
w = W[0]
...
...
@@ -348,7 +348,7 @@ c_j = \big[\nabla~\big({\textstyle \sum_k}~z_k(\boldsymbol{a}) \cdot
s_k
\b
ig)
\b
ig]_j
">
<p>
where
$s_k$
is treated as constant.
</p>
<p>
where
<i>
s
<sub>
k
</sub></i>
is treated as constant.
</p>
<p><b>
Pooling layers:
</b>
It is suggested in Section 10.3.2 of the paper to
treat max-pooling layers as average pooling layers in the backward pass.
...
...
@@ -411,10 +411,9 @@ dimensional maps are shown for a selection of VGG-16 layers.
<p>
We observe that the explanation becomes increasingly resolved spatially. Note
that, like for the MNIST example, we have stopped the propagation procedure one
layer before the pixels because the rule we have used is not applicable to pixel
layers. Like for the MNIST case, we need ot apply the pixel-specific <img
src="http://latex.codecogs.com/svg.latex?
\t
ext z^
\m
athcal{B}">-rule for this
last layer. This rule can again be implemented in terms of forward passes and
gradient computations.
</p>
layers. Like for the MNIST case, we need ot apply the pixel-specific zB-rule for
this last layer. This rule can again be implemented in terms of forward passes
and gradient computations.
</p>
A[0] = (A[0].data).requires_grad_(True)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment