The Dual Form of Neural Networks Revisited: Connecting Test Time Predictions to Training Patterns via Spotlights of Attention

Kazuki Irie, Róbert Csordás, Jürgen Schmidhuber
2/11/2022
cs.LG

Official code: RobertCsordas/linear_layer_as_attention (17 stars, Python, last commit 2025-06-11).

Abstract

Linear layers in neural networks (NNs) trained by gradient descent can be expressed as a key-value memory system which stores all training datapoints and the initial weights, and produces outputs using unnormalised dot attention over the entire training experience. While this has been technically known since the 1960s, no prior work has effectively studied the operations of NNs in such a form, presumably due to prohibitive time and space complexities and impractical model sizes, all of them growing linearly with the number of training patterns which may get very large.

Show full abstract

However, this dual formulation offers a possibility of directly visualising how an NN makes use of training patterns at test time, by examining the corresponding attention weights. We conduct experiments on small scale supervised image classification tasks in single-task, multi-task, and continual learning settings, as well as language modelling, and discuss potentials and limits of this view for better understanding and interpreting how NNs exploit training patterns. Our code is public.

View on arXivView PDF

Code Implementations(1)

The official repository for our paper "The Dual Form of Neural Networks Revisited: Connecting Test Time Predictions to Training Patterns via Spotlights of Attention".

171PythonFeb 10, 20221 years ago

Similar Papers

Cite this paper

@article{irie2022dual,
  title  = {The Dual Form of Neural Networks Revisited: Connecting Test Time Predictions to Training Patterns via Spotlights of Attention},
  author = {Kazuki Irie and Róbert Csordás and Jürgen Schmidhuber},
  year   = {2022},
  eprint = {2202.05798},
  archivePrefix = {arXiv},
  url    = {https://arxiv.org/abs/2202.05798}
}

Add a badge to your README

Shows whether official code is linked for this paper.

Code of Paper badge
[![Code of Paper](https://codeofpaper.com/badge/2202.05798.svg)](https://codeofpaper.com/paper/2202.05798)

Discussion