You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mxnet.apache.org by GitBox <gi...@apache.org> on 2018/08/20 19:20:43 UTC

[GitHub] szha closed pull request #12192: Fix flaky tests in control flow

szha closed pull request #12192: Fix flaky tests in control flow
URL: https://github.com/apache/incubator-mxnet/pull/12192
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git a/tests/python/unittest/test_contrib_control_flow.py b/tests/python/unittest/test_contrib_control_flow.py
index a4b794c9595..76d0218775b 100644
--- a/tests/python/unittest/test_contrib_control_flow.py
+++ b/tests/python/unittest/test_contrib_control_flow.py
@@ -237,11 +237,11 @@ def _zeros_like_dict(name_list):
     for imp_out, sym_out in zip(imp_outs, sym_outs):
         if imp_out is None or sym_out is None:
             continue
-        assert_almost_equal(imp_out, sym_out, rtol=1e-4, atol=1e-4)
+        assert_almost_equal(imp_out, sym_out, rtol=1e-3, atol=1e-3)
     for imp_grad, sym_grad in zip(imp_grads, sym_grads):
         if imp_grad is None or sym_grad is None:
             continue
-        assert_almost_equal(imp_grad, sym_grad, rtol=1e-4, atol=1e-4)
+        assert_almost_equal(imp_grad, sym_grad, rtol=1e-3, atol=1e-3)
 
 
 @with_seed()
@@ -888,9 +888,9 @@ def _get_sym_result(is_train, args, args_grad, out_grad):
         assert len(imp_out) == len(sym_out)
         assert len(imp_grad) == len(sym_grad)
         for x, y in zip(imp_out, sym_out):
-            assert_almost_equal(x, y, rtol=1e-4, atol=1e-4)
+            assert_almost_equal(x, y, rtol=1e-3, atol=1e-3)
         for x, y in zip(imp_grad, sym_grad):
-            assert_almost_equal(x, y, rtol=1e-4, atol=1e-4)
+            assert_almost_equal(x, y, rtol=1e-3, atol=1e-3)
 
 
 @with_seed()
@@ -966,14 +966,14 @@ def _func(*states):
             for x, y in zip(e_1.outputs, e_2.outputs):
                 x = x.asnumpy()
                 y = y.asnumpy()
-                assert_almost_equal(x, y, rtol=1e-4, atol=1e-4)
+                assert_almost_equal(x, y, rtol=1e-3, atol=1e-3)
             grad_keys = list(e_2.grad_dict.keys())
             e_1_grad = [e_1.grad_dict[x] for x in grad_keys]
             e_2_grad = [e_2.grad_dict[x] for x in grad_keys]
             for x, y in zip(e_1_grad, e_2_grad):
                 x = x.asnumpy()
                 y = y.asnumpy()
-                assert_almost_equal(x, y, rtol=1e-4, atol=1e-4)
+                assert_almost_equal(x, y, rtol=1e-3, atol=1e-3)
 
 def _verify_cond(cond_func, then_func, else_func, input_var_shapes, free_var_shapes, is_train):
 
@@ -1053,11 +1053,11 @@ def _get_symbolic_result(out_grads):
     for imp_out, sym_out in zip(imp_outs, sym_outs):
         if imp_out is None or sym_out is None:
             continue
-        assert_almost_equal(imp_out, sym_out, rtol=1e-5, atol=1e-5)
+        assert_almost_equal(imp_out, sym_out, rtol=1e-3, atol=1e-3)
     for imp_grad, sym_grad in zip(imp_grads, sym_grads):
         if imp_grad is None or sym_grad is None:
             continue
-        assert_almost_equal(imp_grad, sym_grad, rtol=1e-5, atol=1e-5)
+        assert_almost_equal(imp_grad, sym_grad, rtol=1e-3, atol=1e-3)
 
 
 @with_seed()
@@ -1174,7 +1174,7 @@ def check_contrib_rnn(cell_type, num_states):
         trainer = gluon.Trainer(params2, 'sgd', {'learning_rate' : 0.03})
         with mx.autograd.record():
             res2 = layer(rnn_data, states)
-        assert_almost_equal(res1.asnumpy(), res2.asnumpy(), rtol=0.001, atol=0.0001)
+        assert_almost_equal(res1.asnumpy(), res2.asnumpy(), rtol=1e-3, atol=1e-3)
         res2.backward()
         trainer.step(batch_size)
 
