alibi.utils.gradients module
- alibi.utils.gradients.num_grad_batch(func, X, args=(), eps=1e-08)[source]
Calculate the numerical gradients of a vector-valued function (typically a prediction function in classification) with respect to a batch of arrays X.
- Parameters:
func (
Callable
) – Function to be differentiated.X (
ndarray
) – A batch of vectors at which to evaluate the gradient of the function.args (
Tuple
) – Any additional arguments to pass to the function.eps (
Union
[float
,ndarray
]) – Gradient step to use in the numerical calculation, can be a single float or one for each feature.
- Return type:
ndarray
- Returns:
An array of gradients at each point in the batch X.