Created
September 16, 2019 07:56
-
-
Save mdouze/2e53b12f0766b9f3df1770eed27d25d1 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
In [1]: import faiss | |
In [2]: import numpy as np | |
In [4]: d = 32 | |
In [5]: m = 4 | |
In [6]: c = 6 | |
In [7]: pq = faiss.ProductQuantizer(d, m, c) | |
In [8]: opq = faiss.OPQMatrix(d, m) | |
In [10]: opq.pq = pq | |
In [12]: opq.verbose = True | |
In [14]: x = np.random.rand(100, d).astype('float32') | |
In [15]: opq.train(x) | |
OPQMatrix::train: training an OPQ rotation matrix for M=4 from 100 vectors in 32D -> 32D | |
OPQMatrix::train: making random 32*32 rotation | |
Training PQ slice 0/4 | |
WARNING clustering 100 points to 64 centroids: please provide at least 2496 training points | |
Clustering 100 points in 8D to 64 clusters, redo 1 times, 40 iterations | |
Preprocessing in 0.00 s | |
Iteration 39 (0.49 s, search 0.35 s): objective=8.0993 imbalance=1.318 nsplit=0 | |
Training PQ slice 1/4 | |
WARNING clustering 100 points to 64 centroids: please provide at least 2496 training points | |
Clustering 100 points in 8D to 64 clusters, redo 1 times, 40 iterations | |
Preprocessing in 0.00 s | |
Iteration 39 (0.04 s, search 0.03 s): objective=8.07424 imbalance=1.318 nsplit=0 | |
.... | |
Training PQ slice 2/4 | |
WARNING clustering 100 points to 64 centroids: please provide at least 2496 training points | |
Clustering 100 points in 8D to 64 clusters, redo 1 times, 4 iterations | |
Using 64 centroids provided as input (not frozen) | |
Preprocessing in 0.00 s | |
Iteration 3 (0.00 s, search 0.00 s): objective=4.14809 imbalance=1.306 nsplit=0 | |
Training PQ slice 3/4 | |
WARNING clustering 100 points to 64 centroids: please provide at least 2496 training points | |
Clustering 100 points in 8D to 64 clusters, redo 1 times, 4 iterations | |
Using 64 centroids provided as input (not frozen) | |
Preprocessing in 0.00 s | |
Iteration 3 (0.00 s, search 0.00 s): objective=4.65961 imbalance=1.254 nsplit=0 | |
encode / decode | |
Iteration 49 (4 PQ iterations):1.730 s, obj=0.178715 | |
X * recons | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment