HackerPapers

arXiv:1911.03584cs.LG

On the Relationship between Self-Attention and Convolutional Layers

Jean-Baptiste Cordonnier, Andreas Loukas, Martin Jaggi

Abstract

Recent trends of incorporating attention mechanisms in vision have led researchers to reconsider the supremacy of convolutional layers as a primary building block. Beyond helping CNNs to handle long-range dependencies, Ramachandran et al. (2019) showed that attention can completely replace convolution and achieve state-of-the-art performance on vision tasks. This raises the question: do learned attention layers operate similarly to convolutional layers? This work provides evidence that attention layers can perform convolution and, indeed, they often learn to do so in practice. Specifically, we prove that a multi-head self-attention layer with sufficient number of heads is at least as expressive as any convolutional layer. Our numerical experiments then show that self-attention layers attend to pixel-grid patterns similarly to CNN layers, corroborating our analysis. Our code is publicly available.

arXiv comments
To appear at ICLR 2020
Journal reference
DOI
Subjects
cs.LGMachine Learning cs.CLComputation and Language cs.CVComputer Vision and Pattern Recognition stat.MLMachine Learning (Statistics)

On Hacker News

Linked by 2 identifiable commenters in 3 comments across 3 threads, from Jun 2020 to Sep 2025.

Comments linking this paper, per year.

Discussed in comments3 threads

  1. Steve Ballmer Interview 1 comment
    • It's worth noting that many of those projects were the famous versions of papers, ones that were successful through scale rather than through innovation. I'll give a good example, here's essentially the same architecture as the 16x16 words ViT paper but a year earlier[0]. It's…

      godelskiView on HNParent context

    • You could even argue that ML does classical vision in addition to other stuff. CNNs learn gabor filters. The AlexNet paper even shows this [0] Or if you look at the work ViT built itself on, they show attention heads will also learn these fillers. [1] That's actually a big part…

      godelskiView on HNParent context

  2. Image GPT 1 comment
    • > Now we can learn even the image priors (spatial locality and translation invariance) from data. Right. The attention layers even learn attention patterns which look like convolution layer kernels! But better, presumably: https://arxiv.org/abs/1911.03584

      gwernView on HNParent context

Submitted to Hacker News

Connected through shared HN threads, not inferred similarity or a recommendation.