ceml.backend.tensorflow¶

ceml.backend.tensorflow.costfunctions¶

class ceml.backend.tensorflow.costfunctions.costfunctions.CostFunctionDifferentiableTf(**kwds)

Base class of differentiable cost functions implemented in tensorflow.

grad()

Warning

Do not use this method!

Raises

NotImplementedError

class ceml.backend.tensorflow.costfunctions.costfunctions.DummyCost(**kwds)

Dummy cost function - always returns zero.

score_impl(x)

Applying the cost function to a given input.

Abstract method for computing applying the cost function to a given input x.

Note

All derived classes must implement this method.

class ceml.backend.tensorflow.costfunctions.costfunctions.L1Cost(x_orig, **kwds)

L1 cost function.

score_impl(x)

Applying the cost function to a given input.

Abstract method for computing applying the cost function to a given input x.

Note

All derived classes must implement this method.

class ceml.backend.tensorflow.costfunctions.costfunctions.L2Cost(x_orig, **kwds)

L2 cost function.

score_impl(x)

Applying the cost function to a given input.

Abstract method for computing applying the cost function to a given input x.

Note

All derived classes must implement this method.

class ceml.backend.tensorflow.costfunctions.costfunctions.LMadCost(x_orig, mad, **kwds)

Manhattan distance weighted feature-wise with the inverse median absolute deviation (MAD).

score_impl(x)

Applying the cost function to a given input.

Abstract method for computing applying the cost function to a given input x.

Note

All derived classes must implement this method.

class ceml.backend.tensorflow.costfunctions.costfunctions.NegLogLikelihoodCost(y_target, **kwds)

Negative-log-likelihood cost function.

score_impl(y)

Applying the cost function to a given input.

Abstract method for computing applying the cost function to a given input x.

Note

All derived classes must implement this method.

class ceml.backend.tensorflow.costfunctions.costfunctions.RegularizedCost(penalize_input, penalize_output, C=1.0, **kwds)

Regularized cost function.

score_impl(x)

Applying the cost function to a given input.

Abstract method for computing applying the cost function to a given input x.

Note

All derived classes must implement this method.

class ceml.backend.tensorflow.costfunctions.costfunctions.SquaredError(y_target, **kwds)

Squared error cost function.

score_impl(y)

Computes the loss - squared error.

ceml.backend.tensorflow.optimizer¶

class ceml.backend.tensorflow.optimizer.optimizer.TfOptimizer(**kwds)

Wrapper for a tensorflow optimization algorithm.

The TfOptimizer provides an interface for wrapping an arbitrary tensorflow optimization algorithm (see tf.train.Optimizer) and minimizing a given loss function.

init(model, loss, x, optim, tol=None, max_iter=1, grad_mask=None)

Initializes all parameters.

Parameters
• model (callable or instance of tf.keras.Model) – The model that is to be used.

• loss (instance of ceml.backend.tensorflow.costfunctions.RegularizedCost) – The loss that has to be minimized.

• x (numpy.ndarray) – The starting value of x - usually this is the original input whose prediction has to be explained..

• optim (instance of tf.train.Optimizer) – Optimizer for minimizing the loss.

• tol (float, optional) –

Tolerance for termination.

The default is 0.0

• max_iter (int, optional) –

Maximum number of iterations.

The default is 1.