fairseq/criterions/label_smoothed_cross_entropy.py
Killed 0 out of 8 mutantsSurvived
Survived mutation testing. These mutants show holes in your test suite.Mutant 3343
--- fairseq/criterions/label_smoothed_cross_entropy.py
+++ fairseq/criterions/label_smoothed_cross_entropy.py
@@ -9,7 +9,7 @@
from fairseq.criterions import FairseqCriterion, register_criterion
-def label_smoothed_nll_loss(lprobs, target, epsilon, ignore_index=None, reduce=True):
+def label_smoothed_nll_loss(lprobs, target, epsilon, ignore_index=None, reduce=False):
if target.dim() == lprobs.dim() - 1:
target = target.unsqueeze(-1)
nll_loss = -lprobs.gather(dim=-1, index=target)
Mutant 3344
--- fairseq/criterions/label_smoothed_cross_entropy.py
+++ fairseq/criterions/label_smoothed_cross_entropy.py
@@ -29,7 +29,7 @@
return loss, nll_loss
-@register_criterion('label_smoothed_cross_entropy')
+@register_criterion('XXlabel_smoothed_cross_entropyXX')
class LabelSmoothedCrossEntropyCriterion(FairseqCriterion):
def __init__(self, task, sentence_avg, label_smoothing):
Mutant 3345
--- fairseq/criterions/label_smoothed_cross_entropy.py
+++ fairseq/criterions/label_smoothed_cross_entropy.py
@@ -28,8 +28,6 @@
loss = (1. - epsilon) * nll_loss + eps_i * smooth_loss
return loss, nll_loss
-
-@register_criterion('label_smoothed_cross_entropy')
class LabelSmoothedCrossEntropyCriterion(FairseqCriterion):
def __init__(self, task, sentence_avg, label_smoothing):
Mutant 3346
--- fairseq/criterions/label_smoothed_cross_entropy.py
+++ fairseq/criterions/label_smoothed_cross_entropy.py
@@ -37,7 +37,6 @@
self.sentence_avg = sentence_avg
self.eps = label_smoothing
- @staticmethod
def add_args(parser):
"""Add criterion-specific arguments to the parser."""
# fmt: off
Mutant 3347
--- fairseq/criterions/label_smoothed_cross_entropy.py
+++ fairseq/criterions/label_smoothed_cross_entropy.py
@@ -45,7 +45,7 @@
help='epsilon for label smoothing, 0 means no label smoothing')
# fmt: on
- def forward(self, model, sample, reduce=True):
+ def forward(self, model, sample, reduce=False):
"""Compute the loss for the given sample.
Returns a tuple with three elements:
Mutant 3348
--- fairseq/criterions/label_smoothed_cross_entropy.py
+++ fairseq/criterions/label_smoothed_cross_entropy.py
@@ -65,7 +65,7 @@
}
return loss, sample_size, logging_output
- def compute_loss(self, model, net_output, sample, reduce=True):
+ def compute_loss(self, model, net_output, sample, reduce=False):
lprobs = model.get_normalized_probs(net_output, log_probs=True)
lprobs = lprobs.view(-1, lprobs.size(-1))
target = model.get_targets(sample, net_output).view(-1, 1)
Mutant 3349
--- fairseq/criterions/label_smoothed_cross_entropy.py
+++ fairseq/criterions/label_smoothed_cross_entropy.py
@@ -74,7 +74,6 @@
)
return loss, nll_loss
- @staticmethod
def reduce_metrics(logging_outputs) -> None:
"""Aggregate logging outputs from data parallel training."""
loss_sum = sum(log.get('loss', 0) for log in logging_outputs)
Mutant 3350
--- fairseq/criterions/label_smoothed_cross_entropy.py
+++ fairseq/criterions/label_smoothed_cross_entropy.py
@@ -86,7 +86,6 @@
metrics.log_scalar('nll_loss', nll_loss_sum / ntokens / math.log(2), ntokens, round=3)
metrics.log_derived('ppl', lambda meters: utils.get_perplexity(meters['nll_loss'].avg))
- @staticmethod
def logging_outputs_can_be_summed() -> bool:
"""
Whether the logging outputs returned by `forward` can be summed