Skip to content

Instantly share code, notes, and snippets.

@itsuncheng
Created June 12, 2020 10:26
Show Gist options
  • Save itsuncheng/3c84f0b5b90f00702245a311a87ee246 to your computer and use it in GitHub Desktop.
Save itsuncheng/3c84f0b5b90f00702245a311a87ee246 to your computer and use it in GitHub Desktop.
class BERT(nn.Module):
def __init__(self):
super(BERT, self).__init__()
options_name = "bert-base-uncased"
self.encoder = BertForSequenceClassification.from_pretrained(options_name)
def forward(self, text, label):
loss, text_fea = self.encoder(text, labels=label)[:2]
return loss, text_fea
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment