IBA.pytorch_readout¶
-
class
IBAReadout
(attach_layer, readout_layers, model, estimator_type=None, **kwargs)[source]¶ Bases:
IBA.pytorch.IBA
The Readout Bottleneck is an extension to yield the alphas for the IBA bottleneck from a readout network. The readout network is trained on intermediate feature maps which are obtained by performing a nested forward pass on the model and recording activations.
Major differences to the Per-Sample IBA: * an additional context manager for the nested pass * additional hooks to collect the input and the feature maps in the nested pass * a readout network of three 1x1 conv. layers to yield alpha
-
analyze
(input_t, model, mode='saliency', **kwargs)[source]¶ Use the trained Readout IBA to find relevant regions in the input. The input is passed through the network and the Readout Bottleneck restricts the information flow. The capacity at each pixel is then returned as saliency map, similar to the Per-Sample IBA.
- Parameters
input_t – input image of shape (1, C, H W)
model – the model containing the trained bottleneck
mode – how to post-process the resulting map: ‘saliency’ (default) or ‘capacity’
- Returns
The heatmap of the same shape as the
input_t
.
Additional arguments are ignored.
-