parlai/agents/seq2seq/modules.py

Killed 37 out of 95 mutants

Survived

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

Mutant 2

--- parlai/agents/seq2seq/modules.py
+++ parlai/agents/seq2seq/modules.py
@@ -51,7 +51,7 @@
         'attention',
         'attention_length',
         'attention_time',
-        'input_dropout',
+        'XXinput_dropoutXX',
     ]:
         if k in opt:
             kwargs[k] = opt[k]

Mutant 3

--- parlai/agents/seq2seq/modules.py
+++ parlai/agents/seq2seq/modules.py
@@ -53,7 +53,7 @@
         'attention_time',
         'input_dropout',
     ]:
-        if k in opt:
+        if k not in opt:
             kwargs[k] = opt[k]
     return kwargs
 

Mutant 5

--- parlai/agents/seq2seq/modules.py
+++ parlai/agents/seq2seq/modules.py
@@ -63,7 +63,7 @@
     Sequence to sequence parent module.
     """
 
-    RNN_OPTS = {'rnn': nn.RNN, 'gru': nn.GRU, 'lstm': nn.LSTM}
+    RNN_OPTS = {'XXrnnXX': nn.RNN, 'gru': nn.GRU, 'lstm': nn.LSTM}
 
     def __init__(
         self,

Mutant 7

--- parlai/agents/seq2seq/modules.py
+++ parlai/agents/seq2seq/modules.py
@@ -63,7 +63,7 @@
     Sequence to sequence parent module.
     """
 
-    RNN_OPTS = {'rnn': nn.RNN, 'gru': nn.GRU, 'lstm': nn.LSTM}
+    RNN_OPTS = {'rnn': nn.RNN, 'gru': nn.GRU, 'XXlstmXX': nn.LSTM}
 
     def __init__(
         self,

Mutant 9

--- parlai/agents/seq2seq/modules.py
+++ parlai/agents/seq2seq/modules.py
@@ -85,7 +85,7 @@
         end_idx=2,
         unknown_idx=3,
         input_dropout=0,
-        longest_label=1,
+        longest_label=2,
     ):
         """
         Initialize seq2seq model.

Mutant 10

--- parlai/agents/seq2seq/modules.py
+++ parlai/agents/seq2seq/modules.py
@@ -100,7 +100,7 @@
             input_dropout=input_dropout,
             longest_label=longest_label,
         )
-        self.attn_type = attention
+        self.attn_type = None
 
         rnn_class = Seq2seq.RNN_OPTS[rnn_class]
         self.decoder = RNNDecoder(

Mutant 12

--- parlai/agents/seq2seq/modules.py
+++ parlai/agents/seq2seq/modules.py
@@ -119,7 +119,7 @@
 
         shared_lt = (
             self.decoder.lt  # share embeddings between rnns
-            if lookuptable in ('enc_dec', 'all')
+            if lookuptable not in ('enc_dec', 'all')
             else None
         )
         shared_rnn = self.decoder.rnn if decoder == 'shared' else None

Mutant 13

--- parlai/agents/seq2seq/modules.py
+++ parlai/agents/seq2seq/modules.py
@@ -119,7 +119,7 @@
 
         shared_lt = (
             self.decoder.lt  # share embeddings between rnns
-            if lookuptable in ('enc_dec', 'all')
+            if lookuptable in ('XXenc_decXX', 'all')
             else None
         )
         shared_rnn = self.decoder.rnn if decoder == 'shared' else None

Mutant 14

--- parlai/agents/seq2seq/modules.py
+++ parlai/agents/seq2seq/modules.py
@@ -119,7 +119,7 @@
 
         shared_lt = (
             self.decoder.lt  # share embeddings between rnns
-            if lookuptable in ('enc_dec', 'all')
+            if lookuptable in ('enc_dec', 'XXallXX')
             else None
         )
         shared_rnn = self.decoder.rnn if decoder == 'shared' else None

Mutant 15

--- parlai/agents/seq2seq/modules.py
+++ parlai/agents/seq2seq/modules.py
@@ -122,7 +122,7 @@
             if lookuptable in ('enc_dec', 'all')
             else None
         )
-        shared_rnn = self.decoder.rnn if decoder == 'shared' else None
+        shared_rnn = self.decoder.rnn if decoder != 'shared' else None
         self.encoder = RNNEncoder(
             num_features,
             embeddingsize,

Mutant 16

--- parlai/agents/seq2seq/modules.py
+++ parlai/agents/seq2seq/modules.py
@@ -122,7 +122,7 @@
             if lookuptable in ('enc_dec', 'all')
             else None
         )
-        shared_rnn = self.decoder.rnn if decoder == 'shared' else None
+        shared_rnn = self.decoder.rnn if decoder == 'XXsharedXX' else None
         self.encoder = RNNEncoder(
             num_features,
             embeddingsize,

Mutant 17

--- parlai/agents/seq2seq/modules.py
+++ parlai/agents/seq2seq/modules.py
@@ -122,7 +122,7 @@
             if lookuptable in ('enc_dec', 'all')
             else None
         )
-        shared_rnn = self.decoder.rnn if decoder == 'shared' else None
+        shared_rnn = None
         self.encoder = RNNEncoder(
             num_features,
             embeddingsize,

Mutant 18

--- parlai/agents/seq2seq/modules.py
+++ parlai/agents/seq2seq/modules.py
@@ -140,7 +140,7 @@
 
         shared_weight = (
             self.decoder.lt  # use embeddings for projection
-            if lookuptable in ('dec_out', 'all')
+            if lookuptable not in ('dec_out', 'all')
             else None
         )
         self.output = OutputLayer(

Mutant 19

--- parlai/agents/seq2seq/modules.py
+++ parlai/agents/seq2seq/modules.py
@@ -140,7 +140,7 @@
 
         shared_weight = (
             self.decoder.lt  # use embeddings for projection
-            if lookuptable in ('dec_out', 'all')
+            if lookuptable in ('XXdec_outXX', 'all')
             else None
         )
         self.output = OutputLayer(

Mutant 20

--- parlai/agents/seq2seq/modules.py
+++ parlai/agents/seq2seq/modules.py
@@ -140,7 +140,7 @@
 
         shared_weight = (
             self.decoder.lt  # use embeddings for projection
-            if lookuptable in ('dec_out', 'all')
+            if lookuptable in ('dec_out', 'XXallXX')
             else None
         )
         self.output = OutputLayer(

Mutant 21

--- parlai/agents/seq2seq/modules.py
+++ parlai/agents/seq2seq/modules.py
@@ -216,7 +216,7 @@
                             at this rate.
         """
         super().__init__()
