mirror of
https://github.com/wassname/Castor.git
synced 2026-08-20 12:00:37 +08:00
Fix HAN for batch_size 1 (#161)
This commit is contained in:
committed by
Ralph Tang
parent
97bdaec5bb
commit
3dd3ced661
@@ -23,7 +23,7 @@ class SentLevelRNN(nn.Module):
|
||||
sentence_h,_ = self.sentence_GRU(x)
|
||||
x = torch.tanh(self.sentence_linear(sentence_h))
|
||||
x = torch.matmul(x, self.sentence_context_wghts)
|
||||
x = x.squeeze()
|
||||
x = x.squeeze(dim=2)
|
||||
x = self.soft_sent(x.transpose(1,0))
|
||||
x = torch.mul(sentence_h.permute(2,0,1), x.transpose(1,0))
|
||||
x = torch.sum(x,dim = 1).transpose(1,0).unsqueeze(0)
|
||||
|
||||
@@ -41,7 +41,7 @@ class WordLevelRNN(nn.Module):
|
||||
h,_ = self.GRU(x)
|
||||
x = torch.tanh(self.linear(h))
|
||||
x = torch.matmul(x, self.word_context_wghts)
|
||||
x = x.squeeze()
|
||||
x = x.squeeze(dim=2)
|
||||
x = self.soft_word(x.transpose(1,0))
|
||||
x = torch.mul(h.permute(2,0,1), x.transpose(1,0))
|
||||
x = torch.sum(x, dim = 1).transpose(1,0).unsqueeze(0)
|
||||
|
||||
Reference in New Issue
Block a user