SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 2103.11816 · ICCV · 2021

Incorporating Convolution Designs into Visual Transformers

Wei Wu, Ziwei Liu, Kun Yuan, Fengwei Yu, Aojun Zhou, Shaopeng Guo

arXiv · PDF · Open in the Atlas

Code that ran

9 of 11 samples (functions and classes) lifted from this paper's linked repositories executed on a synthesized input in Syntology's jail (9 of them constructed an object rather than computing a result; 0 honoured the contract we drafted, 0 violated it and 9 have no contract verdict; 0 failures of our instrument; 2 no recorded run), measured 2026-11-22; repository links from the Papers with Code archive attributed under CC BY-SA, no affiliation; bodies inline only under a permissive licence as GitHub detects it. Not a reproduction of the paper's results.

"Ran" means the function executed on a synthesized input and returned a value. It is not a reproduction of the paper's results. This record, dated, as JSON: /api/ran/2103.11816.json · badge: /api/ran/2103.11816.svg

Each repository's role is a label: a classifier's output recorded on the link, or, where no role is recorded, what the Papers with Code archive marked. The line under it names its basis. Neither says who wrote the code.

RepositoryRoleRan
coeusguo/ceit marked official in Papers with Code
Papers with Code archive
5 ran · 1 no recorded run
rishikksh20/CeiT-pytorch community
Papers with Code archive
4 ran · 1 no recorded run
FunctionStatusWhere it lives
Attention Ran
ran on a synthesized input · constructed an object; no result was computed
coeusguo/ceit/ceit_model.py
code served (permissive licence) · get_code("88ac331124a64a60")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned an instance of its own class, Attention: the run constructed the object and did not call it, so no result was computed. The image it ran in was not recorded. If your copy returns the same type on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import torch
import torch.nn as nn

torch.manual_seed(0)

# Create a small input tensor
# Shape: (batch=2, sequence_length=3, embedding_dim=8)
x = torch.randn(2, 3, 8)

