trw.train.integrated_gradients

Module Contents

Classes

IntegratedGradients

Implementation of Integrated gradients, a method of attributing the prediction of a deep network

Functions

is_feature_metadata(name, value)

Return True is a feature name/value should be considered as metadata

Attributes

logger

trw.train.integrated_gradients.logger
trw.train.integrated_gradients.is_feature_metadata(name, value)

Return True is a feature name/value should be considered as metadata

class trw.train.integrated_gradients.IntegratedGradients(model, steps=100, baseline_inputs=None, use_output_as_target=False, post_process_output=guided_back_propagation.post_process_output_id)
Implementation of Integrated gradients, a method of attributing the prediction of a deep network

to its input features.

This is implementing the paper Axiomatic Attribution for Deep Networks, Mukund Sundararajan, Ankur Taly, Qiqi Yan as described in https://arxiv.org/abs/1703.01365

__call__(self, inputs, target_class_name, target_class=None)

Generate the guided back-propagation gradient

Parameters
  • inputs – a tensor or dictionary of tensors. Must have require_grads for the inputs to be explained

  • target_class – the index of the class to explain the decision. If None, the class output will be used

  • target_class_name

    the output node to be used. If None: * if model output is a single tensor then use this as target output

    • else it will use the first OutputClassification output

Returns

a tuple (output_name, dictionary (input, integrated gradient))