MCPcopy Create free account
hub / github.com/dblalock/bolt / __init__

Method __init__

experiments/python/main.py:110–125  ·  view source on GitHub ↗
(self, dataset, code_bits=-1, bits_per_subvect=-1,
                 nsubvects=-1, elemwise_dist_func=dists_elemwise_sq)

Source from the content-addressed store, hash-verified

108class PQEncoder(object):
109
110 def __init__(self, dataset, code_bits=-1, bits_per_subvect=-1,
111 nsubvects=-1, elemwise_dist_func=dists_elemwise_sq):
112 X = dataset.X_train
113 self.elemwise_dist_func = elemwise_dist_func
114
115 tmp = _parse_codebook_params(X.shape[1], code_bits=code_bits,
116 bits_per_subvect=bits_per_subvect,
117 nsubvects=nsubvects)
118 self.nsubvects, self.ncentroids, self.subvect_len = tmp
119 self.code_bits = int(np.log2(self.ncentroids))
120
121 # for fast lookups via indexing into flattened array
122 self.offsets = np.arange(self.nsubvects, dtype=np.int) * self.ncentroids
123
124 self.centroids = _learn_centroids(X, self.ncentroids, self.nsubvects,
125 self.subvect_len)
126
127 def name(self):
128 return "PQ_{}x{}b".format(self.nsubvects, self.code_bits)

Callers

nothing calls this directly

Calls 2

_parse_codebook_paramsFunction · 0.85
_learn_centroidsFunction · 0.70

Tested by

no test coverage detected