(self, input_ids, token_type_ids=None, attention_mask=None, next_sentence_label=None,
checkpoint_activations=False)
| 1130 | self.apply(self.init_bert_weights) |
| 1131 | |
| 1132 | def forward(self, input_ids, token_type_ids=None, attention_mask=None, next_sentence_label=None, |
| 1133 | checkpoint_activations=False): |
| 1134 | _, pooled_output = self.bert(input_ids, token_type_ids, attention_mask, |
| 1135 | output_all_encoded_layers=False, checkpoint_activations=checkpoint_activations) |
| 1136 | seq_relationship_score = self.cls(pooled_output) |
| 1137 | |
| 1138 | if next_sentence_label is not None: |
| 1139 | loss_fct = CrossEntropyLoss(ignore_index=-1) |
| 1140 | next_sentence_loss = loss_fct(seq_relationship_score.view(-1, 2), next_sentence_label.view(-1)) |
| 1141 | return next_sentence_loss |
| 1142 | else: |
| 1143 | return seq_relationship_score |
| 1144 | |
| 1145 | |
| 1146 | class BertForSequenceClassification(PreTrainedBertModel): |
nothing calls this directly
no outgoing calls
no test coverage detected