ma2za commited on
Commit
ee651c6
1 Parent(s): e3d1ef2

Upload RobertaEmotion

Browse files
Files changed (2) hide show
  1. modeling_roberta_emotion.py +6 -5
  2. 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.dropout = torch.nn.Dropout(p=0.1)
17
- self.output = torch.nn.Linear(config.hidden_size, config.num_labels)
 
 
 
18
 
19
  def forward(self, input_ids, labels=None, attention_mask=None):
20
- model_output = self.backbone(input_ids)
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:817b674ed3b1c8cf89d76ca2fbb13cd6bad525afbe6cc0830a95148db3fdc388
3
  size 498674549
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:36b6517a52c4a01ddbd9737a41ba9fde1c435cbb91f0554e416d90dbd021f045
3
  size 498674549