MCPcopy Create free account
hub / github.com/ICTMCG/FakeSV / bBert

Class bBert

code/models/Baselines.py:92–108  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

90
91
92class bBert(torch.nn.Module):
93 def __init__(self,bert_model,fea_dim, dropout):
94 super(bBert, self).__init__()
95 self.text_dim = 768
96
97 self.bert = BertModel.from_pretrained(bert_model).requires_grad_(False)
98
99 self.linear_text = nn.Sequential(torch.nn.Linear(self.text_dim, fea_dim),torch.nn.ReLU())
100 self.classifier = nn.Linear(fea_dim,2)
101
102 def forward(self, **kwargs):
103 title_inputid = kwargs['title_inputid']
104 title_mask=kwargs['title_mask']
105 fea_text=self.bert(title_inputid,attention_mask=title_mask)[1]
106 fea_text=self.linear_text(fea_text)
107 output = self.classifier(fea_text)
108 return output,fea_text
109
110class bTextCNN(nn.Module):
111 def __init__(self, fea_dim, vocab_size):

Callers 1

get_modelMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected