Skip to content

Commit c94b0ce

Browse files
author
ryan.smith
committed
Change assert_equal to assert_almost_equal
1 parent 942e8a7 commit c94b0ce

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

test/classification/test_loss.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,15 +19,15 @@ def test_sce_equals_ce(self):
1919

2020
ce_loss = F.cross_entropy(Y_probs, Y_golds, reduction="none")
2121
ces_loss = cross_entropy_with_probs(Y_probs, Y_golds_probs, reduction="none")
22-
np.testing.assert_equal(ce_loss.numpy(), ces_loss.numpy())
22+
np.testing.assert_almost_equal(ce_loss.numpy(), ces_loss.numpy())
2323

2424
ce_loss = F.cross_entropy(Y_probs, Y_golds, reduction="sum")
2525
ces_loss = cross_entropy_with_probs(Y_probs, Y_golds_probs, reduction="sum")
26-
np.testing.assert_equal(ce_loss.numpy(), ces_loss.numpy())
26+
np.testing.assert_almost_equal(ce_loss.numpy(), ces_loss.numpy())
2727

2828
ce_loss = F.cross_entropy(Y_probs, Y_golds, reduction="mean")
2929
ces_loss = cross_entropy_with_probs(Y_probs, Y_golds_probs, reduction="mean")
30-
np.testing.assert_equal(ce_loss.numpy(), ces_loss.numpy())
30+
np.testing.assert_almost_equal(ce_loss.numpy(), ces_loss.numpy())
3131

3232
def test_perfect_predictions(self):
3333
# Does soft ce loss achieve approx. 0 loss with perfect predictions?
@@ -39,7 +39,7 @@ def test_perfect_predictions(self):
3939
Y_probs[Y_probs == 0] = -100
4040

4141
ces_loss = cross_entropy_with_probs(Y_probs, Y_golds_probs)
42-
np.testing.assert_equal(ces_loss.numpy(), 0)
42+
np.testing.assert_almost_equal(ces_loss.numpy(), 0)
4343

4444
def test_lower_loss(self):
4545
# Is loss lower when it should be?

0 commit comments

Comments
 (0)