Hi, I am a beginner in PyTorch, and recently faced an issue. Tried thinking a lot but couldn’t figure it out.
Consider we have two matrices
#take c = 500
x = torch.randn(c,c)
y = torch.randn(c,c)
And we do this :
r1 = torch.sum(x*y,axis=1)
Alternatively, if we instead take transpose of second matrix, and then perform a matrix multiplication and consider only diagonal elements, we should get the same answer.
So, we do this :
r2 = torch.diag(torch.mm(x,y.transpose(0,1)))
If we now compare for equality of the two :
r1==r2
Ideally we should get all True because they are same thing, but I get some False.
What exactly is going wrong? Can someone point out the mistake?