How to resolve the RuntimeError related to torch.cat() function?
I have an attention decoder whose forward function is as follows. <SCODE>def forward(self, input, hidden, encoder_outputs):
    embedded = self.embedding(input).view(1, 1, -1)
    embedded = self.drop(embedded)
    attn_weights = F.softmax(self.attn(torch.cat((embedded[0], hidden[0]), 1)))
<ECODE> When ever the forward function gets called, I get the following error. How to resolve this problem? The problem is associated with torch.cat(). Please help.
wasiahmad
you can add prints to figure out the problematic tensor shape for torch.cat
smth
Thanks for your reply. I printed the shape and found the following. <SCODE>embedded = self.embedding(input).view(1, 1, -1)
embedded = self.drop(embedded)
print(embedded[0].size(), hidden[0].size())
<ECODE>
wasiahmad
Spider101
wasiahmad
Spider101
Now it makes sense! Thanks.
wasiahmad