From 1cd72270c1b6b8f392d6b6687fc5f0e75fc3c66a Mon Sep 17 00:00:00 2001 From: Xi Wang Date: Wed, 29 Jul 2020 06:08:11 +0000 Subject: [PATCH 1/2] make parameter smoother --- tests/python/unittest/test_gluon_probability_v1.py | 8 ++++---- tests/python/unittest/test_gluon_probability_v2.py | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/tests/python/unittest/test_gluon_probability_v1.py b/tests/python/unittest/test_gluon_probability_v1.py index 92721f610495..a95256a5fb3a 100644 --- a/tests/python/unittest/test_gluon_probability_v1.py +++ b/tests/python/unittest/test_gluon_probability_v1.py @@ -837,7 +837,7 @@ def hybrid_forward(self, F, alpha, *args): dirichlet = mgp.Dirichlet(alpha, F, validate_args=True) return _distribution_method_invoker(dirichlet, self._func, *args) - event_shapes = [2, 5, 10] + event_shapes = [2, 4, 6] batch_shapes = [None, (2, 3)] # Test sampling @@ -845,7 +845,7 @@ def hybrid_forward(self, F, alpha, *args): for hybridize in [True, False]: desired_shape = ( batch_shape if batch_shape is not None else ()) + (event_shape,) - alpha = np.random.uniform(size=desired_shape) + alpha = np.random.uniform(1.0, 5.0, size=desired_shape) net = TestDirichlet("sample") if hybridize: net.hybridize() @@ -862,9 +862,9 @@ def hybrid_forward(self, F, alpha, *args): for hybridize in [True, False]: desired_shape = ( batch_shape if batch_shape is not None else ()) + (event_shape,) - alpha = np.random.uniform(size=desired_shape) + alpha = np.random.uniform(1.0, 5.0, desired_shape) np_samples = _np.random.dirichlet( - [1 / event_shape] * event_shape, size=batch_shape) + [10.0 / event_shape] * event_shape, size=batch_shape) net = TestDirichlet("log_prob") if hybridize: net.hybridize() diff --git a/tests/python/unittest/test_gluon_probability_v2.py b/tests/python/unittest/test_gluon_probability_v2.py index 9a36b4fc7056..e6359fc96825 100644 --- a/tests/python/unittest/test_gluon_probability_v2.py +++ b/tests/python/unittest/test_gluon_probability_v2.py @@ -837,7 +837,7 @@ def forward(self, alpha, *args): dirichlet = mgp.Dirichlet(alpha, validate_args=True) return _distribution_method_invoker(dirichlet, self._func, *args) - event_shapes = [2, 5, 10] + event_shapes = [2, 4, 6] batch_shapes = [None, (2, 3)] # Test sampling @@ -845,7 +845,7 @@ def forward(self, alpha, *args): for hybridize in [True, False]: desired_shape = ( batch_shape if batch_shape is not None else ()) + (event_shape,) - alpha = np.random.uniform(size=desired_shape) + alpha = np.random.uniform(1.0, 5.0, size=desired_shape) net = TestDirichlet("sample") if hybridize: net.hybridize() @@ -862,9 +862,9 @@ def forward(self, alpha, *args): for hybridize in [True, False]: desired_shape = ( batch_shape if batch_shape is not None else ()) + (event_shape,) - alpha = np.random.uniform(size=desired_shape) + alpha = np.random.uniform(1.0, 5.0, size=desired_shape) np_samples = _np.random.dirichlet( - [1 / event_shape] * event_shape, size=batch_shape) + [10.0 / event_shape] * event_shape, size=batch_shape) net = TestDirichlet("log_prob") if hybridize: net.hybridize() From 03472a29b09466d12369c58fe7ae93089371ce69 Mon Sep 17 00:00:00 2001 From: Xi Wang Date: Wed, 29 Jul 2020 06:14:19 +0000 Subject: [PATCH 2/2] minor changes --- tests/python/unittest/test_gluon_probability_v1.py | 4 ++-- tests/python/unittest/test_gluon_probability_v2.py | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/python/unittest/test_gluon_probability_v1.py b/tests/python/unittest/test_gluon_probability_v1.py index 5805677c0dfb..0fece99bb6d7 100644 --- a/tests/python/unittest/test_gluon_probability_v1.py +++ b/tests/python/unittest/test_gluon_probability_v1.py @@ -341,7 +341,7 @@ def hybrid_forward(self, F, loc, scale, *args): for shape, hybridize in itertools.product(shapes, [True, False]): loc = np.random.uniform(-1, 1, shape) scale = np.random.uniform(0.5, 1.5, shape) - samples = np.random.uniform(size=shape, high=1.0-1e-4) + samples = np.random.uniform(size=shape, low=1e-4, high=1.0-1e-4) net = TestCauchy("icdf") if hybridize: net.hybridize() @@ -879,7 +879,7 @@ def hybrid_forward(self, F, alpha, *args): for func in ['mean', 'variance', 'entropy']: desired_shape = ( batch_shape if batch_shape is not None else ()) + (event_shape,) - alpha = np.random.uniform(size=desired_shape) + alpha = np.random.uniform(1.0, 5.0, desired_shape) net = TestDirichlet(func) if hybridize: net.hybridize() diff --git a/tests/python/unittest/test_gluon_probability_v2.py b/tests/python/unittest/test_gluon_probability_v2.py index 6ae2b9011267..dc8ac1476ea9 100644 --- a/tests/python/unittest/test_gluon_probability_v2.py +++ b/tests/python/unittest/test_gluon_probability_v2.py @@ -879,7 +879,7 @@ def forward(self, alpha, *args): for func in ['mean', 'variance', 'entropy']: desired_shape = ( batch_shape if batch_shape is not None else ()) + (event_shape,) - alpha = np.random.uniform(size=desired_shape) + alpha = np.random.uniform(1.0, 5.0, desired_shape) net = TestDirichlet(func) if hybridize: net.hybridize()