Skip to content

Commit f16b29d

Browse files
committed
upd model
1 parent c4b75ee commit f16b29d

1 file changed

Lines changed: 3 additions & 3 deletions

File tree

models/textcnn.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ def __init__(self, emb_dim, mlp_dims, dataset, dropout):
1717
self.bert = BertModel.from_pretrained('hfl/chinese-bert-wwm-ext').requires_grad_(False)
1818
elif dataset == 'en':
1919
self.bert = RobertaModel.from_pretrained('roberta-base').requires_grad_(False)
20+
self.embedding = self.bert.embeddings
2021

2122
feature_kernel = {1: 64, 2: 64, 3: 64, 5: 64, 10: 64}
2223
self.convs = cnn_extractor(feature_kernel, emb_dim)
@@ -25,9 +26,8 @@ def __init__(self, emb_dim, mlp_dims, dataset, dropout):
2526

2627
def forward(self, **kwargs):
2728
inputs = kwargs['content']
28-
masks = kwargs['content_masks']
29-
bert_feature = self.bert(inputs, attention_mask = masks).last_hidden_state
30-
feature = self.convs(bert_feature)
29+
feature = self.embedding(inputs)
30+
feature = self.convs(feature)
3131
output = self.mlp(feature)
3232
return torch.sigmoid(output.squeeze(1))
3333

0 commit comments

Comments
 (0)