diff options
author | Igor Ganichev <iga@google.com> | 2018-08-10 13:40:00 -0700 |
---|---|---|
committer | TensorFlower Gardener <gardener@tensorflow.org> | 2018-08-10 13:48:35 -0700 |
commit | ba76f5ca8f722d8c66e4687d8a2161d858e9b407 (patch) | |
tree | 11320ba2e0de313af3bb72a568f210889393bd25 /tensorflow/compiler/tests/random_ops_test.py | |
parent | 79c95b754c241afe3dab741a895ffdbb9646bd65 (diff) |
Use global counter for XLA rng seed
PiperOrigin-RevId: 208260479
Diffstat (limited to 'tensorflow/compiler/tests/random_ops_test.py')
-rw-r--r-- | tensorflow/compiler/tests/random_ops_test.py | 14 |
1 files changed, 4 insertions, 10 deletions
diff --git a/tensorflow/compiler/tests/random_ops_test.py b/tensorflow/compiler/tests/random_ops_test.py index cc0e9b2f98..8c4e16e4e0 100644 --- a/tensorflow/compiler/tests/random_ops_test.py +++ b/tensorflow/compiler/tests/random_ops_test.py @@ -101,7 +101,7 @@ class RandomOpsTest(xla_test.XLATestCase): for dtype in [dtypes.float32]: with self.test_session() as sess: with self.test_scope(): - x = random_ops.truncated_normal(shape=[count], dtype=dtype, seed=42) + x = random_ops.truncated_normal(shape=[count], dtype=dtype) y = sess.run(x) def normal_cdf(x): @@ -130,24 +130,18 @@ class RandomOpsTest(xla_test.XLATestCase): # Department of Scientific Computing website. Florida State University. expected_mean = mu + (normal_pdf(alpha) - normal_pdf(beta)) / z * sigma actual_mean = np.mean(y) - atol = 2e-4 - if self.device in ["XLA_GPU", "XLA_CPU"]: - atol = 2.2e-4 - self.assertAllClose(actual_mean, expected_mean, atol=atol) + self.assertAllClose(actual_mean, expected_mean, atol=2e-3) expected_median = mu + probit( (normal_cdf(alpha) + normal_cdf(beta)) / 2.) * sigma actual_median = np.median(y) - self.assertAllClose(actual_median, expected_median, atol=1e-3) + self.assertAllClose(actual_median, expected_median, atol=1e-2) expected_variance = sigma**2 * (1 + ( (alpha * normal_pdf(alpha) - beta * normal_pdf(beta)) / z) - ( (normal_pdf(alpha) - normal_pdf(beta)) / z)**2) actual_variance = np.var(y) - rtol = 1e-3 - if self.device in ["XLA_GPU", "XLA_CPU"]: - rtol = 4e-4 - self.assertAllClose(actual_variance, expected_variance, rtol=rtol) + self.assertAllClose(actual_variance, expected_variance, rtol=2*1e-3) def testShuffle1d(self): # TODO(b/26783907): this test requires the CPU backend to implement sort. |