From f534c66d2d7d87aa580538513f4835439acd7bc0 Mon Sep 17 00:00:00 2001 From: flame Date: Tue, 22 Jan 2019 17:17:51 +0800 Subject: [PATCH] fix test_word2vec bug (#15462) fix test_word2vec float's equality bug --- python/paddle/fluid/tests/book/test_word2vec.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/python/paddle/fluid/tests/book/test_word2vec.py b/python/paddle/fluid/tests/book/test_word2vec.py index 48cb778927..487a29c839 100644 --- a/python/paddle/fluid/tests/book/test_word2vec.py +++ b/python/paddle/fluid/tests/book/test_word2vec.py @@ -220,9 +220,7 @@ def infer(use_cuda, save_dirname=None): np_data = np.array(results[0]) infer_out = infer_outputs[0].data.float_data() for a, b in zip(np_data[0], infer_out): - g_a = float("{:.6g}".format(a)) - g_b = float("{:.6g}".format(b)) - assert g_a == g_b + assert np.isclose(a, b), "a: {}, b: {}".format(a, b) def main(use_cuda, is_sparse, is_parallel): -- GitLab