raise ValueError(Model has not been fitted. Run function `fit(x, y)` of classifier first or provide a
fitted model.)
nb_samples = x.shape[0]
if label is None:
// Compute the gradients w.r.t all classses
label = np.ones(shape=(nb_samples, self.nb_classes))
elif isinstance(label, (int, np.integer)):
// Compute the gradients only w.r.t. the provided label
label = [label] * nb_samples
label = to_categorical(labels=label, nb_classes=self.nb_classes)
elif (isinstance(label, list) and len(label) == nb_samples) or isinstance(label,
np.ndarray) and label.shape == (nb_samples,):
// For each sample, compute the gradients w.r.t. the indicated target class (possibly distinct)
label = to_categorical(labels=label, nb_classes=self.nb_classes)
else:
raise TypeError("Unrecognized type for argument `label` with type " + str(type(label)))
// Apply preprocessing