From 68acf5e2eea5c8dac90f38c1e7782456ec61faa6 Mon Sep 17 00:00:00 2001 From: lameeus Date: Mon, 20 Nov 2017 11:46:24 +0100 Subject: [PATCH] added absolute tolerance to handle comparing zeros --- tests/keras_contrib/backend/backend_test.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/tests/keras_contrib/backend/backend_test.py b/tests/keras_contrib/backend/backend_test.py index 998bc6b..1e4f344 100644 --- a/tests/keras_contrib/backend/backend_test.py +++ b/tests/keras_contrib/backend/backend_test.py @@ -157,8 +157,9 @@ class TestBackend(object): th_var_val = KTH.eval(th_var) tf_var_val = KTF.eval(tf_var) - assert_allclose(th_mean_val, tf_mean_val, rtol=1e-4) - assert_allclose(th_var_val, tf_var_val, rtol=1e-4) + # absolute tolerance needed when working with zeros + assert_allclose(th_mean_val, tf_mean_val, rtol=1e-4, atol=1e-10) + assert_allclose(th_var_val, tf_var_val, rtol=1e-4, atol=1e-10) def test_clip(self): check_single_tensor_operation('clip', (4, 2), min_value=0.4, max_value=0.6)