signxai.tf_signxai.methods_impl.innvestigate.utils package
Subpackages
- signxai.tf_signxai.methods_impl.innvestigate.utils.keras package
- Submodules
- signxai.tf_signxai.methods_impl.innvestigate.utils.keras.backend module
- signxai.tf_signxai.methods_impl.innvestigate.utils.keras.checks module
- signxai.tf_signxai.methods_impl.innvestigate.utils.keras.graph module
get_kernel()get_layer_inbound_count()get_layer_outbound_count()get_layer_neuronwise_io()copy_layer_wo_activation()copy_layer()pre_softmax_tensors()model_wo_softmax()fake_keras_layer()get_model_layers()model_contains()trace_model_execution()get_model_execution_trace()get_model_execution_graph()print_model_execution_graph()get_bottleneck_nodes()get_bottleneck_tensors()
- Module contents
- signxai.tf_signxai.methods_impl.innvestigate.utils.tests package
- Subpackages
- signxai.tf_signxai.methods_impl.innvestigate.utils.tests.cases package
- Submodules
- signxai.tf_signxai.methods_impl.innvestigate.utils.tests.cases.cnn module
- signxai.tf_signxai.methods_impl.innvestigate.utils.tests.cases.helper module
- signxai.tf_signxai.methods_impl.innvestigate.utils.tests.cases.mlp module
- signxai.tf_signxai.methods_impl.innvestigate.utils.tests.cases.special module
- signxai.tf_signxai.methods_impl.innvestigate.utils.tests.cases.trivia module
- Module contents
- signxai.tf_signxai.methods_impl.innvestigate.utils.tests.cases package
- Submodules
- signxai.tf_signxai.methods_impl.innvestigate.utils.tests.dryrun module
- Module contents
- Subpackages
Submodules
signxai.tf_signxai.methods_impl.innvestigate.utils.visualizations module
- signxai.tf_signxai.methods_impl.innvestigate.utils.visualizations.project(X, output_range=(0, 1), absmax=None, input_is_positive_only=False)[source]
Projects a tensor into a value range.
Projects the tensor values into the specified range.
- Parameters:
X – A tensor.
output_range – The output value range.
absmax – A tensor specifying the absmax used for normalizing. Default the absmax along the first axis.
input_is_positive_only – Is the input value range only positive.
- Returns:
The tensor with the values project into output range.
- signxai.tf_signxai.methods_impl.innvestigate.utils.visualizations.heatmap(X, cmap_type='seismic', reduce_op='sum', reduce_axis=-1, alpha_cmap=False, **kwargs)[source]
Creates a heatmap/color map.
Create a heatmap or colormap out of the input tensor.
- Parameters:
X – A image tensor with 4 axes.
cmap_type – The color map to use. Default ‘seismic’.
reduce_op – Operation to reduce the color axis. Either ‘sum’ or ‘absmax’.
reduce_axis – Axis to reduce.
alpha_cmap – Should the alpha component of the cmap be included.
kwargs – Arguments passed on to
project()
- Returns:
The tensor as color-map.
- signxai.tf_signxai.methods_impl.innvestigate.utils.visualizations.graymap(X, **kwargs)[source]
Same as
heatmap()but uses a gray colormap.
- signxai.tf_signxai.methods_impl.innvestigate.utils.visualizations.gamma(X, gamma=0.5, minamp=0, maxamp=None)[source]
Apply gamma correction to an input array X while maintaining the relative order of entries, also for negative vs positive values in X. the fxn firstly determines the max amplitude in both positive and negative direction and then applies gamma scaling to the positive and negative values of the array separately, according to the common amplitude.
- Parameters:
gamma – the gamma parameter for gamma scaling
minamp – the smallest absolute value to consider. if not given assumed to be zero (neutral value for relevance, min value for saliency, …). values above and below minamp are treated separately.
maxamp – the largest absolute value to consider relative to the neutral value minamp if not given determined from the given data.
Module contents
- signxai.tf_signxai.methods_impl.innvestigate.utils.to_list(l)[source]
If not list, wraps parameter into a list.
- class signxai.tf_signxai.methods_impl.innvestigate.utils.BatchSequence(Xs, batch_size=32)[source]
Bases:
SequenceBatch sequence generator.
Take a (list of) input tensors and a batch size and creates a generators that creates a sequence of batches.
- Parameters:
Xs – One or a list of tensors. First axis needs to have same length.
batch_size – Batch size. Default 32.
- class signxai.tf_signxai.methods_impl.innvestigate.utils.TargetAugmentedSequence(sequence, augment_f)[source]
Bases:
SequenceAugments a sequence with a target on the fly.
Takes a sequence/generator and a function that creates on the fly for each batch a target. The generator takes a batch from that sequence, computes the target and returns both.
- Parameters:
sequence – A sequence or generator.
augment_f – Takes a batch and returns a target.
- signxai.tf_signxai.methods_impl.innvestigate.utils.preprocess_images(images, color_coding=None)[source]
Image preprocessing
Takes a batch of images and: * Adjust the color axis to the Keras format. * Fixes the color coding.
- Parameters:
images – Batch of images with 4 axes.
color_coding – Determines the color coding. Can be None, ‘RGBtoBGR’ or ‘BGRtoRGB’.
- Returns:
The preprocessed batch.
- signxai.tf_signxai.methods_impl.innvestigate.utils.postprocess_images(images, color_coding=None, channels_first=None)[source]
Image postprocessing
Takes a batch of images and reverts the preprocessing.
- Parameters:
images – A batch of images with 4 axes.
color_coding – The initial color coding, see
preprocess_images().channels_first – The output channel format.
- Returns:
The postprocessed images.