对抗性BCEWithLogits损失

class AdversarialBCEWithLogitsLoss(inverse_softmax_temperature: float = 1.0, reduction: str = 'mean')[源代码]

基础类:AdversarialLoss

一个对抗性加权的BCE损失。

初始化对抗损失。

Parameters:
  • inverse_softmax_temperature (float) – softmax温度的倒数

  • reduction (str) – 缩减操作的名称,参见 Loss.__init__()

方法总结

negative_loss_term_unreduced(neg_scores[, ...])

计算负分数的损失不进行缩减。

positive_loss_term(pos_scores[, ...])

计算正分数的损失。

方法文档

negative_loss_term_unreduced(neg_scores: Tensor, label_smoothing: float | None = None, num_entities: int | None = None) Tensor[source]

计算负分数的损失不进行缩减。

Parameters:
  • neg_scores (Tensor) – 任意形状 负分数

  • label_smoothing (float | None) – 标签平滑参数

  • num_entities (int | None) – 实体数量(用于标签平滑的必需参数)

Returns:

标量 负分数的未减少损失项

Return type:

Tensor

positive_loss_term(pos_scores: Tensor, label_smoothing: float | None = None, num_entities: int | None = None) Tensor[source]

计算正分数的损失。

Parameters:
  • pos_scores (Tensor) – 任意形状 正分数

  • label_smoothing (float | None) – 标签平滑参数

  • num_entities (int | None) – 实体数量(用于标签平滑的必需参数)

Returns:

标量 正分数的减少损失项

Return type:

Tensor