You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mxnet.apache.org by zh...@apache.org on 2018/03/31 05:40:30 UTC
[incubator-mxnet] branch master updated: [MXNET-258] Improve flaky
test_random.test_shuffle (#10313)
This is an automated email from the ASF dual-hosted git repository.
zhasheng pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-mxnet.git
The following commit(s) were added to refs/heads/master by this push:
new 201ec00 [MXNET-258] Improve flaky test_random.test_shuffle (#10313)
201ec00 is described below
commit 201ec0063c29b95648e7b1e5dffdeb2eec82d050
Author: Deokjae Lee <36...@users.noreply.github.com>
AuthorDate: Sat Mar 31 14:40:26 2018 +0900
[MXNET-258] Improve flaky test_random.test_shuffle (#10313)
* Fix random seed for test_shuffle
* A Comment for the fixed seed is added
* Set random seed to reproduce the failure of test_random.test_shuffle
* Add a link to the github issue on the discussion for the fixed seed
* Testing with the failed random seed and increased number of samples
* Increase the number of samples instead of fixing the random seed for test_shuffle
* Increase the number of samples instead of fixing the random seed for test_shuffle
---
tests/python/unittest/test_random.py | 10 ++++++----
1 file changed, 6 insertions(+), 4 deletions(-)
diff --git a/tests/python/unittest/test_random.py b/tests/python/unittest/test_random.py
index c8dc3c9..5138728 100644
--- a/tests/python/unittest/test_random.py
+++ b/tests/python/unittest/test_random.py
@@ -554,6 +554,7 @@ def test_zipfian_generator():
mx.test_utils.assert_almost_equal(exp_cnt_sampled.asnumpy(), exp_cnt[sampled_classes].asnumpy(), rtol=1e-1, atol=1e-2)
mx.test_utils.assert_almost_equal(exp_cnt_true.asnumpy(), exp_cnt[true_classes].asnumpy(), rtol=1e-1, atol=1e-2)
+# Issue #10277 (https://github.com/apache/incubator-mxnet/issues/10277) discusses this test.
@with_seed()
def test_shuffle():
def check_first_axis_shuffle(arr):
@@ -596,7 +597,8 @@ def test_shuffle():
# The outcomes must be uniformly distributed.
# If `repeat2` is not large enough, this could fail with high probability.
for p in itertools.permutations(range(0, data.size - stride + 1, stride)):
- assert abs(1. * count[str(mx.nd.array(p))] / repeat2 - 1. / math.factorial(data.shape[0])) < 0.01
+ err = abs(1. * count[str(mx.nd.array(p))] / repeat2 - 1. / math.factorial(data.shape[0]))
+ assert err < 0.01, "The absolute error {} is larger than the tolerance.".format(err)
# Check symbol interface
a = mx.sym.Variable('a')
b = mx.sym.random.shuffle(a)
@@ -622,9 +624,9 @@ def test_shuffle():
assert len(count) == repeat
# Test small arrays with different shapes
- testSmall(mx.nd.arange(0, 3), 100, 20000)
- testSmall(mx.nd.arange(0, 9).reshape((3, 3)), 100, 20000)
- testSmall(mx.nd.arange(0, 18).reshape((3, 2, 3)), 100, 20000)
+ testSmall(mx.nd.arange(0, 3), 100, 40000)
+ testSmall(mx.nd.arange(0, 9).reshape((3, 3)), 100, 40000)
+ testSmall(mx.nd.arange(0, 18).reshape((3, 2, 3)), 100, 40000)
# Test larger arrays
testLarge(mx.nd.arange(0, 100000).reshape((10, 10000)), 10)
testLarge(mx.nd.arange(0, 100000).reshape((10000, 10)), 10)
--
To stop receiving notification emails like this one, please contact
zhasheng@apache.org.