-        self.unknown_idx = unknown_idx
+        self.unknown_idx = None
         self.prob = probability
 
     def forward(self, input):

Mutant 23

--- parlai/agents/seq2seq/modules.py
+++ parlai/agents/seq2seq/modules.py
@@ -248,7 +248,7 @@
         shared_rnn=None,
         input_dropout=0,
         unknown_idx=None,
-        sparse=False,
+        sparse=True,
     ):
         """
         Initialize recurrent encoder.

Mutant 25

--- parlai/agents/seq2seq/modules.py
+++ parlai/agents/seq2seq/modules.py
@@ -256,7 +256,7 @@
         super().__init__()
 
         self.dropout = nn.Dropout(p=dropout)
-        self.layers = numlayers
+        self.layers = None
         self.dirs = 2 if bidirectional else 1
         self.hsz = hiddensize
 

Mutant 26

--- parlai/agents/seq2seq/modules.py
+++ parlai/agents/seq2seq/modules.py
@@ -257,7 +257,7 @@
 
         self.dropout = nn.Dropout(p=dropout)
         self.layers = numlayers
-        self.dirs = 2 if bidirectional else 1
+        self.dirs = 3 if bidirectional else 1
         self.hsz = hiddensize
 
         if input_dropout > 0 and unknown_idx is None:

Mutant 29

--- parlai/agents/seq2seq/modules.py
+++ parlai/agents/seq2seq/modules.py
@@ -258,7 +258,7 @@
         self.dropout = nn.Dropout(p=dropout)
         self.layers = numlayers
         self.dirs = 2 if bidirectional else 1
-        self.hsz = hiddensize
+        self.hsz = None
 
         if input_dropout > 0 and unknown_idx is None:
             raise RuntimeError('input_dropout > 0 but unknown_idx not set')

Mutant 30

--- parlai/agents/seq2seq/modules.py
+++ parlai/agents/seq2seq/modules.py
@@ -260,7 +260,7 @@
         self.dirs = 2 if bidirectional else 1
         self.hsz = hiddensize
 
-        if input_dropout > 0 and unknown_idx is None:
+        if input_dropout >= 0 and unknown_idx is None:
             raise RuntimeError('input_dropout > 0 but unknown_idx not set')
         self.input_dropout = UnknownDropout(unknown_idx, input_dropout)
 

Mutant 31

--- parlai/agents/seq2seq/modules.py
+++ parlai/agents/seq2seq/modules.py
@@ -260,7 +260,7 @@
         self.dirs = 2 if bidirectional else 1
         self.hsz = hiddensize
 
-        if input_dropout > 0 and unknown_idx is None:
+        if input_dropout > 1 and unknown_idx is None:
             raise RuntimeError('input_dropout > 0 but unknown_idx not set')
         self.input_dropout = UnknownDropout(unknown_idx, input_dropout)
 

Mutant 32

--- parlai/agents/seq2seq/modules.py
+++ parlai/agents/seq2seq/modules.py
@@ -260,7 +260,7 @@
         self.dirs = 2 if bidirectional else 1
         self.hsz = hiddensize
 
-        if input_dropout > 0 and unknown_idx is None:
+        if input_dropout > 0 and unknown_idx is not None:
             raise RuntimeError('input_dropout > 0 but unknown_idx not set')
         self.input_dropout = UnknownDropout(unknown_idx, input_dropout)
 

Mutant 33

--- parlai/agents/seq2seq/modules.py
+++ parlai/agents/seq2seq/modules.py
@@ -260,7 +260,7 @@
         self.dirs = 2 if bidirectional else 1
         self.hsz = hiddensize
 
-        if input_dropout > 0 and unknown_idx is None:
+        if input_dropout > 0 or unknown_idx is None:
             raise RuntimeError('input_dropout > 0 but unknown_idx not set')
         self.input_dropout = UnknownDropout(unknown_idx, input_dropout)
 

Mutant 35

--- parlai/agents/seq2seq/modules.py
+++ parlai/agents/seq2seq/modules.py
@@ -264,7 +264,7 @@
             raise RuntimeError('input_dropout > 0 but unknown_idx not set')
         self.input_dropout = UnknownDropout(unknown_idx, input_dropout)
 
-        if shared_lt is None:
+        if shared_lt is not None:
             self.lt = nn.Embedding(
                 num_features, embeddingsize, padding_idx=padding_idx, sparse=sparse
             )

Mutant 38

--- parlai/agents/seq2seq/modules.py
+++ parlai/agents/seq2seq/modules.py
@@ -276,7 +276,7 @@
                 embeddingsize,
                 hiddensize,
                 numlayers,
-                dropout=dropout if numlayers > 1 else 0,
+                dropout=dropout if numlayers >= 1 else 0,
                 batch_first=True,
                 bidirectional=bidirectional,
             )

Mutant 39

--- parlai/agents/seq2seq/modules.py
+++ parlai/agents/seq2seq/modules.py
@@ -276,7 +276,7 @@
                 embeddingsize,
                 hiddensize,
                 numlayers,
-                dropout=dropout if numlayers > 1 else 0,
+                dropout=dropout if numlayers > 2 else 0,
                 batch_first=True,
                 bidirectional=bidirectional,
             )

Mutant 40

--- parlai/agents/seq2seq/modules.py
+++ parlai/agents/seq2seq/modules.py
@@ -276,7 +276,7 @@
                 embeddingsize,
                 hiddensize,
                 numlayers,
-                dropout=dropout if numlayers > 1 else 0,
+                dropout=dropout if numlayers > 1 else 1,
                 batch_first=True,
                 bidirectional=bidirectional,
             )

Mutant 41

--- parlai/agents/seq2seq/modules.py
+++ parlai/agents/seq2seq/modules.py
@@ -277,7 +277,7 @@
                 hiddensize,
                 numlayers,
                 dropout=dropout if numlayers > 1 else 0,
-                batch_first=True,
+                batch_first=False,
                 bidirectional=bidirectional,
             )
         elif bidirectional:

Mutant 42

--- parlai/agents/seq2seq/modules.py
+++ parlai/agents/seq2seq/modules.py
@@ -352,7 +352,7 @@
         attn_type='none',
         attn_time='pre',
         attn_length=-1,
-        sparse=False,
+        sparse=True,
     ):
         """
         Initialize recurrent decoder.

