Comments (1)
Not sure such a nested PQ is useful of not, becuase a PQ with an increased parameter would be usually better. But the following nested PQ should work.
import nanopq
import numpy as np
N, D = 1000, 24
X = np.random.random((N, D)).astype(np.float32) # 1,000 24-dim vectors
# Instantiate with M=4 sub-spaces, with the number of centrods per sub-space is Ks=16
M, Ks = 4, 16
pq = nanopq.PQ(M=M, Ks=Ks)
# Train codewords
pq.fit(X)
# codewords
# The shape is (4, 16, 6), this means that:
# - 4 supspaces
# - 16 codewords for each supspace
# - A codeword is a 6-dim vector
print(pq.codewords.shape)
# Given the codewords, train second-level PQ instances
# For each subspace, create a PQ instance, with M=2 and Ks=4
second_level_pqs = []
for m in range(M):
second_level_pq = nanopq.PQ(M=2, Ks=4)
second_level_pq.fit(pq.codewords[m]) # Train by corresponding codewords
second_level_pqs.append(second_level_pq)
# Check
print(second_level_pqs[0].codewords.shape) # shape = (2, 4, 3)
from nanopq.
Related Issues (12)
- how to get top k closest neighbor without traverse entire dataset? HOT 2
- Travis to github actions HOT 1
- How to compute distance between PQ codes? HOT 1
- why with parametric init has poor performance than non-parametric one ? HOT 3
- Number of codewords for quantization HOT 2
- Typo HOT 1
- Turn print statements into logging HOT 3
- about reconstructed HOT 2
- No module named 'scipy.cluster' HOT 1
- How to compute codes similar to FAISS in NanoPQ HOT 1
- OPQ prints about Reconstruction error even with verbose=False HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from nanopq.