code: def multiclass_hinge_loss(predictions, targets, delta=1):
      """Computes the multi-class hinge loss between predictions and targets.
  
      .. math:: L_i = \\max_{j \\not = t_i} (0, p_j - p_{t_i} + \\delta)
  
      Parameters
      ----------
      predictions : Theano 2D tensor
          Predictions in (0, 1), such as softmax output of a neural network,
          with data points in rows and class probabilities in columns.
      targets : Theano 2D tensor or 1D tensor
          Either a vector of int giving the correct class index per data point
          or a 2D tensor of one-hot encoding of the correct class in the same
          layout as predictions (non-binary targets in [0, 1] do not work!)
      delta : scalar, default 1
          The hinge loss margin
  
      Returns
      -------
      Theano 1D tensor
          An expression for the item-wise multi-class hinge loss
  
      Notes
      -----
      This is an alternative to the categorical cross-entropy loss for
      multi-class classification problems
      """
      num_cls = predictions.shape[1]
      if targets.ndim == predictions.ndim - 1:
          targets = theano.tensor.extra_ops.to_one_hot(targets, num_cls)
      elif targets.ndim != predictions.ndim:
          raise TypeError(
              "rank mismatch between targets and predictions"
          )
      corrects = predictions[targets.nonzero()]
      rest = theano.tensor.reshape(
          predictions[(1 - targets).nonzero()], (-1, num_cls - 1)
      )
      rest = theano.tensor.max(rest, axis=1)
      return theano.tensor.nnet.relu(rest - corrects + delta)
  
file_path: Lasagne/lasagne/objectives.py
imports: import theano.tensor
  from .utils import as_theano_expression
label_desc: Use image node_id 7 for calling a global function with example usage: multiclass_hinge_loss(predictions, targets, delta) and returns: theano