(self,bert_model,fea_dim,dropout)
| 22 | |
| 23 | class SVFENDModel(torch.nn.Module): |
| 24 | def __init__(self,bert_model,fea_dim,dropout): |
| 25 | super(SVFENDModel, self).__init__() |
| 26 | |
| 27 | self.bert = BertModel.from_pretrained(bert_model).requires_grad_(False) |
| 28 | |
| 29 | self.text_dim = 768 |
| 30 | self.comment_dim = 768 |
| 31 | self.img_dim = 4096 |
| 32 | self.video_dim = 4096 |
| 33 | self.num_frames = 83 |
| 34 | self.num_audioframes = 50 |
| 35 | self.num_comments = 23 |
| 36 | self.dim = fea_dim |
| 37 | self.num_heads = 4 |
| 38 | |
| 39 | self.dropout = dropout |
| 40 | |
| 41 | self.attention = Attention(dim=self.dim,heads=4,dropout=dropout) |
| 42 | |
| 43 | self.vggish_layer = torch.hub.load('./torchvggish/', 'vggish', source = 'local') |
| 44 | net_structure = list(self.vggish_layer.children()) |
| 45 | self.vggish_modified = nn.Sequential(*net_structure[-2:-1]) |
| 46 | |
| 47 | self.co_attention_ta = co_attention(d_k=fea_dim, d_v=fea_dim, n_heads=self.num_heads, dropout=self.dropout, d_model=fea_dim, |
| 48 | visual_len=self.num_audioframes, sen_len=512, fea_v=self.dim, fea_s=self.dim, pos=False) |
| 49 | self.co_attention_tv = co_attention(d_k=fea_dim, d_v=fea_dim, n_heads=self.num_heads, dropout=self.dropout, d_model=fea_dim, |
| 50 | visual_len=self.num_frames, sen_len=512, fea_v=self.dim, fea_s=self.dim, pos=False) |
| 51 | self.trm = nn.TransformerEncoderLayer(d_model = self.dim, nhead = 2, batch_first = True) |
| 52 | |
| 53 | |
| 54 | self.linear_text = nn.Sequential(torch.nn.Linear(self.text_dim, fea_dim), torch.nn.ReLU(),nn.Dropout(p=self.dropout)) |
| 55 | self.linear_comment = nn.Sequential(torch.nn.Linear(self.comment_dim, fea_dim), torch.nn.ReLU(),nn.Dropout(p=self.dropout)) |
| 56 | self.linear_img = nn.Sequential(torch.nn.Linear(self.img_dim, fea_dim), torch.nn.ReLU(),nn.Dropout(p=self.dropout)) |
| 57 | self.linear_video = nn.Sequential(torch.nn.Linear(self.video_dim, fea_dim), torch.nn.ReLU(),nn.Dropout(p=self.dropout)) |
| 58 | self.linear_intro = nn.Sequential(torch.nn.Linear(self.text_dim, fea_dim),torch.nn.ReLU(),nn.Dropout(p=self.dropout)) |
| 59 | self.linear_audio = nn.Sequential(torch.nn.Linear(fea_dim, fea_dim), torch.nn.ReLU(),nn.Dropout(p=self.dropout)) |
| 60 | |
| 61 | self.classifier = nn.Linear(fea_dim,2) |
| 62 | |
| 63 | def forward(self, **kwargs): |
| 64 |
nothing calls this directly
no test coverage detected