def forward(self, x, tags, hn_tags, chunks, hn_chunks, deps, hn_deps):
tags = tags.view(1, -1, nb_postags)
chunks = chunks.view(1, -1, nb_chunktags)
deps = deps.view(1, deps.size(0), deps.size(1))
gt = torch.cat([hn_chunks, hn_tags, hn_deps, x, tags, chunks, deps], dim=2)
pad = torch.zeros(1, x.size(1), self.input_size - gt.size(2))
pad = Variable(pad)
gt = torch.cat([gt, pad], dim=2)
out, hn = self.bi_lstm(gt, (self.h[:,:x.size(1),:],
self.w[:,:x.size(1),:]))
sentiment = self.fc(out[0,-1].view(1,-1))
sentiment = F.sigmoid(sentiment)
return sentiment, out
sentiment.py 文件源码
python
阅读 24
收藏 0
点赞 0
评论 0
评论列表
文章目录