| 1190 | """ |
| 1191 | |
| 1192 | def __init__(self, config, num_labels=2): |
| 1193 | super(BertForSequenceClassification, self).__init__(config) |
| 1194 | self.num_labels = num_labels |
| 1195 | self.bert = BertModel(config) |
| 1196 | self.dropout = nn.Dropout(config.hidden_dropout_prob) |
| 1197 | self.classifier = nn.Linear(config.hidden_size, num_labels) |
| 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, |