code: def binary_hinge_loss(
      predictions, targets, delta=1, log_odds=None, binary=True
  ):
      """Computes the binary hinge loss between predictions and targets.
  
      .. math:: L_i = \\max(0, \\delta - t_i p_i)
  
      Parameters
      ----------
      predictions : Theano tensor
          Predictions in (0, 1), such as sigmoidal output of a neural network
          (or log-odds of predictions depending on `log_odds`).
      targets : Theano tensor
          Targets in {0, 1} (or in {-1, 1} depending on `binary`), such as
          ground truth labels.
      delta : scalar, default 1
          The hinge loss margin
      log_odds : bool, default None
          ``False`` if predictions are sigmoid outputs in (0, 1), ``True`` if
          predictions are sigmoid inputs, or log-odds. If ``None``, will assume
          ``True``, but warn that the default will change to ``False``.
      binary : bool, default True
          ``True`` if targets are in {0, 1}, ``False`` if they are in {-1, 1}
  
      Returns
      -------
      Theano tensor
          An expression for the element-wise binary hinge loss
  
      Notes
      -----
      This is an alternative to the binary cross-entropy loss for binary
      classification problems.
  
      Note that it is a drop-in replacement only when giving ``log_odds=False``.
      Otherwise, it requires log-odds rather than sigmoid outputs. Be aware that
      depending on the Theano version, ``log_odds=False`` with a sigmoid
      output layer may be less stable than ``log_odds=True`` with a linear layer.
      """
      if log_odds is None:  # pragma: no cover
          raise FutureWarning(
              "The `log_odds` argument to `binary_hinge_loss` will change "
              "its default to `False` in a future version. Explicitly give "
              "`log_odds=True` to retain current behavior in your code, "
              "but also check the documentation if this is what you want."
          )
          log_odds = True
      if not log_odds:
          predictions = theano.tensor.log(
              predictions / (1 - predictions)
          )
      if binary:
          targets = 2 * targets - 1
      predictions, targets = align_targets(predictions, targets)
      return theano.tensor.nnet.relu(delta - predictions * targets)
  
file_path: Lasagne/lasagne/objectives.py
imports: import theano.tensor
  from .utils import as_theano_expression
label_desc: Use image node_id 6 for calling a global function with example usage: binary_hinge_loss(predictions, targets, delta, log_odds, binary) and returns: theano