Skip to content

Commit f534c66

Browse files
authored
fix test_word2vec bug (#15462)
fix test_word2vec float's equality bug
1 parent b3fdf70 commit f534c66

File tree

1 file changed

+1
-3
lines changed

1 file changed

+1
-3
lines changed

python/paddle/fluid/tests/book/test_word2vec.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -220,9 +220,7 @@ def to_infer_tensor(lod_tensor):
220220
np_data = np.array(results[0])
221221
infer_out = infer_outputs[0].data.float_data()
222222
for a, b in zip(np_data[0], infer_out):
223-
g_a = float("{:.6g}".format(a))
224-
g_b = float("{:.6g}".format(b))
225-
assert g_a == g_b
223+
assert np.isclose(a, b), "a: {}, b: {}".format(a, b)
226224

227225

228226
def main(use_cuda, is_sparse, is_parallel):

0 commit comments

Comments
 (0)