]
def __init__(
self,
classifier: ClassifierGradients,
confidence: float = 0.0,
targeted: bool = False,
learning_rate: float = 0.01,
max_iter: int = 10,
max_halving: int = 5,
max_doubling: int = 5,
eps: float = 0.3,
batch_size: int = 128,
) -> None:
Create a Carlini L_Inf attack instance.
:param classifier: A trained classifier.
:param confidence: Confidence of adversarial examples: a higher value produces examples that are farther away,
from the original input, but classified with higher confidence as the target class.
:param targeted: Should the attack target one specific class.
:param learning_rate: The initial learning rate for the attack algorithm. Smaller values produce better
results but are slower to converge.
:param max_iter: The maximum number of iterations.
:param max_halving: Maximum number of halving steps in the line search optimization.
:param max_doubling: Maximum number of doubling steps in the line search optimization.
:param eps: An upper bound for the L_0 norm of the adversarial perturbation.
:param batch_size: Size of the batch on which adversarial samples are generated.
super(CarliniLInfMethod, self).__init__(classifier)
self.confidence = confidenceself.targeted = targetedself.learning_rate = learning_rateself.max_iter = max_iterself.max_halving = max_halvingself.max_doubling = max_doublingself.eps = epsself.batch_size = batch_sizeself._check_params()
// There is one internal hyperparameter:
// Smooth arguments of arctanh by multiplying with this constant to avoid division by zero:
self._tanh_smoother = 0.999999