-
Notifications
You must be signed in to change notification settings - Fork 26.3k
Closed
Description
Issue description
In PyTorch version 0.4.1, the torch.sigmoid() computes wrong value (version 0.4.0 is OK). In the following code, on MacBook Pro (osx 10.13.6 no GPU), I got the following:
diff1 = 0.044759273529052734
diff2 = 0.0
diff3 = 0.0
Actually it is not hard to create more examples.
Code example
def test_slice_sigmoid():
a = torch.tensor([[[[-0.4999, -0.3056], [-0.4527, 0.2193]], [[ 0.2018, 0.0478], [ 0.0697, 0.0002]]]])
bbb = a[:, :, 1:2, :]
bbb_clone = bbb.clone()
bbb_numpy = bbb.numpy()
sigmoid_numpy = 1 / (1 + np.exp(-bbb_numpy))
sigmoid_torch_clone = torch.sigmoid(bbb_clone)
sigmoid_torch = torch.sigmoid(bbb)
sigmoid_torch_manual = 1 / (1 + torch.exp(-bbb))
diff1 = torch.sum(torch.abs(sigmoid_torch - sigmoid_torch_manual))
diff2 = torch.sum(torch.abs(sigmoid_numpy - sigmoid_torch_manual))
diff3 = torch.sum(torch.abs(sigmoid_torch_manual - sigmoid_torch_clone))
print('diff1 = ', diff1.item())
print('diff2 = ', diff2.item())
print('diff3 = ', diff3.item())
Metadata
Metadata
Assignees
Labels
No labels