Mutant 44

--- parlai/agents/seq2seq/modules.py
+++ parlai/agents/seq2seq/modules.py
@@ -359,7 +359,7 @@
         """
         super().__init__()
         self.dropout = nn.Dropout(p=dropout)
-        self.layers = numlayers
+        self.layers = None
         self.hsz = hiddensize
         self.esz = embeddingsize
 

Mutant 45

--- parlai/agents/seq2seq/modules.py
+++ parlai/agents/seq2seq/modules.py
@@ -360,7 +360,7 @@
         super().__init__()
         self.dropout = nn.Dropout(p=dropout)
         self.layers = numlayers
-        self.hsz = hiddensize
+        self.hsz = None
         self.esz = embeddingsize
 
         self.lt = nn.Embedding(

Mutant 46

--- parlai/agents/seq2seq/modules.py
+++ parlai/agents/seq2seq/modules.py
@@ -361,7 +361,7 @@
         self.dropout = nn.Dropout(p=dropout)
         self.layers = numlayers
         self.hsz = hiddensize
-        self.esz = embeddingsize
+        self.esz = None
 
         self.lt = nn.Embedding(
             num_features, embeddingsize, padding_idx=padding_idx, sparse=sparse

Mutant 47

--- parlai/agents/seq2seq/modules.py
+++ parlai/agents/seq2seq/modules.py
@@ -370,7 +370,7 @@
             embeddingsize,
             hiddensize,
             numlayers,
-            dropout=dropout if numlayers > 1 else 0,
+            dropout=dropout if numlayers >= 1 else 0,
             batch_first=True,
         )
 

Mutant 48

--- parlai/agents/seq2seq/modules.py
+++ parlai/agents/seq2seq/modules.py
@@ -370,7 +370,7 @@
             embeddingsize,
             hiddensize,
             numlayers,
-            dropout=dropout if numlayers > 1 else 0,
+            dropout=dropout if numlayers > 2 else 0,
             batch_first=True,
         )
 

Mutant 49

--- parlai/agents/seq2seq/modules.py
+++ parlai/agents/seq2seq/modules.py
@@ -370,7 +370,7 @@
             embeddingsize,
             hiddensize,
             numlayers,
-            dropout=dropout if numlayers > 1 else 0,
+            dropout=dropout if numlayers > 1 else 1,
             batch_first=True,
         )
 

Mutant 51

--- parlai/agents/seq2seq/modules.py
+++ parlai/agents/seq2seq/modules.py
@@ -374,7 +374,7 @@
             batch_first=True,
         )
 
-        self.attn_type = attn_type
+        self.attn_type = None
         self.attn_time = attn_time
         self.attention = AttentionLayer(
             attn_type=attn_type,

Mutant 52

--- parlai/agents/seq2seq/modules.py
+++ parlai/agents/seq2seq/modules.py
@@ -375,7 +375,7 @@
         )
 
         self.attn_type = attn_type
-        self.attn_time = attn_time
+        self.attn_time = None
         self.attention = AttentionLayer(
             attn_type=attn_type,
             hiddensize=hiddensize,

Mutant 53

--- parlai/agents/seq2seq/modules.py
+++ parlai/agents/seq2seq/modules.py
@@ -472,7 +472,7 @@
         dropout=0,
         numsoftmax=1,
         shared_weight=None,
-        padding_idx=-1,
+        padding_idx=+1,
     ):
         """
         Initialize output layer.

