Take out 'row_index' row from embed_list and convert it to array
(embed_list, row_index, norm)
| 87 | |
| 88 | |
| 89 | def _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 | |
| 107 | def _extract_index(item_index_dict, query_list): |
no outgoing calls
no test coverage detected