tdhook.attribution.lrp_helpers.layers#

LRP-compatible layers.

This code is adapted from the Zennit library (LGPL-3.0) Original source: chr5tphr/zennit

Classes#

Sum

Compute the sum along an axis.

Module Contents#

class tdhook.attribution.lrp_helpers.layers.Sum(dim=-1)[source]#

Bases: torch.nn.Module

Compute the sum along an axis.

Parameters:

dim (int) – Dimension over which to sum.

dim = -1[source]#
forward(input)[source]#

Computes the sum along a dimension.

Parameters:

input (torch.Tensor) – The input on which to sum.

Returns:

The resulting tensor summed along dimension dim.

Return type:

torch.Tensor