SquaredDifferenceScoring

class xaitk_saliency.impls.gen_classifier_conf_sal.squared_difference_scoring.SquaredDifferenceScoring

This saliency implementation transforms black-box confidence predictions from a classification-style network into saliency heatmaps. This should require a sequence of classification scores predicted on the reference image, a number of classification scores predicted on perturbed images, as well as the masks of the reference image perturbations (as would be output from a PerturbImage implementation).

This implementation uses the squared difference of the reference scores and the perturbed scores to compute the saliency maps. This gives an indication of general saliency without distinguishing between positive and negative. The resulting maps are normalized between the range [0,1].

Based on Greydanus et. al: https://arxiv.org/abs/1711.00138

Methods

from_config

Instantiate a new instance of this class given the configuration JSON-compliant dictionary encapsulating initialization arguments.

generate

Generate saliency heatmaps from black-box confidence predictions

get_config

Get the configuration dictionary of the SquaredDifferenceScoring instance.

get_default_config

Generate and return a default configuration dictionary for this class.

get_impls

Discover and return a set of classes that implement the calling class.

is_usable

Check whether this class is available for use.

generate(reference: ndarray, perturbed: ndarray, perturbed_masks: ndarray) ndarray

Generate saliency heatmaps from black-box confidence predictions

Parameters:
  • reference – np.ndarray Reference predictions from the reference image

  • perturbed – np.ndarray Perturbed predictions from the reference image

  • perturbed_masks – np.ndarray Perturbation masks numpy.ndarray over the reference image.

Returns:

np.ndarray Generated visual saliency heatmap.

get_config() dict

Get the configuration dictionary of the SquaredDifferenceScoring instance.

Returns:

dict[str, Any]: Configuration dictionary.