The following code results in nan, but as far as I can tell it shouldn’t?
def batch_outer_product(x: torch.autograd.Variable, y: torch.autograd.Variable):
result = []
for xv, yv in zip(x, y):
result.append(xv.ger(yv).view(1, -1))
result = torch.cat(result, 0)
return result
x = torch.autograd.Variable(torch.ones(50,64), requires_grad=True)
y = torch.autograd.Variable(torch.ones(50,64), requires_grad=True)
xy = batch_outer_product(x,y)
loss = xy.sum()
print(loss)