Mutant 54

--- parlai/agents/seq2seq/modules.py
+++ parlai/agents/seq2seq/modules.py
@@ -472,7 +472,7 @@
         dropout=0,
         numsoftmax=1,
         shared_weight=None,
-        padding_idx=-1,
+        padding_idx=-2,
     ):
         """
         Initialize output layer.

Mutant 57

--- parlai/agents/seq2seq/modules.py
+++ parlai/agents/seq2seq/modules.py
@@ -499,7 +499,7 @@
         self.dropout = nn.Dropout(p=dropout)
 
         self.padding_idx = padding_idx
-        rng = 1.0 / math.sqrt(num_features)
+        rng = 2.0 / math.sqrt(num_features)
         self.bias = Parameter(torch.Tensor(num_features).uniform_(-rng, rng))
 
         # embedding to scores

Mutant 58

--- parlai/agents/seq2seq/modules.py
+++ parlai/agents/seq2seq/modules.py
@@ -499,7 +499,7 @@
         self.dropout = nn.Dropout(p=dropout)
 
         self.padding_idx = padding_idx
-        rng = 1.0 / math.sqrt(num_features)
+        rng = 1.0 * math.sqrt(num_features)
         self.bias = Parameter(torch.Tensor(num_features).uniform_(-rng, rng))
 
         # embedding to scores

Mutant 60

--- parlai/agents/seq2seq/modules.py
+++ parlai/agents/seq2seq/modules.py
@@ -500,7 +500,7 @@
 
         self.padding_idx = padding_idx
         rng = 1.0 / math.sqrt(num_features)
-        self.bias = Parameter(torch.Tensor(num_features).uniform_(-rng, rng))
+        self.bias = Parameter(torch.Tensor(num_features).uniform_(+rng, rng))
 
         # embedding to scores
         if shared_weight is None:

Mutant 61

--- parlai/agents/seq2seq/modules.py
+++ parlai/agents/seq2seq/modules.py
@@ -500,7 +500,7 @@
 
         self.padding_idx = padding_idx
         rng = 1.0 / math.sqrt(num_features)
-        self.bias = Parameter(torch.Tensor(num_features).uniform_(-rng, rng))
+        self.bias = None
 
         # embedding to scores
         if shared_weight is None:

Mutant 62

--- parlai/agents/seq2seq/modules.py
+++ parlai/agents/seq2seq/modules.py
@@ -503,7 +503,7 @@
         self.bias = Parameter(torch.Tensor(num_features).uniform_(-rng, rng))
 
         # embedding to scores
-        if shared_weight is None:
+        if shared_weight is not None:
             # just a regular linear layer
             self.shared = False
             self.weight = Parameter(

Mutant 63

--- parlai/agents/seq2seq/modules.py
+++ parlai/agents/seq2seq/modules.py
@@ -511,7 +511,7 @@
             )
         else:
             # use shared weights and a bias layer instead
-            self.shared = True
+            self.shared = False
             self.weight = shared_weight.weight
 
         self.numsoftmax = numsoftmax

Mutant 64

--- parlai/agents/seq2seq/modules.py
+++ parlai/agents/seq2seq/modules.py
@@ -511,7 +511,7 @@
             )
         else:
             # use shared weights and a bias layer instead
-            self.shared = True
+            self.shared = None
             self.weight = shared_weight.weight
 
         self.numsoftmax = numsoftmax

Mutant 68

--- parlai/agents/seq2seq/modules.py
+++ parlai/agents/seq2seq/modules.py
@@ -515,7 +515,7 @@
             self.weight = shared_weight.weight
 
         self.numsoftmax = numsoftmax
-        if numsoftmax > 1:
+        if numsoftmax > 2:
             self.esz = embeddingsize
             self.softmax = nn.Softmax(dim=1)
             self.prior = nn.Linear(hiddensize, numsoftmax, bias=False)

Mutant 69

--- parlai/agents/seq2seq/modules.py
+++ parlai/agents/seq2seq/modules.py
@@ -523,7 +523,7 @@
             self.activation = nn.Tanh()
         else:
             # rnn output to embedding
-            if hiddensize != embeddingsize:
+            if hiddensize == embeddingsize:
                 # learn projection to correct dimensions
                 self.o2e = nn.Linear(hiddensize, embeddingsize, bias=True)
             else:

Mutant 71

--- parlai/agents/seq2seq/modules.py
+++ parlai/agents/seq2seq/modules.py
@@ -587,7 +587,7 @@
         embeddingsize,
         bidirectional=False,
         attn_length=-1,
-        attn_time='pre',
+        attn_time='XXpreXX',
     ):
         """
         Initialize attention layer.

