How can I print the shape of a tensor inside the forward 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> Any suggestion?
wasiahmad
jekbradbury
Nabarun_Goswami
Mithun_Paul
kingxueyuf
jekbradbury
Use print(embedded) to see the shape, or embedded.eval() If you want to see the content, embedded.weight will show you the tensor and if it requires grad.
eduamf