Skip to main content
QUICK REVIEW

[Paper Review] Hopfield Networks is All You Need

Hubert Ramsauer, Bernhard Schäfl|arXiv (Cornell University)|Jul 16, 2020
Cognitive Science and Education Research106 references72 citations
TL;DR

The paper introduces modern continuous-state Hopfield networks that act as differentiable memory layers, equivalent to transformer attention, enabling exponential storage and one-shot retrieval, and demonstrates their effectiveness across MIL, immune repertoire, small datasets, and drug design.

ABSTRACT

We introduce a modern Hopfield network with continuous states and a corresponding update rule. The new Hopfield network can store exponentially (with the dimension of the associative space) many patterns, retrieves the pattern with one update, and has exponentially small retrieval errors. It has three types of energy minima (fixed points of the update): (1) global fixed point averaging over all patterns, (2) metastable states averaging over a subset of patterns, and (3) fixed points which store a single pattern. The new update rule is equivalent to the attention mechanism used in transformers. This equivalence enables a characterization of the heads of transformer models. These heads perform in the first layers preferably global averaging and in higher layers partial averaging via metastable states. The new modern Hopfield network can be integrated into deep learning architectures as layers to allow the storage of and access to raw input data, intermediate results, or learned prototypes. These Hopfield layers enable new ways of deep learning, beyond fully-connected, convolutional, or recurrent networks, and provide pooling, memory, association, and attention mechanisms. We demonstrate the broad applicability of the Hopfield layers across various domains. Hopfield layers improved state-of-the-art on three out of four considered multiple instance learning problems as well as on immune repertoire classification with several hundreds of thousands of instances. On the UCI benchmark collections of small classification tasks, where deep learning methods typically struggle, Hopfield layers yielded a new state-of-the-art when compared to different machine learning methods. Finally, Hopfield layers achieved state-of-the-art on two drug design datasets. The implementation is available at: https://github.com/ml-jku/hopfield-layers

Motivation & Objective

  • Motivate memory-augmented architectures as alternatives to RNNs and improve storage and retrieval in deep networks.
  • Propose a differentiable, continuous-state Hopfield network with a new energy function and one-update retrieval.
  • Show that Hopfield layers can be integrated into deep architectures as pooling, memory, or attention mechanisms.
  • Demonstrate broad applicability across MIL, small classification tasks, immune repertoire classification, and drug design.

Proposed method

  • Define a new energy function E for continuous-state Hopfield networks that combines -lse with a quadratic state term to bound norms.
  • Introduce a one-update update rule xi_new = X softmax(beta X^T xi) that globally converges to stationary points of E.
  • Prove convergence properties and exponential retrieval accuracy in terms of pattern separation and network parameters.
  • Show equivalence of the update rule to the key-value attention mechanism used in transformers (self-attention).
  • Describe three Hopfield layer types (Hopfield, HopfieldPooling, HopfieldLayer) for integration into deep networks.

Experimental results

Research questions

  • RQ1Can modern Hopfield networks with continuous states store exponentially many patterns in a d-dimensional space and retrieve them with high accuracy in one update?
  • RQ2How can Hopfield networks be integrated as differentiable layers to provide memory, pooling, and attention in deep architectures?
  • RQ3Do Hopfield-based layers improve performance on MIL, immunological repertoire classification, small UCI tasks, and drug design datasets?

Key findings

  • Storage capacity is exponential in dimension, with a provable lower bound N ≥ sqrt(p) c^{(d-1)/4} under certain conditions.
  • The one-update retrieval is typically ε-close to the fixed point for well-separated patterns (exponential in separation Δi).
  • Hopfield layers achieve state-of-the-art results on several MIL benchmarks (immune repertoire and image-based MIL datasets) as reported.
  • In MIL benchmarks, HopfieldPooling yields competitive or superior AUC scores on Tiger, Fox, Elephant, UCSB Breast Cancer datasets.
  • The HopfieldLayer can emulate SVMs, k-NN, and LVQ within a single layer, enabling flexible classification.
  • The attention mechanism in transformers corresponds to the Hopfield update, linking modern memory networks with self-attention.

Better researchstarts right now

From reading papers to final review, dramatically reduce your research time.

No credit card · Free plan available

This review was created by AI and reviewed by human editors.