Downloads · 30 days
0
1990two/hopfield_gnn
hopfield_gnn is a machine learning model from 1990two. Use it for the machine learning task on the model card, and read the license before you ship it in a product. It is set up for pytorch. The card lists the license as apache-2.0.
Graph Neural Networks with Hopfield-Style Associative Memory
Downloads · 30 days
0
Access
Public
Updated Aug 20, 2025
Repo size
—
Likes
0
Public
Click a slice to open those files.
.py46.6 KB · 90%
From the Hugging Face model README
Graph Neural Networks with Hopfield-Style Associative Memory
Experimental Research Code - Functional but unoptimized, expect rough edges
Hopfield Decision Graph combines Graph Neural Networks with Hopfield-style associative memory, where both nodes and edges maintain their own memory systems. Each edge can branch through learnable decision gates that mix multiple relation hypotheses, creating dynamic graph structures.
Core Innovation: Every edge becomes a decision point with multiple relation hypotheses, while Hopfield memories enable associative retrieval across the entire graph structure.
from hopfield_decision_graph import HopfieldDecisionGNN, HopfieldDecisionGNNConfig
# Configure the model
config = HopfieldDecisionGNNConfig(
dim=64,
layers=3,
mem_slots_nodes=128,
mem_slots_edges=64,
branches=4
)
# Create model
model = HopfieldDecisionGNN(config)
# Forward pass
x = torch.randn(batch_size, num_nodes, dim) # Node features
A = torch.randint(0, 2, (batch_size, num_nodes, num_nodes)) # Adjacency
output, aux = model(x, A)
The Hopfield memory retrieval uses content-based addressing:
attention_ij = softmax(q_i · k_j / √d)
retrieved_i = Σ_j attention_ij · v_j
Decision gates compute branch probabilities for each edge:
branch_weights_ij = softmax(MLP([x_i; x_j]) / τ)
The final adjacency emerges from branch mixing:
A'_ij = Σ_k branch_weights_ijk · hypothesis_k_ij
Message passing combines standard GNN updates with associative retrieval.
pip install torch numpy
# Download hopfield_decision_graph.py from this repo
Hopfield Decision Graph is part of a larger exploration of foundational algorithms enhanced with modern neural techniques:
@misc{hopfielddecision2025,
title={Hopfield Decision Graph: Associative Memory for Graph Neural Networks},
author={Jae Parker 𓅸 1990two},
year={2025},
note={Part of The Classics Revival Collection}
}