MCPcopy Create free account
hub / github.com/Tencent/embedx / _slice_to_array

Function _slice_to_array

demo/hit_rate.py:89–104  ·  view source on GitHub ↗

Take out 'row_index' row from embed_list and convert it to array

(embed_list, row_index, norm)

Source from the content-addressed store, hash-verified

87
88
89def _slice_to_array(embed_list, row_index, norm):
90 """Take out 'row_index' row from embed_list and convert it to array"""
91
92 if not row_index:
93 row_index = np.arange(len(embed_list))
94
95 array = np.asarray(embed_list)[row_index, 0:].astype(np.float32)
96 logging.info('Array shape is %d, %d', array.shape[0], array.shape[1])
97
98 if norm:
99 logging.info("Normalizing embedding matrix ...")
100 preprocessing.normalize(array, axis=1, copy=False)
101
102 logging.info("Slicing to array done.")
103
104 return array
105
106
107def _extract_index(item_index_dict, query_list):

Callers 2

eval_hit_rateFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected