AdversarialBCEWithLogitsLoss

class AdversarialBCEWithLogitsLoss(inverse_softmax_temperature=1.0, reduction='mean')[source]

Bases: AdversarialLoss

An adversarially weighted BCE loss.

Initialize the adversarial loss.

Parameters
  • inverse_softmax_temperature (float) – the inverse of the softmax temperature

  • reduction (str) – the name of the reduction operation, cf. Loss.__init__()

Methods Summary

negative_loss_term_unreduced(neg_scores[, ...])

Calculate the loss for the negative scores without reduction.

positive_loss_term(pos_scores[, ...])

Calculate the loss for the positive scores.

Methods Documentation

negative_loss_term_unreduced(neg_scores, label_smoothing=None, num_entities=None)[source]

Calculate the loss for the negative scores without reduction.

Parameters
  • neg_scores (FloatTensor) – any shape the negative scores

  • label_smoothing (Optional[float]) – the label smoothing parameter

  • num_entities (Optional[int]) – the number of entities (required for label-smoothing)

Return type

FloatTensor

Returns

scalar the unreduced loss term for negative scores

positive_loss_term(pos_scores, label_smoothing=None, num_entities=None)[source]

Calculate the loss for the positive scores.

Parameters
  • pos_scores (FloatTensor) – any shape the positive scores

  • label_smoothing (Optional[float]) – the label smoothing parameter

  • num_entities (Optional[int]) – the number of entities (required for label-smoothing)

Return type

FloatTensor

Returns

scalar the reduced loss term for positive scores