Faiss: Getting the centroids of an IndexIVF

Created on 24 Sep 2019  路  2Comments  路  Source: facebookresearch/faiss

@mdouze
How do I get the value of IVF centroids from a trained IndexIVFPQ file with python?
I have tried index_ivfpq.quantizer.xb and index_ivfpq.xb.
Could you help me out?
Thanks a lot!

_Originally posted by @BeginnerW in https://github.com/facebookresearch/faiss/issues/933#issuecomment-534513733_

question

Most helpful comment

You can do it with

import numpy as np
import faiss

x = np.random.rand(10000, 32).astype('float32')
index = faiss.index_factory(32, "IVF100,PQ4np")
index.train(x)
centroids = index.quantizer.reconstruct_n(0, index.nlist)

All 2 comments

You can do it with

import numpy as np
import faiss

x = np.random.rand(10000, 32).astype('float32')
index = faiss.index_factory(32, "IVF100,PQ4np")
index.train(x)
centroids = index.quantizer.reconstruct_n(0, index.nlist)

no activity, closing.

Was this page helpful?
0 / 5 - 0 ratings