igorktech commited on
Commit
850bb86
·
1 Parent(s): 6600760

Update modelling_hibial.py

Browse files
Files changed (1) hide show
  1. modelling_hibial.py +3 -1
modelling_hibial.py CHANGED
@@ -180,7 +180,7 @@ class TransformerEncoderLayer(Module):
180
 
181
  # Extend mask
182
  # src_mask = src_mask.repeat(self.self_attn.num_heads, 1, 1)
183
-
184
  # PreLayerNorm
185
  if self.norm_first:
186
 
@@ -334,6 +334,8 @@ class HiBiAlBert(Module):
334
  bialibi_utt_mask[enc_mask_utt.bool()] = float('-inf')
335
  bialibi_ct_mask[enc_mask_ct.bool()] = float('-inf')
336
 
 
 
337
  # memory = self.encoder(input_ids, mask=src_mask, src_key_padding_mask=src_key_padding_mask)
338
 
339
  # Encoding
 
180
 
181
  # Extend mask
182
  # src_mask = src_mask.repeat(self.self_attn.num_heads, 1, 1)
183
+
184
  # PreLayerNorm
185
  if self.norm_first:
186
 
 
334
  bialibi_utt_mask[enc_mask_utt.bool()] = float('-inf')
335
  bialibi_ct_mask[enc_mask_ct.bool()] = float('-inf')
336
 
337
+ src_key_padding_mask = torch.where(src_key_padding_mask, torch.tensor(float('-inf')), torch.tensor(0.0))
338
+
339
  # memory = self.encoder(input_ids, mask=src_mask, src_key_padding_mask=src_key_padding_mask)
340
 
341
  # Encoding