Upload RobertaEmotion
Browse files- modeling_roberta_emotion.py +6 -5
- pytorch_model.bin +1 -1
modeling_roberta_emotion.py
CHANGED
@@ -13,13 +13,14 @@ class RobertaEmotion(PreTrainedModel):
|
|
13 |
super().__init__(config)
|
14 |
self.num_labels = config.num_labels
|
15 |
self.backbone = AutoModel.from_pretrained("roberta-base", config)
|
16 |
-
self.
|
17 |
-
|
|
|
|
|
|
|
18 |
|
19 |
def forward(self, input_ids, labels=None, attention_mask=None):
|
20 |
-
|
21 |
-
hidden = model_output.last_hidden_state
|
22 |
-
logits = self.output(self.dropout(hidden[:, 0, :]))
|
23 |
|
24 |
loss = None
|
25 |
if labels is not None:
|
|
|
13 |
super().__init__(config)
|
14 |
self.num_labels = config.num_labels
|
15 |
self.backbone = AutoModel.from_pretrained("roberta-base", config)
|
16 |
+
self.classifier = torch.nn.Sequential(
|
17 |
+
torch.nn.Dropout(p=0.1),
|
18 |
+
torch.nn.Linear(config.hidden_size, config.num_labels)
|
19 |
+
)
|
20 |
+
torch.nn.init.xavier_normal_(self.classifier[1].weight)
|
21 |
|
22 |
def forward(self, input_ids, labels=None, attention_mask=None):
|
23 |
+
logits = self.classifier(self.backbone(input_ids).last_hidden_state[:, 0, :])
|
|
|
|
|
24 |
|
25 |
loss = None
|
26 |
if labels is not None:
|
pytorch_model.bin
CHANGED
@@ -1,3 +1,3 @@
|
|
1 |
version https://git-lfs.github.com/spec/v1
|
2 |
-
oid sha256:
|
3 |
size 498674549
|
|
|
1 |
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:36b6517a52c4a01ddbd9737a41ba9fde1c435cbb91f0554e416d90dbd021f045
|
3 |
size 498674549
|