This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class BERT_Arch(nn.Module): | |
def __init__(self, bert): | |
super(BERT_Arch, self).__init__() | |
self.bert = bert | |
# dropout layer | |
self.dropout = nn.Dropout(0.1) | |
# relu activation function | |
self.relu = nn.ReLU() | |
# dense layer 1 | |
self.fc1 = nn.Linear(768,512) | |
# dense layer 2 (Output layer) | |
self.fc2 = nn.Linear(512,2) | |
#softmax activation function | |
self.softmax = nn.LogSoftmax(dim=1) | |
#define the forward pass | |
def forward(self, sent_id, mask): | |
#pass the inputs to the model | |
_, cls_hs = self.bert(sent_id, attention_mask=mask) | |
x = self.fc1(cls_hs) | |
x = self.relu(x) | |
x = self.dropout(x) | |
# output layer | |
x = self.fc2(x) | |
# apply softmax activation | |
x = self.softmax(x) | |
return x |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment