signxai.tf_signxai.methods_impl package

Subpackages

Submodules

signxai.tf_signxai.methods_impl.grad_cam module

Title: Grad-CAM class activation visualization Author: [fchollet](https://twitter.com/fchollet) Date created: 2020/04/26 Last modified: 2021/03/07 Description: How to obtain a class activation heatmap for an image classification model.

Adapted from Deep Learning with Python (2017).

class signxai.tf_signxai.methods_impl.grad_cam.GradCAM(model, last_conv_layer_name)[source]

Bases: object

Grad-CAM implementation for TensorFlow models.

Grad-CAM uses the gradients of a target concept flowing into the final convolutional layer to produce a coarse localization map highlighting important regions in the image for prediction.

__init__(model, last_conv_layer_name)[source]

Initialize GradCAM.

Parameters:
  • model – TensorFlow model

  • last_conv_layer_name – Name of the last convolutional layer

compute_heatmap(x, target_class=None, resize=True)[source]

Compute Grad-CAM heatmap.

Parameters:
  • x – Input tensor or array (must include batch dimension)

  • target_class – Target class index (None for argmax)

  • resize – Whether to resize the heatmap to input size

Returns:

Grad-CAM heatmap

signxai.tf_signxai.methods_impl.grad_cam.calculate_grad_cam_relevancemap_timeseries(x, model, last_conv_layer_name, neuron_selection=None, resize=True)[source]

Calculate Grad-CAM relevance map specifically adapted for time series data.

Parameters:
  • x – Input data, expected shape: (batch_size, time_steps, channels)

  • model – Model to analyze

  • last_conv_layer_name – Name of the last convolutional layer

  • neuron_selection – Index of neuron to analyze (None for predicted class)

  • resize – Whether to resize heatmap to input size

Returns:

Relevance map with shape matching the input if resize=True

signxai.tf_signxai.methods_impl.grad_cam.calculate_grad_cam_relevancemap(x, model, last_conv_layer_name, neuron_selection=None, resize=False, **kwargs)[source]

signxai.tf_signxai.methods_impl.guided_backprop module

Source: https://github.com/Crispy13/crispy

signxai.tf_signxai.methods_impl.guided_backprop.build_guided_model(model)[source]

Builds guided model

signxai.tf_signxai.methods_impl.guided_backprop.guided_backprop_on_guided_model(model_no_softmax, img, layer_name)[source]

Returns guided backpropagation image.

Parameters:
  • model_no_softmax (a keras model object)

  • img (an img to inspect with guided backprop.)

  • layer_name (a string) – a layer name for calculating gradients.

signxai.tf_signxai.methods_impl.signed module

signxai.tf_signxai.methods_impl.signed.calculate_sign_mu(x, mu=None, vlow=-1, vhigh=1, **kwargs)[source]

Module contents