fairseq/criterions/nat_loss.py

Killed 0 out of 11 mutants

Survived

Survived mutation testing. These mutants show holes in your test suite.

Mutant 2730

--- fairseq/criterions/nat_loss.py
+++ fairseq/criterions/nat_loss.py
@@ -13,7 +13,7 @@
 from fairseq.criterions import FairseqCriterion, register_criterion
 
 
-@register_criterion("nat_loss")
+@register_criterion("XXnat_lossXX")
 class LabelSmoothedDualImitationCriterion(FairseqCriterion):
 
     def __init__(self, task, label_smoothing):

Mutant 2731

--- fairseq/criterions/nat_loss.py
+++ fairseq/criterions/nat_loss.py
@@ -12,8 +12,6 @@
 from fairseq import metrics, utils
 from fairseq.criterions import FairseqCriterion, register_criterion
 
-
-@register_criterion("nat_loss")
 class LabelSmoothedDualImitationCriterion(FairseqCriterion):
 
     def __init__(self, task, label_smoothing):

Mutant 2732

--- fairseq/criterions/nat_loss.py
+++ fairseq/criterions/nat_loss.py
@@ -20,7 +20,6 @@
         super().__init__(task)
         self.label_smoothing = label_smoothing
 
-    @staticmethod
     def add_args(parser):
         """Add criterion-specific arguments to the parser."""
         parser.add_argument(

Mutant 2733

--- fairseq/criterions/nat_loss.py
+++ fairseq/criterions/nat_loss.py
@@ -32,7 +32,7 @@
         )
 
     def _compute_loss(
-        self, outputs, targets, masks=None, label_smoothing=0.0, name="loss", factor=1.0
+        self, outputs, targets, masks=None, label_smoothing=1.0, name="loss", factor=1.0
     ):
         """
             outputs: batch x len x d_model

Mutant 2734

--- fairseq/criterions/nat_loss.py
+++ fairseq/criterions/nat_loss.py
@@ -32,7 +32,7 @@
         )
 
     def _compute_loss(
-        self, outputs, targets, masks=None, label_smoothing=0.0, name="loss", factor=1.0
+        self, outputs, targets, masks=None, label_smoothing=0.0, name="XXlossXX", factor=1.0
     ):
         """
             outputs: batch x len x d_model

Mutant 2735

--- fairseq/criterions/nat_loss.py
+++ fairseq/criterions/nat_loss.py
@@ -32,7 +32,7 @@
         )
 
     def _compute_loss(
-        self, outputs, targets, masks=None, label_smoothing=0.0, name="loss", factor=1.0
+        self, outputs, targets, masks=None, label_smoothing=0.0, name="loss", factor=2.0
     ):
         """
             outputs: batch x len x d_model

Mutant 2736

--- fairseq/criterions/nat_loss.py
+++ fairseq/criterions/nat_loss.py
@@ -74,7 +74,7 @@
         loss = loss * factor
         return {"name": name, "loss": loss, "nll_loss": nll_loss, "factor": factor}
 
-    def _custom_loss(self, loss, name="loss", factor=1.0):
+    def _custom_loss(self, loss, name="XXlossXX", factor=1.0):
         return {"name": name, "loss": loss, "factor": factor}
 
     def forward(self, model, sample, reduce=True):

Mutant 2737

--- fairseq/criterions/nat_loss.py
+++ fairseq/criterions/nat_loss.py
@@ -74,7 +74,7 @@
         loss = loss * factor
         return {"name": name, "loss": loss, "nll_loss": nll_loss, "factor": factor}
 
-    def _custom_loss(self, loss, name="loss", factor=1.0):
+    def _custom_loss(self, loss, name="loss", factor=2.0):
         return {"name": name, "loss": loss, "factor": factor}
 
     def forward(self, model, sample, reduce=True):

Mutant 2738

--- fairseq/criterions/nat_loss.py
+++ fairseq/criterions/nat_loss.py
@@ -77,7 +77,7 @@
     def _custom_loss(self, loss, name="loss", factor=1.0):
         return {"name": name, "loss": loss, "factor": factor}
 
-    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:
         1) the loss

Mutant 2739

--- fairseq/criterions/nat_loss.py
+++ fairseq/criterions/nat_loss.py
@@ -142,7 +142,6 @@
 
         return loss, sample_size, logging_output
 
-    @staticmethod
     def reduce_metrics(logging_outputs) -> None:
         """Aggregate logging outputs from data parallel training."""
         sample_size = utils.item(sum(log.get("sample_size", 0) for log in logging_outputs))

Mutant 2740

--- fairseq/criterions/nat_loss.py
+++ fairseq/criterions/nat_loss.py
@@ -163,7 +163,6 @@
                     round=3,
                 )
 
-    @staticmethod
     def logging_outputs_can_be_summed() -> bool:
         """
         Whether the logging outputs returned by `forward` can be summed