Esempio n. 1
0
from vecs_io import *
from run_pq import execute
from opq import OPQ
from run_pq import parse_args


if __name__ == '__main__':
    dataset = 'netflix'
    topk = 20
    codebook = 4
    Ks = 256
    metric = 'product'

    # override default parameters with command line parameters
    import sys
    if len(sys.argv) > 3:
        dataset, topk, codebook, Ks, metric = parse_args()
    else:
        import warnings
        warnings.warn("Using  Default Parameters ")
    print("# Parameters: dataset = {}, topK = {}, codebook = {}, Ks = {}, metric = {}"
          .format(dataset, topk, codebook, Ks, metric))

    X, T, Q, G = loader(dataset, topk, metric, folder='data/')
    # pq, rq, or component of norm-pq
    quantizer = OPQ(M=codebook-1, Ks=Ks)
    execute(quantizer, X, T, Q, G, metric)
Esempio n. 2
0
from run_pq import parse_args
import _init_paths
from util.vecs import vecs_io
from util import dir_io

if __name__ == '__main__':
    dataset = 'siftsmall_normal'
    k_gnd = 10
    codebook = 8
    n_cluster = 16
    metric = 'euclid_norm'

    # override default parameters with command line parameters
    import sys
    if len(sys.argv) > 3:
        dataset, k_gnd, codebook, n_cluster, metric = parse_args()
    else:
        import warnings
        warnings.warn("Using  Default Parameters ")
    print(
        "# Parameters: dataset = {}, topK = {}, codebook = {}, n_cluster = {}, metric = {}"
        .format(dataset, k_gnd, codebook, n_cluster, metric))

    load_data_config = {'data_dir': 'data/dataset/%s_%d' % (dataset, k_gnd)}
    X, Q, G, base_base_gnd = vecs_io.read_data_l2(load_data_config)
    # pq, rq, or component of norm-pq
    quantizer = OPQ(M=codebook, Ks=n_cluster)
    exe_config = {
        'dataset': dataset,
        'codebook': codebook,
        'n_cluster': n_cluster,