Callbacks

class tf_keras_vis.activation_maximization.callbacks.Callback[source]

Bases: ABC

Abstract class for defining callbacks.

__call__(i, values, grads, scores, model_outputs, **kwargs)[source]

This function will be called after updating input values by gradient descent in tf_keras_vis.activation_maximization.ActivationMaximization.__call__().

Parameters:
  • i – The current number of optimizer iteration.

  • values – A list of tf.Tensor that indicates current values.

  • grads – A list of tf.Tensor that indicates the gradients with respect to model input.

  • scores – A list of tf.Tensor that indicates score values with respect to each the model outputs.

  • model_outputs – A list of tf.Tensor that indicates the model outputs.

  • regularizations – A list of tuples of (str, tf.Tensor) that indicates the regularizer values.

  • overall_score – A list of tf.Tensor that indicates the overall scores that includes the scores and regularization values.

on_begin(**kwargs)[source]

Called at the begin of optimization process.

Parameters:

kwargs – The parameters that was passed to tf_keras_vis.activation_maximization.ActivationMaximization.__call__().

on_end()[source]

Called at the end of optimization process.

class tf_keras_vis.activation_maximization.callbacks.GifGenerator2D(path)[source]

Bases: Callback

Callback to construct a gif of optimized image.

Parameters:

path – The file path to save gif.

class tf_keras_vis.activation_maximization.callbacks.PrintLogger(*args, **kwargs)[source]

Bases: Callback

Callback to print values during optimization.

Warning

This class is now deprecated! Please use tf_keras_vis.activation_maximization.callbacks.Progress instead.

Parameters:

interval – An integer that indicates the interval of printing. Defaults to 10.

on_begin(**kwargs)

Called at the begin of optimization process.

Parameters:

kwargs – The parameters that was passed to tf_keras_vis.activation_maximization.ActivationMaximization.__call__().

on_end()

Called at the end of optimization process.

class tf_keras_vis.activation_maximization.callbacks.Progress[source]

Bases: Callback

Callback to print values during optimization.

on_end()

Called at the end of optimization process.