MCPcopy Create free account
hub / github.com/THUDM/GLM / forward

Method forward

model/modeling_bert.py:1200–1211  ·  view source on GitHub ↗
(self, input_ids, token_type_ids=None, attention_mask=None, labels=None, checkpoint_activations=False)

Source from the content-addressed store, hash-verified

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
1214class BertForMultipleChoice(PreTrainedBertModel):

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected