hopfield
- torchhd.memory.hopfield(query: Tensor, memory: Tensor, kappa: int | None = None) Tensor[source]
-
- Parameters:
query (Tensor) – The query vector for the memory lookup.
memory (Tensor) – The items of memory for the memory lookup.
- Shapes:
Query: \((*, d)\)
Memory: \((n, d)\)
Result: \((*, d)\)
- Examples::
>>> items = torchhd.random(6, 512) >>> read = memory.hopfield(items, items).sign() >>> torchhd.cosine_similarity(read, items) tensor([[ 1.0000, 0.0156, -0.0039, -0.0742, 0.0000, -0.0195], [ 0.0156, 1.0000, -0.0352, -0.0586, 0.0000, -0.0039], [-0.0039, -0.0352, 1.0000, 0.0156, 0.0820, -0.0234], [-0.0742, -0.0586, 0.0156, 1.0000, -0.0039, 0.0000], [ 0.0000, 0.0000, 0.0820, -0.0039, 1.0000, 0.0195], [-0.0195, -0.0039, -0.0234, 0.0000, 0.0195, 1.0000]])