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"]
docstr: To get the loss and gradient.
  :param adv_x: the candidate adversarial example
  :param c: parameter 'C' in the paper
  :return: (loss, gradient)
docstr_tok: ["To","get","the","loss","and","gradient",".",":","param","adv_x",":","the","candidate","adversarial","example",":","param","c",":","parameter","'","C","'","in","the","paper",":","return",":","(","loss",",","gradient",")"]
code: def _loss(self, adv_x, c):
      """
      To get the loss and gradient.
      :param adv_x: the candidate adversarial example
      :param c: parameter 'C' in the paper
      :return: (loss, gradient)
      """
      x = adv_x.reshape(self._adversary.original.shape)
  
      # cross_entropy
      logits = self.model.predict(x)
      if not self._is_predicts_normalized(logits):  # to softmax
          e = np.exp(logits)
          logits = e / np.sum(e)
      e = np.exp(logits)
      s = np.sum(e)
      ce = np.log(s) - logits[self._adversary.target_label]
  
      # L2 distance
      min_, max_ = self.model.bounds()
      d = (
          np.sum((x - self._adversary.original).flatten() ** 2)
          / ((max_ - min_) ** 2)
          / len(adv_x)
      )
  
      # gradient
      gradient = self.model.gradient(x, self._adversary.target_label)
  
      result = (c * ce + d).astype(float), gradient.flatten().astype(
          float
      )
      return result
  
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 4 for calling the LBFGSAttack obj's underlying member method code with example usage: obj._loss(adv_x, c) and returns: result