class_docstr: This class implements the evaluation of Security Curves.
  
  Examples of Security Curves can be found in Figure 6 of Madry et al., 2017 (https://arxiv.org/abs/1706.06083).
class_docstr_tok: ["This","class","implements","the","evaluation","of","Security","Curves",".","Examples","of","Security","Curves","can","be","found","in","Figure","6","of","Madry","et","al.",",","2017","(","https",":","\/\/arxiv.org\/abs\/1706.06083",")","."]
docstr: Check if potential gradient obfuscation can be detected. Projected Gradient Descent with 100 iterations is run
  with maximum attack budget `eps` being equal to upper clip value of input data and `eps_step` of
  `eps / (max_iter / 2)`.
  
  :param classifier: A trained classifier that provides loss gradients.
  :param x: Input data to classifier for evaluation.
  :param y: True labels for input data `x`.
  :param kwargs: Keyword arguments for the Projected Gradient Descent attack used for evaluation, except keywords
                 `classifier` and `eps`.
docstr_tok: ["Check","if","potential","gradient","obfuscation","can","be","detected",".","Projected","Gradient","Descent","with","100","iterations","is","run","with","maximum","attack","budget","`","eps","`","being","equal","to","upper","clip","value","of","input","data","and","`","eps_step","`","of","`","eps","\/","(","max_iter","\/","2",")","`",".",":","param","classifier",":","A","trained","classifier","that","provides","loss","gradients",".",":","param","x",":","Input","data","to","classifier","for","evaluation",".",":","param","y",":","True","labels","for","input","data","`","x","`",".",":","param","kwargs",":","Keyword","arguments","for","the","Projected","Gradient","Descent","attack","used","for","evaluation",",","except","keywords","`","classifier","`","and","`","eps","`","."]
code: def _check_gradient(
      self,
      classifier: "CLASSIFIER_LOSS_GRADIENTS_TYPE",
      x: np.ndarray,
      y: np.ndarray,
      **kwargs: Union[str, bool, int, float],
  ) -> None:
      """
      Check if potential gradient obfuscation can be detected. Projected Gradient Descent with 100 iterations is run
      with maximum attack budget `eps` being equal to upper clip value of input data and `eps_step` of
      `eps / (max_iter / 2)`.
  
      :param classifier: A trained classifier that provides loss gradients.
      :param x: Input data to classifier for evaluation.
      :param y: True labels for input data `x`.
      :param kwargs: Keyword arguments for the Projected Gradient Descent attack used for evaluation, except keywords
                     `classifier` and `eps`.
      """
      # Define parameters for Projected Gradient Descent
      max_iter = 100
      kwargs["max_iter"] = max_iter
      if classifier.clip_values is not None:
          clip_value_max = classifier.clip_values[1]
      else:
          clip_value_max = np.max(x)
      kwargs["eps"] = float(clip_value_max)
      kwargs["eps_step"] = float(clip_value_max / (max_iter / 2))
  
      # Create attack
      attack_pgd = ProjectedGradientDescent(estimator=classifier, **kwargs)  # type: ignore
  
      # Evaluate accuracy with maximal attack budget
      x_adv = attack_pgd.generate(x=x, y=y)
      y_pred_adv = classifier.predict(x=x_adv, y=y)
      accuracy_adv = self._get_accuracy(y=y, y_pred=y_pred_adv)
  
      # Decide of obfuscated gradients likely
      if accuracy_adv > 1 / classifier.nb_classes:
          self._detected_obfuscating_gradients = True
      else:
          self._detected_obfuscating_gradients = False
  
file_path: adversarial-robustness-toolbox/art/evaluations/security_curve/security_curve.py
imports: from typing import List, Optional, Tuple, TYPE_CHECKING, Union
  import numpy
  from art.evaluations.evaluation import Evaluation
  from art.attacks.evasion.projected_gradient_descent.projected_gradient_descent import ProjectedGradientDescent
label_desc: Use image node_id 4 for calling the SecurityCurve obj's underlying member method code with example usage: obj._check_gradient(classifier, x, y) without return types