cleanup
- torchhd.cleanup(input: VSATensor, memory: VSATensor, threshold=0.0) VSATensor[source]
Gets the most similar hypervector in memory.
If the cosine similarity is less than threshold, raises a KeyError.
- Parameters:
- Shapes:
Input: \((d)\)
Memory: \((n, d)\)
Output: \((d)\)
Examples:
>>> x = torchhd.random(4, 6) >>> x tensor([[-1., 1., 1., -1., -1., -1.], [ 1., 1., -1., 1., -1., 1.], [-1., 1., -1., -1., 1., 1.], [ 1., -1., 1., 1., 1., -1.]]) >>> torchhd.cleanup(x[0], x) tensor([[-1., 1., 1., -1., -1., -1.]])