Mutant 74

--- parlai/agents/seq2seq/modules.py
+++ parlai/agents/seq2seq/modules.py
@@ -595,7 +595,7 @@
         super().__init__()
         self.attention = attn_type
 
-        if self.attention != 'none':
+        if self.attention != 'XXnoneXX':
             hsz = hiddensize
             hszXdirs = hsz * (2 if bidirectional else 1)
             if attn_time == 'pre':

Mutant 77

--- parlai/agents/seq2seq/modules.py
+++ parlai/agents/seq2seq/modules.py
@@ -597,7 +597,7 @@
 
         if self.attention != 'none':
             hsz = hiddensize
-            hszXdirs = hsz * (2 if bidirectional else 1)
+            hszXdirs = hsz * (3 if bidirectional else 1)
             if attn_time == 'pre':
                 # attention happens on the input embeddings
                 input_dim = embeddingsize

Mutant 80

--- parlai/agents/seq2seq/modules.py
+++ parlai/agents/seq2seq/modules.py
@@ -598,7 +598,7 @@
         if self.attention != 'none':
             hsz = hiddensize
             hszXdirs = hsz * (2 if bidirectional else 1)
-            if attn_time == 'pre':
+            if attn_time != 'pre':
                 # attention happens on the input embeddings
                 input_dim = embeddingsize
             elif attn_time == 'post':