@@ -1182,7 +1182,7 @@ def check_contrib_rnn(cell_type, num_states):
             weight1 = val.data()
             weight2 = params2[key].data()
             assert_almost_equal(weight1.asnumpy(), weight2.asnumpy(),
-                    rtol=0.001, atol=0.0001)
+                    rtol=1e-3, atol=1e-3)
 
 
 @with_seed()
@@ -1294,7 +1294,7 @@ def verify_foreach(step, in_syms, state_syms, free_syms,
         for i in range(len(outs)):
             assert e.outputs[i].shape == outs[i].shape
             assert_almost_equal(e.outputs[i].asnumpy(), outs[i].asnumpy(),
-                    rtol=0.001, atol=0.0001)
+                    rtol=1e-3, atol=1e-3)
         if (is_train):
             all_ins = _as_list(in_arrs)[:]
             all_ins.extend(init_states)
@@ -1303,7 +1303,7 @@ def verify_foreach(step, in_syms, state_syms, free_syms,
             for i in range(size):
                 assert_almost_equal(all_ins[i].grad.asnumpy(),
                         e.grad_arrays[i].asnumpy(),
-                        rtol=0.001, atol=0.0001)
+                        rtol=1e-3, atol=1e-3)
 
     # Test cases:
     # * graph inputs are stored in different orders.
@@ -1559,11 +1559,11 @@ def step_nd(in1, states):
         assert isinstance(states, list)
         assert len(states) == 1
         res = mx.nd.broadcast_add(out, states[0])
-    assert_almost_equal(res.asnumpy(), e.outputs[0].asnumpy(), rtol=0.001, atol=0.0001)
+    assert_almost_equal(res.asnumpy(), e.outputs[0].asnumpy(), rtol=1e-3, atol=1e-3)
 
     res.backward(out_grads[0])
-    assert_almost_equal(data.grad.asnumpy(), data_grad.asnumpy())
-    assert_almost_equal(state.grad.asnumpy(), state_grad.asnumpy())
+    assert_almost_equal(data.grad.asnumpy(), data_grad.asnumpy(), rtol=1e-3, atol=1e-3)
+    assert_almost_equal(state.grad.asnumpy(), state_grad.asnumpy(), rtol=1e-3, atol=1e-3)
 
 
 def check_foreach_rnn(cell_type, num_states):
@@ -1649,12 +1649,12 @@ def sym_group(out):
 
         for i in range(len(outputs2)):
             assert_almost_equal(outputs1[i].asnumpy(), outputs2[i].asnumpy(),
-                    rtol=0.001, atol=0.0001)
+                    rtol=1e-3, atol=1e-3)
         input_names = out.list_inputs()
         for i in range(len(e1.grad_arrays)):
             name = input_names[i]
             assert_almost_equal(args_grad1[name].asnumpy(), args_grad2[name].asnumpy(),
-                    rtol=0.001, atol=0.0001)
+                    rtol=1e-3, atol=1e-3)
 
 
 @with_seed()
@@ -1696,7 +1696,7 @@ def step2(data, states):
 
     with mx.autograd.record():
         res2 = layer(data, [states])
-    assert_almost_equal(res1.asnumpy(), res2.asnumpy(), rtol=0.001, atol=0.0001)
+    assert_almost_equal(res1.asnumpy(), res2.asnumpy(), rtol=1e-3, atol=1e-3)
 
 
 @with_seed()
@@ -1730,7 +1730,7 @@ def hybrid_forward(self, F, data):
     res2 = layer(data)
     with mx.autograd.record():
         res2 = layer(data)
-    assert_almost_equal(res1.asnumpy(), res2.asnumpy(), rtol=0.001, atol=0.0001)
+    assert_almost_equal(res1.asnumpy(), res2.asnumpy(), rtol=1e-3, atol=1e-3)
 
 
 @with_seed()
@@ -1762,7 +1762,7 @@ def hybrid_forward(self, F, data):
     res2 = layer(data)
     with mx.autograd.record():
         res2 = layer(data)
-    assert_almost_equal(res1.asnumpy(), res2.asnumpy(), rtol=0.001, atol=0.0001)
+    assert_almost_equal(res1.asnumpy(), res2.asnumpy(), rtol=1e-3, atol=1e-3)
 
 
 if __name__ == '__main__':


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services