From 098a0f732c813846bb6ddc821e0d38903d17e2d1 Mon Sep 17 00:00:00 2001 From: Qing Date: Tue, 31 Jul 2018 14:00:05 -0700 Subject: [PATCH 1/3] add fix to bce_loss --- tests/python/unittest/test_loss.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/python/unittest/test_loss.py b/tests/python/unittest/test_loss.py index 3c147bc4c723..5a4b85e7b5e6 100644 --- a/tests/python/unittest/test_loss.py +++ b/tests/python/unittest/test_loss.py @@ -84,7 +84,7 @@ def test_ce_loss(): assert mod.score(data_iter, eval_metric=mx.metric.Loss())[0][1] < 0.05 -@with_seed(1234) +@with_seed() def test_bce_loss(): N = 20 data = mx.random.uniform(-1, 1, shape=(N, 20)) @@ -107,7 +107,7 @@ def test_bce_loss(): prob_npy = 1.0 / (1.0 + np.exp(-data.asnumpy())) label_npy = label.asnumpy() npy_bce_loss = - label_npy * np.log(prob_npy) - (1 - label_npy) * np.log(1 - prob_npy) - assert_almost_equal(mx_bce_loss, npy_bce_loss) + assert_almost_equal(mx_bce_loss, npy_bce_loss, rtol=1e-4, atol=1e-5) @with_seed() def test_bce_equal_ce2(): From 0f6f1b0df5259d54d7ae75b8a81d7b9f4afa93fb Mon Sep 17 00:00:00 2001 From: Qing Date: Tue, 31 Jul 2018 15:55:58 -0700 Subject: [PATCH 2/3] add comments --- tests/python/unittest/test_loss.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tests/python/unittest/test_loss.py b/tests/python/unittest/test_loss.py index 5a4b85e7b5e6..325bc201cefe 100644 --- a/tests/python/unittest/test_loss.py +++ b/tests/python/unittest/test_loss.py @@ -83,7 +83,9 @@ def test_ce_loss(): initializer=mx.init.Xavier(magnitude=2)) assert mod.score(data_iter, eval_metric=mx.metric.Loss())[0][1] < 0.05 - +# @lanking520: getting rid of the fixed seed +# and add atol and rtol +# tracked at: https://github.com/apache/incubator-mxnet/issues/11691 @with_seed() def test_bce_loss(): N = 20 From b0adaf7651f8e0a1f250e84901f51bfbe2d2bee6 Mon Sep 17 00:00:00 2001 From: Qing Date: Fri, 3 Aug 2018 11:54:40 -0700 Subject: [PATCH 3/3] remove unecessary comments --- tests/python/unittest/test_loss.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/tests/python/unittest/test_loss.py b/tests/python/unittest/test_loss.py index 325bc201cefe..91ee011dac2e 100644 --- a/tests/python/unittest/test_loss.py +++ b/tests/python/unittest/test_loss.py @@ -83,8 +83,6 @@ def test_ce_loss(): initializer=mx.init.Xavier(magnitude=2)) assert mod.score(data_iter, eval_metric=mx.metric.Loss())[0][1] < 0.05 -# @lanking520: getting rid of the fixed seed -# and add atol and rtol # tracked at: https://github.com/apache/incubator-mxnet/issues/11691 @with_seed() def test_bce_loss():