MCPcopy Create free account
hub / github.com/MotrixLab/MotionDiffuse / calculate_top_k

Function calculate_top_k

text2motion/utils/metrics.py:22–34  ·  view source on GitHub ↗
(mat, top_k)

Source from the content-addressed store, hash-verified

20 return dists
21
22def calculate_top_k(mat, top_k):
23 size = mat.shape[0]
24 gt_mat = np.expand_dims(np.arange(size), 1).repeat(size, 1)
25 bool_mat = (mat == gt_mat)
26 correct_vec = False
27 top_k_list = []
28 for i in range(top_k):
29# print(correct_vec, bool_mat[:, i])
30 correct_vec = (correct_vec | bool_mat[:, i])
31 # print(correct_vec)
32 top_k_list.append(correct_vec[:, None])
33 top_k_mat = np.concatenate(top_k_list, axis=1)
34 return top_k_mat
35
36
37def calculate_R_precision(embedding1, embedding2, top_k, sum_all=False):

Callers 2

evaluate_matching_scoreFunction · 0.85
calculate_R_precisionFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected