Papers › On the Relationship between Self-Attention and Convolutional Layers

On the Relationship between Self-Attention and Convolutional Layers

8 Nov 2019ICLR 2020 1arXiv:1911.03584archive 2025-07-28

Jean-Baptiste Cordonnier, Andreas Loukas, Martin Jaggi

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.

PaperPDFConference PDFCodeCode Syntology ran

In Syntology Open this paper in Syntology's Atlas, the map of the papers in Syntology's graph and their citations.

For agents, Syntology's MCP tool lists every function and class Syntology harvested from this paper and whether it ran (how to connect): get_harvested_code_for_paper(arxiv_id="1911.03584")

Code

Syntology Ran 4 of 16 code samples harvested from 1 repository linked to this paper; 12 have no recorded run. Of those that ran: 1 ran · honoured contract; 3 ran · our draft was wrong.

By repository: official repository: 16 samples from 1 repository, 4 ran. The run record, sample by sample. “Ran” means executed on a synthesized input, not that the code is correct or reproduces the paper.

epfml/attention-cnn officialmentioned in papermentioned on GitHubpytorchApache-2.0 report

Repository list and official/mentioned flags are the archive's, frozen 2025-07-28. Reachability, where shown, is from one Syntology probe window (2026-09-16 to 2026-09-18); repositories not probed show nothing. GitHub stars are not tracked.

Code Syntology ran Syntology

16 samples harvested; 4 ran; 1 honoured the contract we drafted; 12 have no recorded run. Read from Syntology's graph 2026-09-24; that is when this build read the record, not when the samples ran.

1ran · honoured contract
3ran · our draft was wrong
12unverified

Licence: 0 of the 16 samples are pointer only, meaning Syntology does not serve that copy's text. This page shows no code text for any sample; each one links to its file in the repository.

Harvested from epfml/attention-cnn. “Ran” means the sample executed on a synthesized input. It does not mean the output is correct, and nothing here reproduces the paper's results. “Honoured” and “violated” refer to a contract Syntology drafted from the code itself; “our draft was wrong” and “fixture could not drive it” are failures of Syntology's instrument, not of the code.

Each sample ends with its code_sha256, Syntology's identity for that exact code. An agent fetches the stored sample with Syntology's MCP tool get_code(code_sha256="…") (how to connect); click an identity to copy that call.

Repository labels, per sample. official repository: The archive marks this repository official for the paper. named in the paper: The archive records that the paper mentions this repository; it is not marked official. community (archive-listed): In the archive's code links for this paper, not marked official and not recorded as mentioned in the paper. found in paper text by Syntology: Syntology found this repository in the paper's own text; whether it is the authors' implementation is not asserted. community: Not in the archive's code links for this paper; a community repository Syntology harvested. Samples from a repository marked official are listed first. Licence labels name the repository's licence as recorded at harvest. “Pointer only” means Syntology does not serve that copy's text, for one of four reasons: no licence file was found; the licence was not identified; the licence is recorded as permissive but that copy's record is not marked cleared; or the licence is outside the permissive list Syntology serves text under (MIT, Apache-2.0, BSD and similar). Some licences outside that list permit redistribution, such as WTFPL, and GPL-3.0 under its conditions; they are simply not on the list. Hover a licence label for the reason. File links open the file on GitHub at the default branch, which may have changed since the harvest.

gelu epfml/attention-cnn/models/bert.py official repository ran · honoured contract fingerprinted Apache-2.0 (permissive) · fdc64f4c72036ae4 · report
human_format epfml/attention-cnn/utils/logging.py official repository ran · our draft was wrong fingerprinted Apache-2.0 (permissive) · 2844a6a8960060bc · report
sizeof_fmt epfml/attention-cnn/utils/logging.py official repository ran · our draft was wrong fingerprinted Apache-2.0 (permissive) · b6bef72aa7ff57a5 · report
url_to_filename epfml/attention-cnn/models/bert_utils.py official repository ran · our draft was wrong fingerprinted Apache-2.0 (permissive) · 5eff22fa0a651276 · report
ResNet10 epfml/attention-cnn/models/resnet.py official repository unverified Apache-2.0 (permissive) · 1119795bf433256e · report
ResNet18 epfml/attention-cnn/models/resnet.py official repository unverified Apache-2.0 (permissive) · a4eff019b95fd2ce · report
ResNet34 epfml/attention-cnn/models/resnet.py official repository unverified Apache-2.0 (permissive) · af3a6e8a2702592f · report
cached_path epfml/attention-cnn/models/bert_utils.py official repository unverified Apache-2.0 (permissive) · cf9c448c96f48428 · report
filename_to_url epfml/attention-cnn/models/bert_utils.py official repository unverified Apache-2.0 (permissive) · a6aab787fcf8b10d · report
gaussian_kernel_2d epfml/attention-cnn/models/gaussian.py official repository unverified Apache-2.0 (permissive) · 796bf85d9c48fcf1 · report
get_num_parameter epfml/attention-cnn/utils/logging.py official repository unverified Apache-2.0 (permissive) · d5d2fd533e9dac1d · report
linear_warmup_cosine_lr_scheduler epfml/attention-cnn/utils/learning_rate.py official repository unverified Apache-2.0 (permissive) · 14f069410e56d3ba · report
load_tf_weights_in_bert epfml/attention-cnn/models/bert.py official repository unverified Apache-2.0 (permissive) · b1a7180868dd8d6a · report
parse_cli_overides epfml/attention-cnn/utils/config.py official repository unverified Apache-2.0 (permissive) · c3de407b29c79036 · report
plot_attention_layer epfml/attention-cnn/utils/plotting.py official repository unverified Apache-2.0 (permissive) · de4b895397bf1813 · report
prune_linear_layer epfml/attention-cnn/models/bert.py official repository unverified Apache-2.0 (permissive) · 2f516ae7fc833c82 · report

Tasks

Image Classification

Results from the paper archive 2025-07-28

TaskDatasetModelMetricValueRank at snapshotLeaderboardReport
Image Classification CIFAR-10 SA quadratic embedding Percentage correct 93.8 #168 of 265 Archive leaderboard report

Ranks are positions in the archive's leaderboards as they stood at the 2025-07-28 snapshot. Results published since then are not among these rows, so a rank here is not a current standing.

Methods

Convolution

Report a problem or propose a change · a person checks every report against the paper or source before anything changes; decisions are listed on /corrections