hamming_similarity
- torchhd.hamming_similarity(input: VSATensor, others: VSATensor) LongTensor[source]
Hamming similarity is the number of equal elements between the input vectors and each vector in others.
- Parameters:
- Shapes:
Input: \((*, d)\)
Others: \((n, d)\) or \((d)\)
Output: \((*, n)\) or \((*)\), depends on shape of others
Examples:
>>> x = torchhd.random(3, 6) >>> x tensor([[ 1., 1., -1., -1., 1., 1.], [ 1., 1., 1., 1., -1., -1.], [ 1., 1., -1., -1., -1., 1.]]) >>> torchhd.hamming_similarity(x, x) tensor([[6, 2, 5], [2, 6, 3], [5, 3, 6]])