I have a matrix X of shape (N,D) ans a vector mu of shape(D,K). I tried subtracting one column of mu from one row of X and am getting the wrong answer. When I convert it to numpy array, I am getting the right answer. What am I doing wrong?
print(X[0,:])
print(mu[:,0])
print(X[0,:]-mu[:, 0])
print(X[0,:].data.numpy()-mu[:, 0].data.numpy())
tensor([-2.4682, 0.9872, -0.4661, 1.7443, 0.5375, -0.5948, 2.2457, -0.2980,
1.2467, 0.2932], dtype=torch.float64)
tensor([-1.5256, -0.6092, -0.7773, 0.4676, 0.8657, -0.1759, -0.7981, -0.4370,
0.2152, -0.8696], grad_fn=)
tensor([ -9.4257e-01, 1.1631e+00, -4.6614e-01, 1.7443e+00, 5.3751e-01,
-5.9480e-01, 2.2457e+00, -1.1146e+171, 2.1892e+00, 8.8797e-01],
dtype=torch.float64, grad_fn=)
[-0.94256972 1.59635256 0.31117838 1.27669038 -0.32818301 -0.41886666
3.0437956 0.13902091 1.03149757 1.16275023]