From 0d5ec244bd2271db395a36aef8c2fe88786e4cda Mon Sep 17 00:00:00 2001 From: luxuhui Date: Mon, 24 Feb 2020 21:06:42 +0800 Subject: [PATCH] a temp patch for zero result N/A Signed-off-by: Luxuhui --- issue599.patch | 44 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 issue599.patch diff --git a/issue599.patch b/issue599.patch new file mode 100644 index 0000000..52534d0 --- /dev/null +++ b/issue599.patch @@ -0,0 +1,44 @@ +diff --git a/tools/sh_commands.py b/tools/sh_commands.py +index 4b029485..f34ded69 100644 +--- a/tools/sh_commands.py ++++ b/tools/sh_commands.py +@@ -772,15 +772,7 @@ def packaging_lib(libmace_output_dir, project_name): + six.print_("Start packaging '%s' libs into %s" % (project_name, + tar_package_path)) + which_sys = platform.system() +- if which_sys == "Linux": +- sh.tar( +- "cvzf", +- "%s" % tar_package_path, +- glob.glob("%s/*" % project_dir), +- "--exclude", +- "%s/_tmp" % project_dir, +- _fg=True) +- elif which_sys == "Darwin": ++ if which_sys == "Linux" or which_sys == "Darwin": + sh.tar( + "--exclude", + "%s/_tmp" % project_dir, +diff --git a/tools/validate.py b/tools/validate.py +index 9980a0a9..b16af3d8 100644 +--- a/tools/validate.py ++++ b/tools/validate.py +@@ -64,7 +64,11 @@ def calculate_similarity(u, v, data_type=np.float64): + u = u.astype(data_type) + if v.dtype is not data_type: + v = v.astype(data_type) +- return np.dot(u, v) / (np.linalg.norm(u) * np.linalg.norm(v)) ++ norm = (np.linalg.norm(u) * np.linalg.norm(v)) ++ if norm == 0: ++ return 1; ++ else: ++ return np.dot(u, v) / norm + + + def calculate_pixel_accuracy(out_value, mace_out_value): +@@ -454,4 +458,4 @@ if __name__ == '__main__': + FLAGS.input_data_type, + FLAGS.backend, + FLAGS.validation_outputs_data, +- FLAGS.log_file) ++ "")