# Define ARGS dict with all parameters for Attention.__init__
ARGS = {
    "dim": 8,
    "num_heads": 2,
    "qkv_bias": False,
    "qk_scale": None,
    "attn_drop": 0.1,
    "proj_drop": 0.1,
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type Attention — the run constructed an instance of its own class and did not call it; no shape is stated — the instrument coerces any output to an array; for a Attention output the recorded ndim 0 and dtype family float describe that coercion, not the output, and are not stated
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
AttentionLCA Ran
ran on a synthesized input · constructed an object; no result was computed
coeusguo/ceit/ceit_model.py
code served (permissive licence) · get_code("ef3f1eb732093bcb")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned an instance of its own class, AttentionLCA: the run constructed the object and did not call it, so no result was computed. The image it ran in was not recorded. If your copy returns the same type on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import torch
import torch.nn as nn

torch.manual_seed(0)

# Create a minimal AttentionLCA instance to understand its constructor
# AttentionLCA.__init__ takes: dim, num_heads, qkv_bias, qk_scale, attn_drop, proj_drop

# Define the attention module
attention_lca = nn.Module()  # placeholder to build actual instance below

# Set up parameters for AttentionLCA
dim = 8
num_heads = 2
qkv_bias = True
qk_scale = None
attn_drop = 0.1
proj_drop = 0.1

# Create the actual AttentionLCA instance
from torch.nn import Module, Linear, Dropout
import torch.nn.functional as F

class AttentionLCA(nn.Module):
    def __init__(self, dim, num_heads=8, qkv_bias=False, qk_scale=None, attn_drop=0.0, proj_drop=0.0):
        super(AttentionLCA, self).__init__()
        self.num_heads = num_heads
        head_dim = dim // num_heads
        self.scale = qk_scale or head_dim ** (-0.5)
        self.qkv = nn.Linear(dim, dim * 3, bias=qkv_bias)
        self.attn_drop = nn.Dropout(attn_drop)
        self.proj = nn.Linear(dim, dim)
        self.proj_drop = nn.Dropout(proj_drop)
        self.dim = dim
        self.qkv_bias = qkv_bias

    def forward(self, x):
        q_weight = self.qkv.weight[:self.dim, :]
        q_bias = None if not self.qkv_bias else self.qkv.bias[:self.dim]
        kv_weight = self.qkv.weight[self.dim:, :]
        kv_bias = None if not self.qkv_bias else self.qkv.bias[self.dim:]
        B, N, C = x.shape
        _, last_token = torch.split(x, [N - 1, 1], dim=1)
        q = F.linear(last_token, q_weight, q_bias).reshape(B, 1, self.num_heads, C // self.num_heads).permute(0, 2, 1, 3)
        kv = F.linear(x, kv_weight, kv_bias).reshape(B, N, 2, self.num_heads, C // self.num_heads).permute(2, 0, 3, 1, 4)
        k, v = (kv[0], kv[1])
        attn = q @ k.transpose(-2, -1) * self.scale
        attn = attn.softmax(dim=-1)
        attn = self.attn_drop(attn)
        x = (attn @ v).transpose(1, 2).reshape(B, 1, C)
        x = self.proj(x)
        x = self.proj_drop(x)
        return x

# Create sample input tensor
# Shape: (batch_size=2, num_tokens=3, embedding_dim=8)
x = torch.randn(2, 3, 8)

# Instantiate the module
attention_lca_module = AttentionLCA(
    dim=8,
    num_heads=2,
    qkv_bias=True,
    qk_scale=None,
    attn_drop=0.1,
    proj_drop=0.1
)

ARGS = {
    "dim": 8,
    "num_heads": 2,
    "qkv_bias": True,
    "qk_scale": None,
    "attn_drop": 0.1,
    "proj_drop": 0.1
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type AttentionLCA — the run constructed an instance of its own class and did not call it; no shape is stated — the instrument coerces any output to an array; for a AttentionLCA output the recorded ndim 0 and dtype family float describe that coercion, not the output, and are not stated
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
Block Ran
ran on a synthesized input · constructed an object; no result was computed
coeusguo/ceit/ceit_model.py
code served (permissive licence) · get_code("e5a66231dac09f8c")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned an instance of its own class, Block: the run constructed the object and did not call it, so no result was computed. The image it ran in was not recorded. If your copy returns the same type on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import torch
import torch.nn as nn
import math
from timm.models.layers import DropPath

torch.manual_seed(0)

ARGS = {
    'dim': 64,
    'num_heads': 8,
    'mlp_ratio': 4.0,
    'qkv_bias': False,
    'qk_scale': None,
    'drop': 0.0,
    'attn_drop': 0.0,
    'drop_path': 0.0,
    'act_layer': nn.GELU,
    'norm_layer': nn.LayerNorm,
    'kernel_size': 3,
    'with_bn': True,
    'feedforward_type': 'leff'
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
timm, torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type Block — the run constructed an instance of its own class and did not call it; no shape is stated — the instrument coerces any output to an array; for a Block output the recorded ndim 0 and dtype family float describe that coercion, not the output, and are not stated
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
HybridEmbed Ran
ran on a synthesized input · constructed an object; no result was computed
coeusguo/ceit/ceit_model.py
code served (permissive licence) · get_code("531854dd3e8dc7b0")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned an instance of its own class, HybridEmbed: the run constructed the object and did not call it, so no result was computed. The image it ran in was not recorded. If your copy returns the same type on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import torch
import torch.nn as nn
from timm.models.layers import to_2tuple

torch.manual_seed(0)

# Create a minimal backbone CNN that outputs a feature map
class MinimalBackbone(nn.Module):
    def __init__(self):
        super().__init__()
        self.conv1 = nn.Conv2d(3, 64, kernel_size=3, stride=2, padding=1)
        self.conv2 = nn.Conv2d(64, 128, kernel_size=3, stride=2, padding=1)
        # After two stride-2 convs: 224 -> 112 -> 56
        self.feature_info = self.FeatureInfo()
    
    class FeatureInfo:
        def channels(self):
            return [128]
    
    def forward(self, x):
        x = self.conv1(x)
        x = self.conv2(x)
        return x

backbone = MinimalBackbone()

ARGS = {
    'backbone': backbone,
    'img_size': 224,
    'patch_size': 16,
    'feature_size': None,
    'in_chans': 3,
    'embed_dim': 768,
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
timm, torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type HybridEmbed — the run constructed an instance of its own class and did not call it; no shape is stated — the instrument coerces any output to an array; for a HybridEmbed output the recorded ndim 0 and dtype family float describe that coercion, not the output, and are not stated
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
LCA Ran
ran on a synthesized input · constructed an object; no result was computed
rishikksh20/CeiT-pytorch/ceit.py
code served (permissive licence) · get_code("f7134b0e48a1485d")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned an instance of its own class, LCA: the run constructed the object and did not call it, so no result was computed. The image it ran in was not recorded. If your copy returns the same type on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import torch
import torch.nn as nn

torch.manual_seed(0)

# Define ARGS with all required parameters for LCA.__init__
ARGS = {
    'dim': 4,
    'heads': 2,
    'dim_head': 2,
    'mlp_dim': 8,
    'dropout': 0.1
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
einops, torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type LCA — the run constructed an instance of its own class and did not call it; no shape is stated — the instrument coerces any output to an array; for a LCA output the recorded ndim 0 and dtype family float describe that coercion, not the output, and are not stated
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
LCAttention Ran
ran on a synthesized input · constructed an object; no result was computed
rishikksh20/CeiT-pytorch/ceit.py
code served (permissive licence) · get_code("218a36c2869e1755")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned an instance of its own class, LCAttention: the run constructed the object and did not call it, so no result was computed. The image it ran in was not recorded. If your copy returns the same type on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import torch
import torch.nn as nn
from einops import rearrange, repeat

torch.manual_seed(0)

# Construct a minimal input tensor
# Shape: (batch, sequence_length, embedding_dim)
x = torch.randn(2, 5, 64)

# Define ARGS dict with all parameters for LCAttention.__init__
ARGS = {
    'dim': 64,
    'heads': 8,
    'dim_head': 8,
    'dropout': 0.1
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
einops, torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type LCAttention — the run constructed an instance of its own class and did not call it; no shape is stated — the instrument coerces any output to an array; for a LCAttention output the recorded ndim 0 and dtype family float describe that coercion, not the output, and are not stated
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
LeFF Ran
ran on a synthesized input · constructed an object; no result was computed
rishikksh20/CeiT-pytorch/ceit.py
code served (permissive licence) · get_code("35eefd450a0413e9")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned an instance of its own class, LeFF: the run constructed the object and did not call it, so no result was computed. The image it ran in was not recorded. If your copy returns the same type on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import torch
import torch.nn as nn
from einops.layers.torch import Rearrange

torch.manual_seed(0)

# Create a minimal input tensor
# The module expects input of shape (batch, n, dim) where n*dim = 196 (14*14)
# So for batch=2, dim=192, we need n=196/192 which doesn't work cleanly
# Looking at the forward pass:
# - up_proj takes (b, n, c) -> (b, c, n) -> (b, c, h, w) where h=14, w=14
# - This means n must equal h*w = 196
# - So input is (batch, 196, dim)

batch_size = 2
dim = 192
n_tokens = 196  # 14 * 14

# Create input tensor: (batch, n_tokens, dim)
x = torch.randn(batch_size, n_tokens, dim)

# Define arguments for LeFF
ARGS = {
    'dim': dim,
    'scale': 4,
    'depth_kernel': 3
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
einops, torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type LeFF — the run constructed an instance of its own class and did not call it; no shape is stated — the instrument coerces any output to an array; for a LeFF output the recorded ndim 0 and dtype family float describe that coercion, not the output, and are not stated
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
LocallyEnhancedFeedForward Ran
ran on a synthesized input · constructed an object; no result was computed
coeusguo/ceit/ceit_model.py
code served (permissive licence) · get_code("ceb88739eac75055")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned an instance of its own class, LocallyEnhancedFeedForward: the run constructed the object and did not call it, so no result was computed. The image it ran in was not recorded. If your copy returns the same type on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import torch
import torch.nn as nn
import math

torch.manual_seed(0)

# The function expects:
# - in_features: int (number of input channels)
# - hidden_features: int or None (number of hidden channels)
# - out_features: int or None (number of output channels)
# - act_layer: activation layer class (defaults to nn.GELU)
# - drop: float (dropout rate, not used in forward but in __init__)
# - kernel_size: int (for depthwise convolution)
# - with_bn: bool (whether to use batch norm)

# The forward method expects input of shape (batch, n, k)
# where n must be a perfect square + 1 (for class token)
# and k is the feature dimension

# For a 4x4 spatial patch plus 1 class token: n = 17, k = 8
in_features = 8
hidden_features = 16
out_features = 8
act_layer = nn.GELU
drop = 0.1
kernel_size = 3
with_bn = True

ARGS = {
    'in_features': in_features,
    'hidden_features': hidden_features,
    'out_features': out_features,
    'act_layer': act_layer,
    'drop': drop,
    'kernel_size': kernel_size,
    'with_bn': with_bn,
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type LocallyEnhancedFeedForward — the run constructed an instance of its own class and did not call it; no shape is stated — the instrument coerces any output to an array; for a LocallyEnhancedFeedForward output the recorded ndim 0 and dtype family float describe that coercion, not the output, and are not stated
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
TransformerLeFF Ran
ran on a synthesized input · constructed an object; no result was computed
rishikksh20/CeiT-pytorch/ceit.py
code served (permissive licence) · get_code("bbca7f007eecf184")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned an instance of its own class, TransformerLeFF: the run constructed the object and did not call it, so no result was computed. The image it ran in was not recorded. If your copy returns the same type on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import torch
import torch.nn as nn

torch.manual_seed(0)

ARGS = {
    "dim": 192,
    "depth": 2,
    "heads": 8,
    "dim_head": 64,
    "scale": 4,
    "depth_kernel": 3,
    "dropout": 0.0,
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
einops, torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type TransformerLeFF — the run constructed an instance of its own class and did not call it; no shape is stated — the instrument coerces any output to an array; for a TransformerLeFF output the recorded ndim 0 and dtype family float describe that coercion, not the output, and are not stated
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
CeIT Not yet run
unverified (harvested, no recorded run)
coeusguo/ceit/ceit_model.py
code served (permissive licence) · get_code("f706125b2848bd36")
How it ran

no invocation recorded.

CeiT Not yet run
unverified (harvested, no recorded run)
rishikksh20/CeiT-pytorch/ceit.py
code served (permissive licence) · get_code("779c5d5035c71712")
How it ran

no invocation recorded.

Also present in other papers' code

Of 11 samples lifted from this paper's linked repositories, 11 carry a function identity and 0 do not. Of the 11 distinct functions with an identity, 0 are also present in other papers whose code we hold (0 with at least one paper dated earlier, 0 the same month, 0 later) and 11 are only here among the 52,977 papers whose code Syntology holds (as of 2026-09-26).

Only here means: among the 52,977 papers whose code Syntology holds (51,887 with lifted samples, 1,090 through their assemblies only), as of 2026-09-26, no other paper's lifted samples or current assembly bricks contain an identical function body after normalisation.

Presence, not direction: an identical function body in two papers' repositories does not say who wrote it, which came from which, or that either paper's method rests on it. Matching is exact after normalisation, so a renamed or edited function is not matched. Dates are when papers appeared, not when code was written. Only .py files the harvester lifted are covered; notebooks are not read. A new-style arXiv id YYMM.NNNN dates a paper to the month 20YY-MM; otherwise Paper.year dates it to the year; otherwise it is undated. Dates are when the paper appeared, not when the code was written. Read 2026-11-22.

Repositories linked to this paper

Some links come from the archived Papers with Code dataset (CC BY-SA 4.0): attribution and licence.

Abstract

Motivated by the success of Transformers in natural language processing (NLP) tasks, there emerge some attempts (e.g., ViT and DeiT) to apply Transformers to the vision domain. However, pure Transformer architectures often require a large amount of training data or extra supervision to obtain comparable performance with convolutional neural networks (CNNs). To overcome these limitations, we analyze the potential drawbacks when directly borrowing Transformer architectures from NLP. Then we propose a new Convolution-enhanced image Transformer (CeiT) which combines the advantages of CNNs in extracting lowlevel features, strengthening locality, and the advantages of Transformers in establishing long-range dependencies. Three modifications are made to the original Transformer: 1) instead of the straightforward tokenization from raw input images, we design an Image-to-Tokens (I2T) module that extracts patches from generated low-level features; 2) the feed-froward network in each encoder block is replaced with a Locally-enhanced Feed-Forward (LeFF) layer that promotes the correlation among neighboring tokens in the spatial dimension; 3) a Layer-wise Class token Attention (LCA) is attached at the top of the Transformer that utilizes the multi-level representations. Experimental results on ImageNet and seven downstream tasks show the effectiveness and generalization ability of CeiT compared with previous Transformers and stateof-the-art CNNs, without requiring a large amount of training data and extra CNN teachers. Besides, CeiT models demonstrate better convergence with 3× fewer training iterations, which can reduce the training cost significantly 1 .

For agents

The same record, over MCP at https://syntology.ai/mcp:

get_harvested_code_for_paper("2103.11816")
get_code_for_paper("2103.11816")
have("2103.11816")

The run record, dated, one paper per request, free:

curl https://syntology.ai/api/ran/2103.11816.json

A badge for a README (the split and the date, never a ratio):

[![Syntology run record](https://syntology.ai/api/ran/2103.11816.svg)](https://syntology.ai/paper/2103.11816)

Connect an agent — have() is free.