(self, input_ids, token_type_ids=None, attention_mask=None, masked_lm_labels=None,
checkpoint_activations=False)
| 1066 | self.apply(self.init_bert_weights) |
| 1067 | |
| 1068 | def forward(self, input_ids, token_type_ids=None, attention_mask=None, masked_lm_labels=None, |
| 1069 | checkpoint_activations=False): |
| 1070 | sequence_output, _ = self.bert(input_ids, token_type_ids, attention_mask, |
| 1071 | output_all_encoded_layers=False, checkpoint_activations=checkpoint_activations) |
| 1072 | prediction_scores = self.cls(sequence_output) |
| 1073 | |
| 1074 | if masked_lm_labels is not None: |
| 1075 | loss_fct = CrossEntropyLoss(ignore_index=-1) |
| 1076 | masked_lm_loss = loss_fct(prediction_scores.view(-1, self.config.vocab_size), masked_lm_labels.view(-1)) |
| 1077 | return masked_lm_loss |
| 1078 | else: |
| 1079 | return prediction_scores |
| 1080 | |
| 1081 | |
| 1082 | class BertForNextSentencePrediction(PreTrainedBertModel): |
nothing calls this directly
no outgoing calls
no test coverage detected