Spaces:
Runtime error
Runtime error
| from transformers import BertModel | |
| import torch.nn as nn | |
| import torch.nn.functional as F | |
| class SentimentModel(nn.Module): | |
| def __init__(self, config): | |
| super(SentimentModel, self).__init__() | |
| self.bert = BertModel.from_pretrained(modelName, return_dict=False) | |
| self.dropout = nn.Dropout(0.3) | |
| self.classifier = nn.Linear(config.hidden_size, config.num_labels) | |
| def forward(self, input_ids, attention_mask): | |
| _, pooled_output = self.bert( | |
| input_ids=input_ids, | |
| attention_mask=attention_mask) | |
| pooled_output = self.dropout(pooled_output) | |
| logits = self.classifier(pooled_output) | |
| return logits |