sparse_modern_hopfield
A multiple instance learning classifier for bags of MNIST digits that pools instances with a sparse Hopfield layer.
23 operations Checked
Click or tap a spot to read it up close. Scroll or drag inside the diagram to move through it. Zoom with + and − or Ctrl and scroll. Press 0 for the whole graph. Swipe inside the diagram to move through it. Use + and − to zoom.
At a glance
- Parameters
- 1.5M
- Operations
- 23
- Framework
- PyTorch
- Recurrent
- No
- Published
- NeurIPS 2023
- Cited by
- 2 (as of 22 October 2026)
- Authors
- Jerry Yao-Chieh Hu, Donglin Yang, Dennis Wu and others
- License
- MIT
- Checked
- Passed: the trace was replayed operation by operation and matched the model's own output for this input.
Files
The file opened in a new tab. Use your browser's Save command there to keep it.
The diagram is a drawing of a TorchLens trace of the source code. It contains no code or weights.
Details
- Stable ID
- m10113
- Graph hash
- 4ad7420c43dba3b662ee020c71f8f163ee89e862b58f5f78609dd2daed62c521
- Skeleton hash
- 7951366004ac2d2ccd14358dede192a548d9086405b71b991ff90964c14ea151
- Architecture hash
- 98398788091304063c877ad583c8c0aef6f3a4d8ca50358b048f53deb55e67c5
- Diagram SHA-256
- cbe268bee043f754497e5d2f26a74840ae2c5ecc382762ab4502defa530f1893
- TorchLens version
- 2.36.0
- Renderer
- graphviz 2.43.0+pyvips 3.2.0+libvips 8.18.7+render-opts@06c1f0d3
- Check
- Forward pass replayed in PyTorch
What it is
The sparse modern Hopfield model is a sparse extension of the modern Hopfield model, a form of associative memory. The paper's motivation is that the dense retrieval of modern Hopfield models can be computationally inefficient and noise-sensitive, because it assigns probability mass to many implausible patterns. In the sparse model, the retrieval dynamics correspond to the sparsemax attention mechanism. The paper also gives a memory retrieval error bound that depends on sparsity and is provably tighter than the dense one.
For use inside networks, the paper introduces three layers as sparse analogs of the earlier Hopfield layers: SparseHopfield, SparseHopfieldPooling and SparseHopfieldLayer. SparseHopfieldPooling has learnable query patterns and can be read as a pooling operation over the input memory patterns. The paper applies these layers to multiple instance learning (MIL), where the goal is to predict the label of a bag from the instances it contains. On its synthetic bit pattern dataset, the paper reports that the sparse model performs better across all sparsity levels and all bag sizes.
The authors' code includes MNIST MIL experiments with a configurable bag size. This model is the classifier from those experiments with its Hopfield pooling in sparsemax mode, the setting the code labels Sparse Hopfield.
Key idea. The paper derives sparse memory retrieval dynamics from a closed-form sparse Hopfield energy and shows their one-step approximation is equivalent to sparse-structured attention.
- sparse modern hopfield model
- sparse hopfield
- sparsemodernhopfield
- sparse hopfield layer
- associative memory
- sparsemax attention
- multiple instance learning
- hopfield pooling
- mnist mil
AI-written summary, based on the paper and checked automatically against it; not reviewed by a person. Corrections welcome.
Cite the paper
@misc{hu2023sparsemodernhopfieldmodel,
title={On Sparse Modern Hopfield Model},
author={Jerry Yao-Chieh Hu and Donglin Yang and Dennis Wu and Chenwei Xu and Bo-Yu Chen and Han Liu},
year={2023},
eprint={2309.12673},
archivePrefix={arXiv},
primaryClass={cs.LG},
url={https://arxiv.org/abs/2309.12673},
}