现代霍普菲尔德
- torchhd.memory.modern_hopfield(query: Tensor, memory: Tensor) Tensor[来源]
-
也被称为密集关联记忆。
- Parameters:
query (Tensor) – 用于内存查找的查询向量。
memory (Tensor) – 用于内存查找的内存项。
- Shapes:
查询: \((*, d)\)
内存:\((n, d)\)
结果: \((*, d)\)
- Examples::
>>> items = torchhd.random(6, 512) >>> read = memory.dense_associative(items, items).sign() >>> torchhd.cosine_similarity(read, items) tensor([[ 1.0000, 0.0469, -0.0117, 0.0039, -0.0313, -0.0078], [ 0.0469, 1.0000, -0.0352, -0.0039, -0.0391, -0.0078], [-0.0117, -0.0352, 1.0000, 0.0547, 0.0742, -0.0352], [ 0.0039, -0.0039, 0.0547, 1.0000, 0.0273, 0.0117], [-0.0313, -0.0391, 0.0742, 0.0273, 1.0000, -0.0547], [-0.0078, -0.0078, -0.0352, 0.0117, -0.0547, 1.0000]])