def generateSingleHash(X, planesFileName, n_bits=64):
    """
    Generate a n_bits long hash for each input in X
    :param X:
    :param n_bits:
    :return:
    """
    import utils

    # overwrite old matrixes an build some random new ones
    fileName = os.path.join(utils.lsh_planes_dir, planesFileName + '.npz')
    lsh = LSHash(n_bits, np.shape(X)[0], matrices_filename=fileName, overwrite=False)

    return lsh._hash(lsh.uniform_planes[0], X.tolist())
def test():
    import utils

    trueIds, testSet = utils.load_test_set('fc7', 'raw', 0)

    lsh = LSHash(128, np.shape(testSet[0])[0], matrices_filename='lsh_planes.data.npz', overwrite=True)

    for idx, input_point in enumerate(testSet):
        hastValue = lsh._hash(lsh.uniform_planes[0], input_point.tolist())
        print hastValue

        lsh.index(input_point, idx)

    print lsh.query(testSet[3], 3)

    return None
Exemple #3
0
def generateSingleHash(X, planesFileName, n_bits=64):
    """
    Generate a n_bits long hash for each input in X
    :param X:
    :param n_bits:
    :return:
    """
    import utils

    # overwrite old matrixes an build some random new ones
    fileName = os.path.join(utils.lsh_planes_dir, planesFileName + '.npz')
    lsh = LSHash(n_bits,
                 np.shape(X)[0],
                 matrices_filename=fileName,
                 overwrite=False)

    return lsh._hash(lsh.uniform_planes[0], X.tolist())
def generateHashes(X, scalar, planesFileName, n_bits=64):
    """
    Generate a n_bits long hash for each input in X
    :param X:
    :param n_bits:
    :return:
    """
    import utils

    # overwrite old matrixes an build some random new ones
    fileName = os.path.join(utils.lsh_planes_dir, planesFileName + '.npz')
    lsh = LSHash(n_bits, np.shape(X[0])[0], matrices_filename=fileName, overwrite=False)
    hashValues = []
    for input_point in X:
        input_point = scalar.transform(input_point)
        hashValues.append(lsh._hash(lsh.uniform_planes[0], input_point))

    return hashValues
Exemple #5
0
def test():
    import utils

    trueIds, testSet = utils.load_test_set('fc7', 'raw', 0)

    lsh = LSHash(128,
                 np.shape(testSet[0])[0],
                 matrices_filename='lsh_planes.data.npz',
                 overwrite=True)

    for idx, input_point in enumerate(testSet):
        hastValue = lsh._hash(lsh.uniform_planes[0], input_point.tolist())
        print hastValue

        lsh.index(input_point, idx)

    print lsh.query(testSet[3], 3)

    return None
Exemple #6
0
def generateHashes(X, scalar, planesFileName, n_bits=64):
    """
    Generate a n_bits long hash for each input in X
    :param X:
    :param n_bits:
    :return:
    """
    import utils

    # overwrite old matrixes an build some random new ones
    fileName = os.path.join(utils.lsh_planes_dir, planesFileName + '.npz')
    lsh = LSHash(n_bits,
                 np.shape(X[0])[0],
                 matrices_filename=fileName,
                 overwrite=False)
    hashValues = []
    for input_point in X:
        input_point = scalar.transform(input_point)
        hashValues.append(lsh._hash(lsh.uniform_planes[0], input_point))

    return hashValues