histocartography.interpretability.grad_cam module

Summary

Classes:

BaseCAM

BaseGraphGradCAMExplainer

GradCAM

Class activation map extraction as in “Grad-CAM: Visual Explanations from Deep Networks via Gradient-based Localization”.

GradCAMpp

Class activation map extraction as in “Grad-CAM++: Improved Visual Explanations for Deep Convolutional Networks”.

GraphGradCAMExplainer

Explain a graph with GradCAM.

GraphGradCAMPPExplainer

Explain a graph with GradCAM++.

class BaseCAM(model: torch.nn.modules.module.Module, conv_layers: List[str])[source]

Bases: object

__init__(model: torch.nn.modules.module.Module, conv_layers: List[str])None[source]

BaseCAM constructor. :param model: Input model. :type model: torch.nn.Module :param conv_layer: List of tensor names to compute activations on. :type conv_layer: List[str]

clear_hooks()[source]

Clear model hooks.

class GradCAM(model: torch.nn.modules.module.Module, conv_layers: List[str])[source]

Bases: histocartography.interpretability.grad_cam.BaseCAM

Class activation map extraction as in “Grad-CAM: Visual Explanations from Deep Networks via Gradient-based Localization”.

class GradCAMpp(model: torch.nn.modules.module.Module, conv_layers: List[str])[source]

Bases: histocartography.interpretability.grad_cam.BaseCAM

Class activation map extraction as in “Grad-CAM++: Improved Visual Explanations for Deep Convolutional Networks”.

class BaseGraphGradCAMExplainer(gnn_layer_name: Optional[List[str]] = None, gnn_layer_ids: Optional[List[str]] = None, **kwargs)[source]

Bases: histocartography.interpretability.base_explainer.BaseExplainer

__init__(gnn_layer_name: Optional[List[str]] = None, gnn_layer_ids: Optional[List[str]] = None, **kwargs)None[source]

BaseGraphGradCAMExplainer explainer constructor.

Parameters
  • gnn_layer_name (List[str]) – List of reference layers to use for computing CAM Default to None. If None tries to automatically infer from the model.

  • gnn_layer_ids – (List[str]): List of reference layer IDs to use for computing CAM Default to None. If None tries to automatically infer from the model.

class GraphGradCAMExplainer(gnn_layer_name: Optional[List[str]] = None, gnn_layer_ids: Optional[List[str]] = None, **kwargs)[source]

Bases: histocartography.interpretability.grad_cam.BaseGraphGradCAMExplainer

Explain a graph with GradCAM.

class GraphGradCAMPPExplainer(gnn_layer_name: Optional[List[str]] = None, gnn_layer_ids: Optional[List[str]] = None, **kwargs)[source]

Bases: histocartography.interpretability.grad_cam.BaseGraphGradCAMExplainer

Explain a graph with GradCAM++.

Reference

If you use histocartography in your projects, please cite the following:

@inproceedings{pati2021,
    title = {Hierarchical Graph Representations for Digital Pathology},
    author = {Pushpak Pati, Guillaume Jaume, Antonio Foncubierta, Florinda Feroce, Anna Maria Anniciello, Giosuè Scognamiglio, Nadia Brancati, Maryse Fiche, Estelle Dubruc, Daniel Riccio, Maurizio Di Bonito, Giuseppe De Pietro, Gerardo Botti, Jean-Philippe Thiran, Maria Frucci, Orcun Goksel, Maria Gabrani},
    booktitle = {https://arxiv.org/pdf/2102.11057},
    year = {2021}
}