| @@ 191-203 (lines=13) @@ | ||
| 188 | return raw_vectors, binary_vectors |
|
| 189 | ||
| 190 | ||
| 191 | def gen_binary_sub_vectors(vectors, length): |
|
| 192 | raw_vectors = [] |
|
| 193 | binary_vectors = [] |
|
| 194 | dim = len(vectors[0]) |
|
| 195 | for i in range(length): |
|
| 196 | raw_vector = [0 for i in range(dim)] |
|
| 197 | vector = vectors[i] |
|
| 198 | for index, j in enumerate(vector): |
|
| 199 | if j == 1: |
|
| 200 | raw_vector[index] = 1 |
|
| 201 | raw_vectors.append(raw_vector) |
|
| 202 | binary_vectors.append(bytes(np.packbits(raw_vector, axis=-1).tolist())) |
|
| 203 | return raw_vectors, binary_vectors |
|
| 204 | ||
| 205 | ||
| 206 | def gen_binary_super_vectors(vectors, length): |
|
| @@ 185-197 (lines=13) @@ | ||
| 182 | return raw_vectors, binary_vectors |
|
| 183 | ||
| 184 | ||
| 185 | def gen_binary_sub_vectors(vectors, length): |
|
| 186 | raw_vectors = [] |
|
| 187 | binary_vectors = [] |
|
| 188 | dim = len(vectors[0]) |
|
| 189 | for i in range(length): |
|
| 190 | raw_vector = [0 for i in range(dim)] |
|
| 191 | vector = vectors[i] |
|
| 192 | for index, j in enumerate(vector): |
|
| 193 | if j == 1: |
|
| 194 | raw_vector[index] = 1 |
|
| 195 | raw_vectors.append(raw_vector) |
|
| 196 | binary_vectors.append(bytes(np.packbits(raw_vector, axis=-1).tolist())) |
|
| 197 | return raw_vectors, binary_vectors |
|
| 198 | ||
| 199 | ||
| 200 | def gen_binary_super_vectors(vectors, length): |
|