Mutant 81

--- parlai/agents/seq2seq/modules.py
+++ parlai/agents/seq2seq/modules.py
@@ -598,7 +598,7 @@
         if self.attention != 'none':
             hsz = hiddensize
             hszXdirs = hsz * (2 if bidirectional else 1)
-            if attn_time == 'pre':
+            if attn_time == 'XXpreXX':
                 # attention happens on the input embeddings
                 input_dim = embeddingsize
             elif attn_time == 'post':

Mutant 86

--- parlai/agents/seq2seq/modules.py
+++ parlai/agents/seq2seq/modules.py
@@ -608,7 +608,7 @@
                 raise RuntimeError('unsupported attention time')
 
             # linear layer for combining applied attention weights with input
-            self.attn_combine = nn.Linear(hszXdirs + input_dim, input_dim, bias=False)
+            self.attn_combine = nn.Linear(hszXdirs + input_dim, input_dim, bias=True)
 
             if self.attention == 'local':
                 # local attention over fixed set of output states

Mutant 89

--- parlai/agents/seq2seq/modules.py
+++ parlai/agents/seq2seq/modules.py
@@ -610,7 +610,7 @@
             # linear layer for combining applied attention weights with input
             self.attn_combine = nn.Linear(hszXdirs + input_dim, input_dim, bias=False)
 
-            if self.attention == 'local':
+            if self.attention == 'XXlocalXX':
                 # local attention over fixed set of output states
                 if attn_length < 0:
                     raise RuntimeError('Set attention length to > 0.')

Mutant 91

--- parlai/agents/seq2seq/modules.py
+++ parlai/agents/seq2seq/modules.py
@@ -618,7 +618,7 @@
                 # combines input and previous hidden output layer
                 self.attn = nn.Linear(hsz + input_dim, attn_length, bias=False)
                 # combines attention weights with encoder outputs
-            elif self.attention == 'concat':
+            elif self.attention == 'XXconcatXX':
                 self.attn = nn.Linear(hsz + hszXdirs, hsz, bias=False)
                 self.attn_v = nn.Linear(hsz, 1, bias=False)
             elif self.attention == 'general':

Mutant 94

--- parlai/agents/seq2seq/modules.py
+++ parlai/agents/seq2seq/modules.py
@@ -623,7 +623,7 @@
                 self.attn_v = nn.Linear(hsz, 1, bias=False)
             elif self.attention == 'general':
                 # equivalent to dot if attn is identity
-                self.attn = nn.Linear(hsz, hszXdirs, bias=False)
+                self.attn = nn.Linear(hsz, hszXdirs, bias=True)
 
     def forward(self, xes, hidden, attn_params):
         """