Sparse Resonance Networks is a research toolkit for building and evaluating sparse modern Hopfield-style associative memories. The project focuses on scalable modules, reproducible experiments, and approachable baselines that demonstrate how sparsity can improve memory retrieval efficiency.
- Modular Hopfield pooling layers with interchangeable sparsity mechanisms
- Ready-to-run experiments for MNIST and CIFAR multiple-instance learning
- Scripts for theoretical validation and visualization of convergence behaviour
- Lightweight configuration files for quick benchmarking and ablation studies
Create a fresh environment and install the core dependencies:
conda create -n sparse_resonance python=3.8
conda activate sparse_resonance
pip install -r requirement.txtRun the MNIST MIL demo with default hyperparameters:
python mnist_mil_main.py --bag_size 5For CIFAR MIL experiments:
python cifar_mil_main.py --dataset cifar10 --bag_size 20layers.py— entry point for Hopfield pooling layers with sparse, dense, entmax, and generalized sparse variantshflayers/andsparse_hflayers/— reference implementations of dense and sparse transformer blocksdatasets/— utilities for creating synthetic bags and loading real datasetstheoretical_results_validation/— scripts to replicate convergence and energy landscape figuresimgs/— sample plots from baseline experiments
python theoretical_results_validation/plotting.pypython real_world_mil.py --dataset fox --mode sparseKey arguments:
dataset:fox,tiger,ucsb,elephantmode:sparseorstandardcpus_per_trial: number of CPU cores to reserve per rungpus_per_trial: GPU allocation per run (0 or 1)gpus_id: comma-separated device IDs when GPUs are available
- Fork the repository and create a feature branch.
- Format code with
blackand run unit tests relevant to your change. - Open a pull request describing the motivation and experimental impact.
Bug reports and feature suggestions are welcome through issues. Please include reproduction steps and expected outcomes when possible.
This project is distributed under the terms of the MIT License.