jaandoui commited on
Commit
07f9362
1 Parent(s): 48b1050

Update bert_layers.py

Browse files
Files changed (1) hide show
  1. bert_layers.py +4 -3
bert_layers.py CHANGED
@@ -491,6 +491,7 @@ class BertEncoder(nn.Module):
491
  if not output_all_encoded_layers:
492
  all_encoder_layers.append(hidden_states)
493
  return all_encoder_layers, all_attention_weights # Return both hidden states and attention weights
 
494
 
495
 
496
 
@@ -614,13 +615,13 @@ class BertModel(BertPreTrainedModel):
614
  first_col_mask[:, 0] = True
615
  subset_mask = masked_tokens_mask | first_col_mask
616
 
617
- encoder_outputs, all_attentions = self.encoder(
618
  embedding_output,
619
  attention_mask,
620
  output_all_encoded_layers=output_all_encoded_layers,
621
  subset_mask=subset_mask)
622
- print(f'here is the matrix of attentions in BERT: \n {all_attention_weights}')
623
- print(f'and this is the shape in BERT: \n {all_attention_weights.shape}')
624
 
625
  if masked_tokens_mask is None:
626
  sequence_output = encoder_outputs[-1]
 
491
  if not output_all_encoded_layers:
492
  all_encoder_layers.append(hidden_states)
493
  return all_encoder_layers, all_attention_weights # Return both hidden states and attention weights
494
+ return all_encoder_layers # Return both hidden states and attention weights
495
 
496
 
497
 
 
615
  first_col_mask[:, 0] = True
616
  subset_mask = masked_tokens_mask | first_col_mask
617
 
618
+ encoder_outputs = self.encoder(
619
  embedding_output,
620
  attention_mask,
621
  output_all_encoded_layers=output_all_encoded_layers,
622
  subset_mask=subset_mask)
623
+ # print(f'here is the matrix of attentions in BERT: \n {all_attention_weights}')
624
+ # print(f'and this is the shape in BERT: \n {all_attention_weights.shape}')
625
 
626
  if masked_tokens_mask is None:
627
  sequence_output = encoder_outputs[-1]