本文整理匯總了Python中lshash.LSHash._hash方法的典型用法代碼示例。如果您正苦於以下問題:Python LSHash._hash方法的具體用法?Python LSHash._hash怎麽用?Python LSHash._hash使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類lshash.LSHash
的用法示例。
在下文中一共展示了LSHash._hash方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: generateSingleHash
# 需要導入模塊: from lshash import LSHash [as 別名]
# 或者: from lshash.LSHash import _hash [as 別名]
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())
示例2: test
# 需要導入模塊: from lshash import LSHash [as 別名]
# 或者: from lshash.LSHash import _hash [as 別名]
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
示例3: generateHashes
# 需要導入模塊: from lshash import LSHash [as 別名]
# 或者: from lshash.LSHash import _hash [as 別名]
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