Whole-model LRP: runs the forward pass, seeds relevance at the chosen output(s), and propagates it to the input through every module's own propagate_relevance() rule.
More...
#include <lrp.hpp>
Whole-model LRP: runs the forward pass, seeds relevance at the chosen output(s), and propagates it to the input through every module's own propagate_relevance() rule.
- Note
- The per-layer rules are the ones each Module implements (see each module's propagate_relevance() doc); either one
config is passed to all of them, or an LRPComposite chooses one per module. A module asked for a rule it does not implement throws (ExplainerContext::relevance_pass) – there is no silent fallback to epsilon. With LRPRuleConfig::epsilon_bias_in_denominator set, bias terms absorb relevance, and the AttnLRP softmax / attention rules do not conserve exactly, so sum(values) matches the seeded total only for conservative stacks. The Attribution's metadata reports both sums.
-
Device-generic: the seed is assembled on the host (one device->host copy of the network output when seeding with output values) and uploaded through
backend, which must be the backend the network's output lives on.
◆ LRP() [1/2]
Uniform rule: every module applies config.
◆ LRP() [2/2]
| pulsatrix::LRP::LRP |
( |
LRPComposite |
composite, |
|
|
std::string |
name = "custom" |
|
) |
| |
|
inlineexplicit |
Per-layer rules from a composite; name is reported as "composite:<name>".
- Exceptions
-
| std::invalid_argument | if composite is empty. |
◆ composite()
The composite, or an empty function for a uniform-rule LRP.
◆ config()
The uniform config (default-constructed when this LRP uses a composite).
◆ epsilon_alpha2_beta1()
| static LRP pulsatrix::LRP::epsilon_alpha2_beta1 |
( |
float |
epsilon = 1e-6f | ) |
|
|
inlinestatic |
◆ epsilon_gamma_box()
| static LRP pulsatrix::LRP::epsilon_gamma_box |
( |
float |
low, |
|
|
float |
high, |
|
|
float |
gamma = 0.25f, |
|
|
float |
epsilon = 1e-6f |
|
) |
| |
|
inlinestatic |
◆ epsilon_plus()
| static LRP pulsatrix::LRP::epsilon_plus |
( |
float |
epsilon = 1e-6f | ) |
|
|
inlinestatic |
◆ explain() [1/2]
Explains the given target(s) / contrast(s).
- Returns
- Attribution{"lrp", relevance (input's shape), metadata}: rule (the uniform rule's name, or "composite:<name>"), rules (each module's rule, comma-separated, forward order), epsilon (the uniform config's), seed, targets, contrasts, relevance_out_sum, relevance_in_sum.
- Exceptions
-
| std::invalid_argument | if the network output isn't rank-2, a target/contrast list has neither 1 nor N entries, an index is out of range, or a row's contrast equals its target (that seed is all zeros and explains nothing), a module does not implement its rule, or a rule's parameters are invalid. |
| std::logic_error | if the context's last forward pass was patched (relevance_pass()). |
◆ explain() [2/2]
Explains target_index for every row, OutputValue seed.
The documentation for this class was generated from the following file: