class_docstr: Rank hinge loss.
  
  Examples:
      >>> from keras import backend as K
      >>> x_pred = K.variable(np.array([[1.0], [1.2], [0.8], [1.4]]))
      >>> x_true = K.variable(np.array([[1], [0], [1], [0]]))
      >>> expect = ((1.0 + 1.2 - 1.0) + (1.0 + 1.4 - 0.8)) / 2
      >>> expect
      1.4
      >>> loss = K.eval(RankHingeLoss(num_neg=1, margin=1.0)(x_true, x_pred))
      >>> np.isclose(loss, expect)
      True
class_docstr_tok: ["Rank","hinge","loss",".","Examples",":",">",">",">","from","keras","import","backend","as","K",">",">",">","x_pred","=","K.variable","(","np.array","(","[","[","1.0","]",",","[","1.2","]",",","[","0.8","]",",","[","1.4","]","]",")",")",">",">",">","x_true","=","K.variable","(","np.array","(","[","[","1","]",",","[","0","]",",","[","1","]",",","[","0","]","]",")",")",">",">",">","expect","=","(","(","1.0","+","1.2","-","1.0",")","+","(","1.0","+","1.4","-","0.8",")",")","\/","2",">",">",">","expect","1.4",">",">",">","loss","=","K.eval","(","RankHingeLoss","(","num_neg=1",",","margin=1.0",")","(","x_true",",","x_pred",")",")",">",">",">","np.isclose","(","loss",",","expect",")","True"]
docstr: :class:`RankHingeLoss` constructor.
  
  :param num_neg: number of negative instances in hinge loss.
  :param margin: the margin between positive and negative scores.
docstr_tok: [":","class",":","`","RankHingeLoss","`","constructor",".",":","param","num_neg",":","number","of","negative","instances","in","hinge","loss",".",":","param","margin",":","the","margin","between","positive","and","negative","scores","."]
code: def __init__(self, num_neg: int = 1, margin: float = 1.0):
      """
      :class:`RankHingeLoss` constructor.
  
      :param num_neg: number of negative instances in hinge loss.
      :param margin: the margin between positive and negative scores.
      """
      super().__init__(
          reduction=losses_utils.Reduction.SUM_OVER_BATCH_SIZE,
          name="rank_hinge",
      )
  
      self._num_neg = num_neg
      self._margin = margin
  
file_path: MatchZoo/matchzoo/losses/rank_hinge_loss.py
imports: import numpy
  import tensorflow
  from keras import layers, backend
  from keras.losses import Loss
  from keras.utils import losses_utils
label_desc: Use image node_id 1 to create a new RankHingeLoss object from inherited base classes: Loss with example: obj = RankHingeLoss(num_neg, margin)