Skip to content

Commit

Permalink
a temp patch for zero result
Browse files Browse the repository at this point in the history
N/A

Signed-off-by: Luxuhui <[email protected]>
  • Loading branch information
lu229 committed Feb 24, 2020
1 parent add9809 commit 0d5ec24
Showing 1 changed file with 44 additions and 0 deletions.
44 changes: 44 additions & 0 deletions issue599.patch
Original file line number Diff line number Diff line change
@@ -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)
+ "")

0 comments on commit 0d5ec24

Please sign in to comment.