roberta-base-sentiment-bg / modeling_roberta.py
rmihaylov's picture
add model
54e216c
raw
history blame
454 Bytes
from torch import nn
from transformers import XLMRobertaModel
class XLMRobertaForSequenceClassification(XLMRobertaModel):
def __init__(self, config):
super().__init__(config)
self.classifier = nn.Linear(768, 2)
def forward(self, input_ids, attention_mask):
outputs = super(XLMRobertaForSequenceClassification, self).forward(input_ids=input_ids, attention_mask=attention_mask)
return self.classifier(outputs[1])