So Train_y is originally a numpy array, right?
What dtype is it?
I think a torch.FloatTensor generally contains 32 bit floats, I’m guessing that the numpy array isn’t a 32 bit float, maybe the conversion is altering the precision a little.
Another point concerns the limitations of floating point precision which can be seen with this example
print(1 - .8 - .2)
# outputs -5.551115123125783e-17 on my machine

Train_y == 0 means exactly equal which is probably too precise when Train_y is some sort of floating point datatype. It might make sense to change Train_y == 0 into abs(Train_y) < epsilon where epsilon is chosen to be some really small value such as 1e-8.