pulsatrix 1.1.0
Loading...
Searching...
No Matches
pulsatrix::lrp_composite Namespace Reference

Zennit 1.0.0's composite presets (zennit.composites), mapped onto pulsatrix modules by type: LinearModule = torch Linear, Conv2DModule = torch Conv2d; every other module gets the epsilon rule (the pass-through modules – ReLU, Flatten, Dropout, MaxPool – ignore it, as Zennit's Pass rule / plain gradient does). More...

Namespaces

namespace  detail
 

Functions

LRPRuleConfig epsilon_with_conv (float epsilon, const LRPRuleConfig &conv)
 Epsilon for this module, and conv for every Conv2D inside it (residual blocks, sequences): Zennit's by-type mapping carried into nested modules.
 
LRPComposite epsilon_plus (float epsilon=1e-6f)
 Zennit EpsilonPlus: Epsilon for Linear, ZPlus (AlphaBeta 1, 0) for Conv2D, including convolutions inside residual blocks and other containers.
 
LRPComposite epsilon_alpha2_beta1 (float epsilon=1e-6f)
 Zennit EpsilonAlpha2Beta1: Epsilon for Linear, AlphaBeta(2, 1) for Conv2D, nested ones included.
 
LRPComposite epsilon_gamma_box (float low, float high, float gamma=0.25f, float epsilon=1e-6f)
 Zennit EpsilonGammaBox: ZBox(low, high) for the first Conv2D layer (lowest index), Gamma(gamma) for every other Conv2D, nested ones included, Epsilon for every Linear.
 

Detailed Description

Zennit 1.0.0's composite presets (zennit.composites), mapped onto pulsatrix modules by type: LinearModule = torch Linear, Conv2DModule = torch Conv2d; every other module gets the epsilon rule (the pass-through modules – ReLU, Flatten, Dropout, MaxPool – ignore it, as Zennit's Pass rule / plain gradient does).

Note
Every Epsilon entry sets epsilon_bias_in_denominator = true: Zennit's Epsilon rule puts the bias in z, so matching Zennit numerically requires it (this codebase's own default epsilon rule leaves the bias out to be conservative).

Function Documentation

◆ epsilon_alpha2_beta1()

LRPComposite pulsatrix::lrp_composite::epsilon_alpha2_beta1 ( float  epsilon = 1e-6f)
inline

Zennit EpsilonAlpha2Beta1: Epsilon for Linear, AlphaBeta(2, 1) for Conv2D, nested ones included.

◆ epsilon_gamma_box()

LRPComposite pulsatrix::lrp_composite::epsilon_gamma_box ( float  low,
float  high,
float  gamma = 0.25f,
float  epsilon = 1e-6f 
)
inline

Zennit EpsilonGammaBox: ZBox(low, high) for the first Conv2D layer (lowest index), Gamma(gamma) for every other Conv2D, nested ones included, Epsilon for every Linear.

Note
The first Conv2D must be a top-level module, as it is in ResNet and VGG: one nested in a container before any top-level Conv2D gets Gamma.
As in Zennit 1.0.0, whose first_map holds only Convolution: a Linear is never ZBox'd, even when it is the first layer, so on a Conv2D-free network this preset is Epsilon on every layer (checked against Zennit in tests/lrp_reference_test.cpp).
Remembers the first Conv2D it has seen since the last index-0 call (see LRPComposite's calling order).

◆ epsilon_plus()

LRPComposite pulsatrix::lrp_composite::epsilon_plus ( float  epsilon = 1e-6f)
inline

Zennit EpsilonPlus: Epsilon for Linear, ZPlus (AlphaBeta 1, 0) for Conv2D, including convolutions inside residual blocks and other containers.

◆ epsilon_with_conv()

LRPRuleConfig pulsatrix::lrp_composite::epsilon_with_conv ( float  epsilon,
const LRPRuleConfig &  conv 
)
inline

Epsilon for this module, and conv for every Conv2D inside it (residual blocks, sequences): Zennit's by-type mapping carried into nested modules.