signxai.tf_signxai.methods_impl.innvestigate.tools package

Submodules

signxai.tf_signxai.methods_impl.innvestigate.tools.pattern module

signxai.tf_signxai.methods_impl.innvestigate.tools.pattern.get_active_neuron_io(layer, active_node_indices, return_i=True, return_o=True, do_activation_search=False)[source]

Returns the neuron-wise input output for the passed layer. This is done while taking care of only considering layer nodes that are listed as active.

Starting from the passed layer this functions returns the first layer with an activation upstream in the model, if do_activation_search is an execution list. Otherwise the current layer’s output is returned.

signxai.tf_signxai.methods_impl.innvestigate.tools.pattern.get_pattern_class(pattern_type)[source]
class signxai.tf_signxai.methods_impl.innvestigate.tools.pattern.BasePattern(model, layer, model_tensors=None, execution_list=None)[source]

Bases: object

Interface for pattern objects used to compute patterns by the PatternComputer class.

The basic work-flow is that a pattern computes statistics for the passed layer, which are then used to compute the final pattern.

__init__(model, layer, model_tensors=None, execution_list=None)[source]
has_pattern()[source]
stats_from_batch()[source]

Creates statistics while the PatternComputer passes the dataset once.

compute_pattern()[source]

Computes the pattern after computing the statistics.

class signxai.tf_signxai.methods_impl.innvestigate.tools.pattern.DummyPattern(model, layer, model_tensors=None, execution_list=None)[source]

Bases: BasePattern

Computes a dummy pattern for test purposes.

get_stats_from_batch()[source]
compute_pattern()[source]

Computes the pattern after computing the statistics.

class signxai.tf_signxai.methods_impl.innvestigate.tools.pattern.LinearPattern(model, layer, model_tensors=None, execution_list=None)[source]

Bases: BasePattern

get_stats_from_batch()[source]
compute_pattern()[source]

Computes the patterns according to the formula in the paper.

class signxai.tf_signxai.methods_impl.innvestigate.tools.pattern.ReLUPositivePattern(model, layer, model_tensors=None, execution_list=None)[source]

Bases: LinearPattern

class signxai.tf_signxai.methods_impl.innvestigate.tools.pattern.ReLUNegativePattern(model, layer, model_tensors=None, execution_list=None)[source]

Bases: LinearPattern

class signxai.tf_signxai.methods_impl.innvestigate.tools.pattern.PatternComputer(model, pattern_type='linear', compute_layers_in_parallel=True, gpus=None)[source]

Bases: object

Pattern computer.

Computes a pattern for each layer with a kernel of a given model.

Parameters:
  • model – A Keras model.

  • pattern_type – A string or a tuple of strings. Valid types are ‘linear’, ‘relu’, ‘relu.positive’, ‘relu.negative’.

  • compute_layers_in_parallel – Not supported yet. Compute all patterns at once. Otherwise computer layer after layer.

  • gpus – Not supported yet. Gpus to use.

__init__(model, pattern_type='linear', compute_layers_in_parallel=True, gpus=None)[source]
compute(X, batch_size=32, verbose=0)[source]

Compute and return the patterns for the model and the data X.

Parameters:
  • X – Data to compute patterns.

  • batch_size – Batch size to use.

  • verbose – As for keras model.fit.

compute_generator(generator, **kwargs)[source]

Compute and return the patterns for the model and the data X.

Parameters:
  • generator – Data to compute patterns.

  • kwargs – Same as for keras model.fit_generator.

signxai.tf_signxai.methods_impl.innvestigate.tools.perturbate module

Module contents