class_docstr: Uses L-BFGS-B to minimize the cross-entropy and the distance between the
  original and the adversary.
  
  Paper link: https://arxiv.org/abs/1510.05328
class_docstr_tok: ["Uses","L-BFGS-B","to","minimize","the","cross-entropy","and","the","distance","between","the","original","and","the","adversary",".","Paper","link",":","https",":","\/\/arxiv.org\/abs\/1510.05328"]
code: def _apply(self, adversary, epsilon=0.001, steps=10):
      self._adversary = adversary
  
      if not adversary.is_targeted_attack:
          raise ValueError(
              "This attack method only support targeted attack!"
          )
  
      # finding initial c
      logging.info("finding initial c...")
      c = epsilon
      x0 = np.copy(adversary.original.flatten())
      for i in range(30):
          c = 2 * c
          logging.info("c={}".format(c))
          is_adversary = self._lbfgsb(x0, c, steps)
          if is_adversary:
              break
      if not is_adversary:
          logging.info("Failed!")
          return adversary
  
      # binary search c
      logging.info("binary search c...")
      c_low = 0
      c_high = c
      while c_high - c_low >= epsilon:
          logging.info(
              "c_high={}, c_low={}, diff={}, epsilon={}".format(
                  c_high, c_low, c_high - c_low, epsilon
              )
          )
          c_half = (c_low + c_high) / 2
          is_adversary = self._lbfgsb(x0, c_half, steps)
          if is_adversary:
              c_high = c_half
          else:
              c_low = c_half
  
      return adversary
  
file_path: AdvBox/adversarialbox/attacks/lbfgs.py
imports: from __future__ import division
  from builtins import range
  import logging
  import numpy
  from scipy.optimize import fmin_l_bfgs_b
  from .base import Attack
label_desc: Use image node_id 2 for calling the LBFGSAttack obj's underlying member method code with example usage: obj._apply(adversary, epsilon, steps) and returns: adversary, adversary