@@ -19,7 +19,8 @@ index = 10
19
19
x, _ = MNIST (Float32, :test )[10 ]
20
20
input = reshape (x, 28 , 28 , 1 , :);
21
21
22
- # ## Custom LRP composites
22
+ # ## LRP composites
23
+ # ### Custom composites
23
24
# When creating an LRP-analyzer, we can assign individual rules to each layer.
24
25
# The array of rules has to match the length of the Flux chain:
25
26
rules = [
@@ -49,11 +50,11 @@ heatmap(input, analyzer)
49
50
# To obtain the same set of rules as in the previous example, we can define
50
51
composite = Composite (
51
52
ZeroRule (), # default rule
52
- GlobalRuleMap (
53
+ GlobalTypeRule (
53
54
Conv => GammaRule (), # apply GammaRule on all convolutional layers
54
55
MaxPool => EpsilonRule (), # apply EpsilonRule on all pooling-layers
55
56
),
56
- FirstRule (ZBoxRule (0.0f0 , 1.0f0 )), # apply ZBoxRule on the first layer
57
+ FirstLayerRule (ZBoxRule (0.0f0 , 1.0f0 )), # apply ZBoxRule on the first layer
57
58
)
58
59
59
60
analyzer = LRP (model, composite) # construct LRP analyzer from composite
@@ -63,24 +64,31 @@ heatmap(input, analyzer)
63
64
analyzer. rules # show rules
64
65
65
66
# ### Composite primitives
66
- # The following sets of primitives can used to construct a [`Composite`](@ref).
67
+ # The following [Composite primitives](@ref composite_primitive_api) can used to construct a [`Composite`](@ref).
67
68
#
68
69
# To apply a single rule, use:
69
70
# * [`LayerRule`](@ref) to apply a rule to the `n`-th layer of a model
70
- # * [`GlobalRule`](@ref) to apply a rule to all layers of a model
71
- # * [`RangeRule`](@ref) to apply a rule to a positional range of layers of a model
72
- # * [`FirstRule `](@ref) to apply a rule to the first layer of a model
73
- # * [`LastRule `](@ref) to apply a rule to the last layer of a model
71
+ # * [`GlobalRule`](@ref) to apply a rule to all layers
72
+ # * [`RangeRule`](@ref) to apply a rule to a positional range of layers
73
+ # * [`FirstLayerRule `](@ref) to apply a rule to the first layer
74
+ # * [`LastLayerRule `](@ref) to apply a rule to the last layer
74
75
#
75
- # To apply a set of rules to multiple layers, use:
76
- # * [`GlobalRuleMap`](@ref) to apply a dictionary that maps layer types to LRP-rules
77
- # * [`RangeRuleMap`](@ref) for a `RuleMap` on generalized ranges
78
- # * [`FirstNRuleMap`](@ref) for a `RuleMap` on the first `n` layers of a model
79
- # * [`LastNRuleMap`](@ref) for a `RuleMap` on the last `n` layers
76
+ # To apply a set of rules to layers based on their type, use:
77
+ # * [`GlobalTypeRule`](@ref) to apply a dictionary that maps layer types to LRP-rules
78
+ # * [`RangeTypeRule`](@ref) for a `TypeRule` on generalized ranges
79
+ # * [`FirstLayerTypeRule`](@ref) for a `TypeRule` on the first layer of a model
80
+ # * [`LastLayerTypeRule`](@ref) for a `TypeRule` on the last layer
81
+ # * [`FirstNTypeRule`](@ref) for a `TypeRule` on the first `n` layers
82
+ # * [`LastNTypeRule`](@ref) for a `TypeRule` on the last `n` layers
80
83
#
81
84
# Primitives are called sequentially in the order the `Composite` was created with
82
85
# and overwrite rules specified by previous primitives.
83
86
87
+ # ### Default composites
88
+ # A list of implemented default composites can be found under
89
+ # [Default composites](@ref default_composite_api) in the API reference, e.g. [`EpsilonPlusFlat`](@ref):
90
+ EpsilonPlusFlat ()
91
+
84
92
# ## Custom LRP rules
85
93
# Let's define a rule that modifies the weights and biases of our layer on the forward pass.
86
94
# The rule has to be of type `AbstractLRPRule`.
0 commit comments