(self, input_ids, token_type_ids=None, attention_mask=None, labels=None, checkpoint_activations=False)
| 1198 | self.apply(self.init_bert_weights) |
| 1199 | |
| 1200 | def forward(self, input_ids, token_type_ids=None, attention_mask=None, labels=None, checkpoint_activations=False): |
| 1201 | _, pooled_output = self.bert(input_ids, token_type_ids, attention_mask, output_all_encoded_layers=False, |
| 1202 | checkpoint_activations=checkpoint_activations) |
| 1203 | pooled_output = self.dropout(pooled_output) |
| 1204 | logits = self.classifier(pooled_output) |
| 1205 | |
| 1206 | if labels is not None: |
| 1207 | loss_fct = CrossEntropyLoss() |
| 1208 | loss = loss_fct(logits.view(-1, self.num_labels), labels.view(-1)) |
| 1209 | return loss |
| 1210 | else: |
| 1211 | return logits |
| 1212 | |
| 1213 | |
| 1214 | class BertForMultipleChoice(PreTrainedBertModel): |
nothing calls this directly
no outgoing calls
no test coverage detected