未验证 提交 343890b2 编写于 作者: L lijianshe02 提交者: GitHub

fix fpgm pruning memory bug runing on Windows test=develop (#285)

上级 b571201c
...@@ -57,17 +57,21 @@ def geometry_median(group, graph): ...@@ -57,17 +57,21 @@ def geometry_median(group, graph):
scores = [] scores = []
name, value, axis = group[0] name, value, axis = group[0]
assert (len(value.shape) == 4) assert (len(value.shape) == 4)
def get_distance_sum(value, out_idx):
w = value.view() w = value.view()
channel_num = value.shape[0]
w.shape = value.shape[0], np.product(value.shape[1:]) w.shape = value.shape[0], np.product(value.shape[1:])
x = w.repeat(channel_num, axis=0) selected_filter = np.tile(w[out_idx], (w.shape[0], 1))
y = np.zeros_like(x) x = w - selected_filter
for i in range(channel_num): x = np.sqrt(np.sum(x * x, -1))
y[i * channel_num:(i + 1) * channel_num] = np.tile(w[i], return x.sum()
(channel_num, 1))
tmp = np.sqrt(np.sum((x - y)**2, -1)) dist_sum_list = []
tmp = tmp.reshape((channel_num, channel_num)) for out_i in range(value.shape[0]):
tmp = np.sum(tmp, -1) dist_sum = get_distance_sum(value, out_i)
dist_sum_list.append(dist_sum)
tmp = np.array(dist_sum_list)
for name, value, axis in group: for name, value, axis in group:
scores.append((name, axis, tmp)) scores.append((name, axis, tmp))
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册