SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 2210.05958 · 2022

Bridging the Gap Between Vision Transformers and Convolutional Neural Networks on Small Datasets

arXiv · PDF · Open in the Atlas

Code that ran

8 of 10 samples (functions and classes) lifted from this paper's linked repositories executed on a synthesized input in Syntology's jail (0 of them constructed an object rather than computing a result; 1 honoured the contract we drafted, 0 violated it and 1 has no contract verdict; 6 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/2210.05958.json · badge: /api/ran/2210.05958.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
arieseirack/dhvt canonical (classifier label)
classifier basis not recorded on the link
8 ran · 2 no recorded run
FunctionStatusWhere it lives
DiversityLoss Ran
ran on a synthesized input
arieseirack/dhvt/losses.py
code served (permissive licence) · get_code("7085cfd021be27e3")
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 Tensor, ndim 0, dtype family float, shape () as a later run recorded it. The image it ran in was not recorded. The code mentions cuda, and the harness aliases cuda to the CPU for every sample; whether this run needed that is not recorded. If your copy returns the same type, ndim and shape 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
from torch.nn import functional as F

torch.manual_seed(0)

# The function expects inputs with shape (B, depth, head, C)
# B = batch size
# depth = depth dimension
# head = number of heads
# C = channel/embedding dimension

B = 2
depth = 3
head = 4
C = 5

# Create a random tensor with the expected shape
inputs = torch.randn(B, depth, head, C)

ARGS = {
    "inputs": inputs
}
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 Tensor, ndim 0, dtype family float, shape () — shape () as a later run recorded it
dtype family
int means an integer dtype; float means any other dtype the instrument saw, bool and complex included (fixture_check.py records only these two families)
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
adjust_keep_rate Ran
ran, honoured the contract we drafted
arieseirack/dhvt/helpers.py
pointer only (licence: Apache-2.0); the stored copy get_code serves, from liuting20/sparse-tuning, is pointer only (licence: NONE) · get_code("66733f50aff69220")
How it ran

The body of this sample is withheld: this paper's link allows the body inline (Apache-2.0), but get_code serves the stored copy, first harvested from liuting20/sparse-tuning, and GitHub detected no licence in that repository when it was checked. The setup block that called it is withheld with it, because it is written against that body. source_path and origin say where the code lives, to read under the repository's own terms. A run is recorded.

build_transform Ran
ran; our contract draft was wrong, not the code
arieseirack/dhvt/datasets.py
code served (permissive licence) · get_code("3bc74137ab36aa79")
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 Compose. 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 numpy as np
from torchvision import transforms

torch.manual_seed(0)

class ArgsConfig:
    def __init__(self):
        self.input_size = 224
        self.color_jitter = 0.4
        self.aa = "rand-m9-mstd0.5"
        self.train_interpolation = "bicubic"
        self.reprob = 0.25
        self.remode = "pixel"
        self.recount = 2

ARGS = {
    "is_train": True,
    "args": ArgsConfig()
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
numpy, timm, torch, torchvision — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type Compose — a Compose output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a Compose 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
conv3x3 Ran
ran; our contract draft was wrong, not the code
arieseirack/dhvt/vision_transformer.py
pointer only (licence: Apache-2.0); the stored copy get_code serves, from facebookresearch/xcit, is pointer only (licence: Apache-2.0) · get_code("429abe9dc8793925")
How it ran

The body of this sample is withheld: this paper's link allows the body inline (Apache-2.0), but get_code serves the stored copy, first harvested from facebookresearch/xcit, and Apache-2.0, as GitHub detects it on that repository, is in the permissive set, but a licence decision keeps the body a pointer: its licence file names an outside party, so it may cover vendored code rather than the repository owner's files (recorded as pointer:licence_names_third_party_corporation). The setup block that called it is withheld with it, because it is written against that body. source_path and origin say where the code lives, to read under the repository's own terms. A run is recorded.

drop_path Ran
ran; the contract check could not run (RAISES, DEP_MISSING or TIMEOUT)
arieseirack/dhvt/vision_transformer.py
pointer only (licence: Apache-2.0); the stored copy get_code serves, from fudan-zvg/SeaFormer, is pointer only (licence: NONE) · get_code("3ac6b7d76e8e3584")
How it ran

The body of this sample is withheld: this paper's link allows the body inline (Apache-2.0), but get_code serves the stored copy, first harvested from fudan-zvg/SeaFormer, and GitHub detected no licence in that repository when it was checked. The setup block that called it is withheld with it, because it is written against that body. source_path and origin say where the code lives, to read under the repository's own terms. A run is recorded.

raw_reader Ran
ran; our contract draft was wrong, not the code
arieseirack/dhvt/folder2lmdb.py
code served (permissive licence) · get_code("51738010a21f76a1")
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 bytes. 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 tempfile
import os

# Create a temporary binary file with some test data
temp_dir = tempfile.mkdtemp()
test_file = os.path.join(temp_dir, "test_data.bin")

# Write some binary data to the file
with open(test_file, 'wb') as f:
    f.write(b'\x00\x01\x02\x03\x04\x05')

ARGS = {
    'path': test_file
}
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 bytes — a bytes output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a bytes 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
resize_pos_embed Ran
ran; the contract check could not run (RAISES, DEP_MISSING or TIMEOUT)
arieseirack/dhvt/vision_transformer.py
code served (permissive licence) · get_code("191b2735955d18f4")
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 Tensor, ndim 3, dtype family float, shape (1, 17, 4) as a later run recorded it. The image it ran in was not recorded. If your copy returns the same type, ndim and shape 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 math

torch.manual_seed(0)

# The function resizes positional embeddings from one shape to another
# posemb: original position embeddings tensor (batch_size, num_tokens, embedding_dim)
# posemb_new: target position embeddings tensor with desired shape
# num_tokens: number of special tokens (like cls token) to preserve
# gs_new: target grid size (height, width) for the spatial part

# Create small test tensors
embedding_dim = 4
num_special_tokens = 1
old_grid_size = 3  # 3x3 = 9 spatial tokens
old_total_tokens = num_special_tokens + (old_grid_size * old_grid_size)  # 1 + 9 = 10

# Original position embedding: (batch=1, num_tokens=10, embedding_dim=4)
posemb = torch.randn(1, old_total_tokens, embedding_dim)

# New position embedding target shape
new_grid_size = 4  # 4x4 = 16 spatial tokens
new_total_tokens = num_special_tokens + (new_grid_size * new_grid_size)  # 1 + 16 = 17
posemb_new = torch.randn(1, new_total_tokens, embedding_dim)

# Grid size for new embedding (4x4 spatial grid)
gs_new = [4, 4]

ARGS = {
    'posemb': posemb,
    'posemb_new': posemb_new,
    'num_tokens': num_special_tokens,
    'gs_new': gs_new,
}
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 Tensor, ndim 3, dtype family float, shape (1, 17, 4) — shape (1, 17, 4) as a later run recorded it
dtype family
int means an integer dtype; float means any other dtype the instrument saw, bool and complex included (fixture_check.py records only these two families)
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
speed_test Ran
ran; our contract draft was wrong, not the code
arieseirack/dhvt/helpers.py
pointer only (licence: Apache-2.0); the stored copy get_code serves, from liuting20/sparse-tuning, is pointer only (licence: NONE) · get_code("e294b62d47bcc26f")
How it ran

The body of this sample is withheld: this paper's link allows the body inline (Apache-2.0), but get_code serves the stored copy, first harvested from liuting20/sparse-tuning, and GitHub detected no licence in that repository when it was checked. The setup block that called it is withheld with it, because it is written against that body. source_path and origin say where the code lives, to read under the repository's own terms. A run is recorded.

dumps_pyarrow Not yet run
unverified (harvested, no recorded run)
arieseirack/dhvt/folder2lmdb.py
pointer only (licence: Apache-2.0); the stored copy get_code serves, from wangya22/I3SB, is pointer only (licence: NONE) · get_code("9e7bf674714e06d5")
How it ran

The body of this sample is withheld: this paper's link allows the body inline (Apache-2.0), but get_code serves the stored copy, first harvested from wangya22/I3SB, and GitHub detected no licence in that repository when it was checked. The setup block that called it is withheld with it, because it is written against that body. source_path and origin say where the code lives, to read under the repository's own terms. No invocation recorded.

loads_pyarrow Not yet run
unverified (harvested, no recorded run)
arieseirack/dhvt/folder2lmdb.py
code served (permissive licence) · get_code("b4c154b6f0568b6b")
How it ran

no invocation recorded.

Also present in other papers' code

Of 10 samples lifted from this paper's linked repositories, 10 carry a function identity and 0 do not. Of the 10 distinct functions with an identity, 9 are also present in other papers whose code we hold (9 with at least one paper dated earlier, 1 the same month, 9 later) and 1 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.

FunctionAlso present inEarliest-datedOthers named
drop_path 224 other papers
56 dated earlier, 3 the same month, 162 later, 2 same year, order not determinable, 1 undated · 38 only as an assembly brick
2003.12039 (2020-03)
RAFT: Recurrent All-Pairs Field Transforms for Optical Flow
2007.09384 (2020-07)
Multi-Scale Positive Sample Refinement for Few-Shot Object Detection
2010.11929 (2020-10)
An Image is Worth 16x16 Words: Transformers for Image Recognition at Scale
and 221 more not named here
build_transform 37 other papers
16 dated earlier, 19 later, 2 same year, order not determinable
2104.05707 (2021-04)
LocalViT: Analyzing Locality in Vision Transformers
2104.13840 (2021-04)
Twins: Revisiting the Design of Spatial Attention in Vision Transformers
2106.00515 (2021-06)
KVT: k-NN Attention for Boosting Vision Transformers
and 34 more not named here
resize_pos_embed 20 other papers
5 dated earlier, 14 later, 1 same year, order not determinable · 1 only as an assembly brick
2105.12723 (2021-05)
Nested Hierarchical Transformer: Towards Accurate, Data-Efficient and Interpretable Visual Understanding
2202.07800 (2022-02)
Not All Patches are What You Need: Expediting Vision Transformers via Token Reorganizations
and 17 more not named here
raw_reader 8 other papers
2 dated earlier, 6 later
2202.07800 (2022-02)
Not All Patches are What You Need: Expediting Vision Transformers via Token Reorganizations
2209.04996 (2022-09)
Switchable Online Knowledge Distillation
2311.14097 (2023-11)
ACT-Diffusion: Efficient Adversarial Consistency Training for One-step Diffusion Models
and 5 more not named here
loads_pyarrow 6 other papers
4 dated earlier, 2 later
2110.07402 (2021-10)
Self-Supervised Learning by Estimating Twin Class Distributions
2111.15174 (2021-11)
CRIS: CLIP-Driven Referring Image Segmentation
2202.07800 (2022-02)
Not All Patches are What You Need: Expediting Vision Transformers via Token Reorganizations
and 3 more not named here
dumps_pyarrow 4 other papers
2 dated earlier, 2 later
2202.07800 (2022-02)
Not All Patches are What You Need: Expediting Vision Transformers via Token Reorganizations
2209.04996 (2022-09)
Switchable Online Knowledge Distillation
2403.06069 (2024-03)
Implicit Image-to-Image Schrodinger Bridge for Image Restoration
and 1 more not named here
adjust_keep_rate 3 other papers
1 dated earlier, 2 later
2202.07800 (2022-02)
Not All Patches are What You Need: Expediting Vision Transformers via Token Reorganizations
2404.07713 (2024-04)
Progressive Semantic-Guided Vision Transformer for Zero-Shot Learning
2405.14700 (2024-05)
Sparse-Tuning: Adapting Vision Transformers with Efficient Fine-tuning and Inference
conv3x3 3 other papers
2 dated earlier, 1 later
2106.09681 (2021-06)
XCiT: Cross-Covariance Image Transformers
2206.08898 (2022-06)
SimA: Simple Softmax-free Attention for Vision Transformers
2410.02675 (2024-10)
FAN: Fourier Analysis Networks
speed_test 3 other papers
1 dated earlier, 2 later
2202.07800 (2022-02)
Not All Patches are What You Need: Expediting Vision Transformers via Token Reorganizations
2404.07713 (2024-04)
Progressive Semantic-Guided Vision Transformer for Zero-Shot Learning
2405.14700 (2024-05)
Sparse-Tuning: Adapting Vision Transformers with Efficient Fine-tuning and Inference

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

There still remains an extreme performance gap between Vision Transformers (ViTs) and Convolutional Neural Networks (CNNs) when training from scratch on small datasets, which is concluded to the lack of inductive bias. In this paper, we further consider this problem and point out two weaknesses of ViTs in inductive biases, that is, the spatial relevance and diverse channel representation. First, on spatial aspect, objects are locally compact and relevant, thus fine-grained feature needs to be extracted from a token and its neighbors. While the lack of data hinders ViTs to attend the spatial relevance. Second, on channel aspect, representation exhibits diversity on different channels. But the scarce data can not enable ViTs to learn strong enough representation for accurate recognition. To this end, we propose Dynamic Hybrid Vision Transformer (DHVT) as the solution to enhance the two inductive biases. On spatial aspect, we adopt a hybrid structure, in which convolution is integrated into patch embedding and multi-layer perceptron module, forcing the model to capture the token features as well as their neighboring features. On channel aspect, we introduce a dynamic feature aggregation module in MLP and a brand new "head token" design in multi-head self-attention module to help re-calibrate channel representation and make different channel group representation interacts with each other. The fusion of weak channel representation forms a strong enough representation for classification. With this design, we successfully eliminate the performance gap between CNNs and ViTs, and our DHVT achieves a series of state-of-the-art performance with a lightweight model, 85.68% on CIFAR-100 with 22.8M parameters, 82.3% on ImageNet-1K with 24.0M parameters. Code is available at https://github.com/ArieSeirack/DHVT.

For agents

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

get_harvested_code_for_paper("2210.05958")
get_code_for_paper("2210.05958")
have("2210.05958")

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

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

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

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

Connect an agent — have() is free.