morphoclass.xai.grad_cam_on_models module

Explain model layers using GradCam.

morphoclass.xai.grad_cam_on_models.get_edges_colors_based_on_barcode_colors(tree, colors)

Collect colors for edges based on barcode colors.

Parameters
  • tree (tmd.Tree.Tree) – Morphology tree used to create barcode.

  • colors (list_like) – List of barcode colors.

Returns

color_edges – List of edge colors.

Return type

list_like

morphoclass.xai.grad_cam_on_models.grad_cam_cnn_model(model, dataset, sample_id)

Explain CNN model.

Plot with feature maps after each feature extractor layer. Starting from original image to the last feature extractor layer. Only one morphology sample is visualized.

Parameters
Returns

fig – Figure with explainable plots.

Return type

matplotlib.figure.Figure

morphoclass.xai.grad_cam_on_models.grad_cam_gnn_model(model, dataset, sample_id)

Explain GNN model.

Plot with two rows:

  • Original graph and graph with GradCam values within the nodes.

  • Heatmap of the original graph (zero-values) and heatmap of the GradCam values on the graph.

Only one morphology sample is visualized.

Parameters
Returns

fig – Figure with explainable plots.

Return type

matplotlib.figure.Figure

morphoclass.xai.grad_cam_on_models.grad_cam_perslay_model(model, dataset, sample_id)

Explain PersLay model.

Plot with 3 rows:

  • Barcodes: The original barcode and GradCam weighted barcode (colored bar) after each feature extraction layer.

  • Persistence diagrams: The original PD and GradCam weighted PD (colored dot) after each feature extraction layer.

  • Graph: The original graph and GradCam weighted graph (colored edge) after each feature extraction layer.

Parameters
Returns

fig – Figure with explainable plots.

Return type

matplotlib.figure.Figure