besskge.loss.MarginRankingLoss
- class besskge.loss.MarginRankingLoss(margin, negative_adversarial_sampling, negative_adversarial_scale=1.0, loss_scale=1.0, activation_function='relu')[source]
- The margin ranking (or pairwise hinge) loss function. - Initialize margin ranking loss function. - Parameters:
- margin ( - float) – see- MarginBasedLossFunction.__init__()
- negative_adversarial_sampling ( - bool) – see- BaseLossFunction
- negative_adversarial_scale ( - float) – see- BaseLossFunction
- loss_scale ( - float) – see- BaseLossFunction
- activation_function ( - str) – The activation function in loss computation. Default: “relu”.
 
 - get_negative_weights(negative_score)
- Construct weights of negative samples, based on their score. - Parameters:
- negative_score ( - Tensor) – : (batch_size, n_negative) Scores of negative samples.
- Return type:
- Returns:
- shape: (batch_size, n_negative) if - BaseLossFunction.negative_adversarial_samplingelse () Weights of negative samples.