RISEStack

class xaitk_saliency.impls.gen_image_classifier_blackbox_sal.rise.RISEStack(n: int, s: int, p1: float, seed: int | None = None, threads: int = 0, debiased: bool = True)

Encapsulation of the perturbation-occlusion method using specifically the RISE implementations of the component algorithms.

This more specifically encapsulates the original RISE method as presented in their paper and code. See references in the RISEGrid and RISEScoring documentation.

This implementation shares the p1 probability with the internal RISEScoring instance use, effectively causing this implementation to utilize debiased RISE.

Methods

from_config

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

generate

Generates per-class visual saliency heatmaps for some classifier black box over some image of interest.

get_config

Get the configuration dictionary of the RISEStack 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.

__init__(n: int, s: int, p1: float, seed: int | None = None, threads: int = 0, debiased: bool = True) None

Initialization of the perturbation-occlusion method using specifically the RISE implementations of the component algorithms.

Parameters:
  • n – Number of random masks used in the algorithm. E.g. 1000.

  • s – Spatial resolution of the small masking grid. E.g. 8. Assumes square grid.

  • p1 – Probability of the grid cell being set to 1 (otherwise 0). This should be a float value in the [0, 1] range. E.g. 0.5.

  • seed – A seed to pass into the constructed random number generator to allow for reproducibility

  • threads – The number of threads to utilize when generating masks. If this is <=0 or None, no threading is used and processing is performed in-line serially.

  • debiased – If we should pass the provided debiasing parameter to the RISE saliency map generation algorithm. See the RISEScoring() documentation for more details on debiasing.

property fill: int | Sequence[int] | None

Gets the fill value

get_config() dict[str, Any]

Get the configuration dictionary of the RISEStack instance.

Returns:

dict[str, Any]: Configuration dictionary.