mirror of
https://git.freebsd.org/ports.git
synced 2025-06-11 07:40:40 -04:00
16 lines
588 B
Python
16 lines
588 B
Python
import numpy as np
|
|
d = 64 # dimension
|
|
nb = 100000 # database size
|
|
nq = 10000 # nb of queries
|
|
np.random.seed(1234) # make reproducible
|
|
xb = np.random.random((nb, d)).astype('float32')
|
|
xb[:, 0] += np.arange(nb) / 1000.
|
|
xq = np.random.random((nq, d)).astype('float32')
|
|
xq[:, 0] += np.arange(nq) / 1000.
|
|
|
|
|
|
import faiss # make faiss available
|
|
index = faiss.IndexFlatL2(d) # build the index
|
|
print(index.is_trained)
|
|
index.add(xb) # add vectors to the index
|
|
print(index.ntotal)
|