We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 22df924 commit 229472bCopy full SHA for 229472b
test/test_nn.py
@@ -4116,6 +4116,16 @@ def func(root):
4116
gradcheck(func, [v])
4117
gradgradcheck(func, [v])
4118
4119
+ def test_bce_loss_always_nonnegative(self):
4120
+ target = torch.ones(5)
4121
+ input = torch.ones(5)
4122
+ assert ((nn.BCELoss()(input,target) < 0).sum() == 0)
4123
+
4124
+ target = torch.zeros(5)
4125
+ input = torch.zeros(5)
4126
+ print((nn.BCELoss()(input,target) < 0).sum)
4127
4128
4129
def test_bce_with_logits_raises_if_target_and_input_are_different_size(self):
4130
target = torch.rand(5)
4131
input = torch.rand(5, 1)
0 commit comments