本文整理汇总了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