SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 2010.11929 · ICLR · 2021

An Image is Worth 16x16 Words: Transformers for Image Recognition at Scale

Mostafa Dehghani, Dirk Weissenborn, Thomas Unterthiner, Georg Heigold, Jakob Uszkoreit, Alexey Dosovitskiy, Lucas Beyer, Alexander Kolesnikov, Xiaohua Zhai, Matthias Minderer, Sylvain Gelly, Neil Houlsby

arXiv · PDF · Open in the Atlas

Code that ran

307 of 419 samples (functions and classes) lifted from this paper's linked repositories executed on a synthesized input in Syntology's jail (165 of them constructed an object rather than computing a result; 8 honoured the contract we drafted, 2 violated it and 275 have no contract verdict; 22 failures of our instrument; 112 no recorded run); 2 of them were also run on the host, not in the jail, by the peer-agreement lane that set their level, measured 2026-11-23; 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/2010.11929.json · badge: /api/ran/2010.11929.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
google-research/vision_transformer canonical (classifier label)
classifier basis: classifier_2025
0 ran · 6 no recorded run
arkel23/PyTorch-Pretrained-ViT community
not in the paper's declared repositories
31 ran · 6 no recorded run
lukemelas/PyTorch-Pretrained-ViT reimplementation (classifier label)
classifier basis: classifier_2025
10 ran · 1 no recorded run
OML-Team/open-metric-learning community
not in the paper's declared repositories
9 ran · 3 no recorded run
Thanusan19/Vision_Transformer community (classifier label)
classifier basis not recorded on the link
8 ran · 3 no recorded run
tintn/vision-transformer-from-scratch community
not in the paper's declared repositories
7 ran · 3 no recorded run
SHI-Labs/Compact-Transformers community
Papers with Code archive
7 ran · 0 no recorded run
drumpt/ViT community
not in the paper's declared repositories
7 ran · 0 no recorded run
asyml/vision-transformer-pytorch community
not in the paper's declared repositories
7 ran · 0 no recorded run
KiUngSong/Vision community
Papers with Code archive
7 ran · 0 no recorded run
lukas-blecher/LaTeX-OCR community (classifier label)
classifier basis not recorded on the link
6 ran · 5 no recorded run
pytorch/vision community
not in the paper's declared repositories
6 ran · 4 no recorded run
Ugenteraan/Vanilla-ViT community
not in the paper's declared repositories
6 ran · 3 no recorded run
kamalkraj/Vision-Transformer community
not in the paper's declared repositories
6 ran · 2 no recorded run
sangHa0411/VIT community
not in the paper's declared repositories
6 ran · 1 no recorded run
Ugenteraan/Masked-AutoEncoder-PyTorch community
Papers with Code archive
6 ran · 1 no recorded run
nachiket273/Vision_transformer_pytorch community
not in the paper's declared repositories
6 ran · 0 no recorded run
mdmhriday/vision-transformers community
not in the paper's declared repositories
6 ran · 0 no recorded run
nachiket273/VisTrans community
not in the paper's declared repositories
5 ran · 5 no recorded run
facebookresearch/ClassyVision community
not in the paper's declared repositories
5 ran · 4 no recorded run
skchen1993/TrangFG community
not in the paper's declared repositories
5 ran · 3 no recorded run
TheTensorDude/vision_transformer_tf community
Papers with Code archive
5 ran · 3 no recorded run
gupta-abhay/ViT community
not in the paper's declared repositories
5 ran · 2 no recorded run
uzi0espil/research-papers-implementation community
not in the paper's declared repositories
5 ran · 1 no recorded run
Mayurji/Image-Classification-PyTorch community
Papers with Code archive
5 ran · 0 no recorded run
FunctionStatusWhere it lives
np2th Ran
ran; the contract check could not run (RAISES, DEP_MISSING or TIMEOUT)
jeonsworld/ViT-pytorch/models/modeling.py
code served (permissive licence) · get_code("7d8eaf5537f699e4")
How it ran

Ran in Syntology's jail on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1) and returned Tensor, ndim 4, dtype family float, shape (5, 4, 2, 3) as a later run recorded it. The image it ran in was not recorded. The comparison behind this sample's level is a different run: the peer-agreement lane ran it again on the host, not in the jail (report dated 2026-09-05T00:36:31Z). 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 numpy as np

torch.manual_seed(0)

# Create a small numpy array with shape HWIO (Height, Width, Input channels, Output channels)
# Using distinct dimensions: H=2, W=3, I=4, O=5
weights = np.random.randn(2, 3, 4, 5).astype(np.float32)

ARGS = {
    "weights": weights,
    "conv": True
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1
Imports
numpy, torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type Tensor, ndim 4, dtype family float, shape (5, 4, 2, 3) — shape (5, 4, 2, 3) 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
swish Ran
ran; our contract draft was wrong, not the code
jeonsworld/ViT-pytorch/models/modeling.py
code served (permissive licence) · get_code("0f786c407fb1ee4c")
How it ran

Ran in Syntology's jail on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1) and returned Tensor, ndim 2, dtype family float, shape (2, 4) as a later run recorded it. The image it ran in was not recorded. The comparison behind this sample's level is a different run: the peer-agreement lane ran it again on the host, not in the jail (report dated 2026-09-04T22:33:52Z). 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

torch.manual_seed(0)

# The function swish takes a single parameter 'x' which is used with:
# - torch.sigmoid(x) - requires a tensor
# - x * ... - requires a tensor that supports multiplication
# So x should be a tensor

x = torch.randn(2, 4)

ARGS = {
    "x": x
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1
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 2, dtype family float, shape (2, 4) — shape (2, 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
Attention Ran
ran on a synthesized input · constructed an object; no result was computed
mahmoodlab/hipt/HIPT_4K/vision_transformer.py
pointer only (licence: NOASSERTION) · get_code("3806102629027da3")
How it ran

The body of this sample is withheld: GitHub could not classify the licence of this paper's repository, mahmoodlab/hipt (NOASSERTION). 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.

Attention Ran
ran on a synthesized input
asarigun/TransGAN/models.py
code served (permissive licence) · get_code("f817c1f38785cb41")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, class construct-then-call prompt, model not recorded) and returned Tensor, ndim 3, dtype family float; no output shape is stated. The image it ran in was not recorded. If your copy returns the same type and ndim 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 scipy import stats

INIT_ARGS = {
    "dim": 4,
    "heads": 2,
    "attention_dropout": 0.1,
    "proj_dropout": 0.1,
}

# Construct input tensor: batch=2, sequence_length=3, dim=4
ARGS = {
    "x": torch.randn(2, 3, 4),
}
Setup block drafted by
a language model, class construct-then-call prompt, model not recorded
Imports
numpy, scipy, 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 — no output shape is stated: observe_signature.py observed this class with its constructor sizes canonicalised where it could, which the node does not record, so its shape is not stated as this setup block's
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: torch and numpy seeded to 0 by the harness immediately before the class was constructed from INIT_ARGS (fixture_check.py)
Attention Ran
ran on a synthesized input
nachiket273/VisTrans/vistrans/models/vit.py
code served (permissive licence) · get_code("5f7f49ed28389849")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, class construct-then-call prompt, model not recorded) and returned Tensor, ndim 3, dtype family float; no output shape is stated. The image it ran in was not recorded. If your copy returns the same type and ndim 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

# INIT_ARGS: parameters for Attention.__init__
INIT_ARGS = {
    'dim': 16,
    'num_heads': 4,
    'attn_dropout': 0.1,
    'bias': False
}

# ARGS: parameters for Attention.forward
# Input shape: (batch_size, sequence_length, dim)
ARGS = {
    'x': torch.randn(2, 5, 16)
}
Setup block drafted by
a language model, class construct-then-call prompt, model not recorded
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 — no output shape is stated: observe_signature.py observed this class with its constructor sizes canonicalised where it could, which the node does not record, so its shape is not stated as this setup block's
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: torch and numpy seeded to 0 by the harness immediately before the class was constructed from INIT_ARGS (fixture_check.py)
Attention Ran
ran on a synthesized input · constructed an object; no result was computed
explainingai-code/VIT-Pytorch/model/transformer.py
pointer only (licence: NONE) · get_code("998014b6f71af139")
How it ran

The body of this sample is withheld: GitHub detected no licence in this paper's repository, explainingai-code/VIT-Pytorch 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.

Attention Ran
ran on a synthesized input
nachiket273/Vision_transformer_pytorch/vit.py
pointer only (licence: NONE) · get_code("4e9b033c45eda05d")
How it ran

The body of this sample is withheld: GitHub detected no licence in this paper's repository, nachiket273/Vision_transformer_pytorch 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.

Attention Ran
ran on a synthesized input · constructed an object; no result was computed
OML-Team/open-metric-learning/oml/models/vit_dino/external_v2/vision_transformer.py
code served (permissive licence) · get_code("49d02e769ff703f2")
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)

ARGS = {
    "dim": 8,
    "num_heads": 2,
    "qkv_bias": False,
    "proj_bias": True,
    "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
Attention Ran
ran on a synthesized input · constructed an object; no result was computed
SHI-Labs/Compact-Transformers/src/vit.py
code served (permissive licence) · get_code("fb209281f7dc7ae4")
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
from torch.nn import Module, ModuleList, Linear, Dropout, LayerNorm, Identity, Parameter, init

torch.manual_seed(0)

# The Attention module expects:
# - dim: embedding dimension (int)
# - num_heads: number of attention heads (int)
# - attention_dropout: dropout rate for attention (float)
# - projection_dropout: dropout rate for projection (float)

ARGS = {
    "dim": 8,
    "num_heads": 2,
    "attention_dropout": 0.1,
    "projection_dropout": 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
Attention Ran
ran on a synthesized input · constructed an object; no result was computed
HzcIrving/DeepLearning_PlayGround/VIT/Model.py
code served (permissive licence) · get_code("e65111831b48a20f")
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
import math

torch.manual_seed(0)

# Create a minimal config object with required attributes
class Config:
    def __init__(self):
        self.hidden_size = 12
        self.transformer = {
            'num_heads': 3,
            'attention_dropout_rate': 0.1
        }

config = Config()

# Create hidden_states tensor
# Shape: (batch_size=2, sequence_length=5, hidden_size=12)
hidden_states = torch.randn(2, 5, 12)

# Assemble arguments
ARGS = {
    'config': config,
    'vis': False
}
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
Attention Ran
ran on a synthesized input
meowbutlerdev/ViT/vit.py
pointer only (licence: NONE) · get_code("03826c508404de86")
How it ran

The body of this sample is withheld: GitHub detected no licence in this paper's repository, meowbutlerdev/ViT 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.

Attention Ran
ran on a synthesized input · constructed an object; no result was computed
Mayurji/Image-Classification-PyTorch/ViT.py
pointer only (licence: GPL-3.0) · get_code("99a27bf8a6745bca")
How it ran

The body of this sample is withheld: GPL-3.0, as GitHub detects it on this paper's repository, Mayurji/Image-Classification-PyTorch, is not in the permissive set Syntology serves inline. 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.

Attention Ran
ran on a synthesized input
lucidrains/vit-pytorch/vit_pytorch/vit.py
code served (permissive licence) · get_code("303b5fcf0f3b83ab")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, class construct-then-call prompt, model not recorded) and returned Tensor, ndim 3, dtype family float, shape (2, 5, 16) 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
from torch import nn
from torch.nn import Module, ModuleList
from einops import rearrange, repeat

class Attention(Module):

    def __init__(self, dim, heads=8, dim_head=64, dropout=0.0):
        super().__init__()
        inner_dim = dim_head * heads
        project_out = not (heads == 1 and dim_head == dim)
        self.heads = heads
        self.scale = dim_head ** (-0.5)
        self.norm = nn.LayerNorm(dim)
        self.attend = nn.Softmax(dim=-1)
        self.dropout = nn.Dropout(dropout)
        self.to_qkv = nn.Linear(dim, inner_dim * 3, bias=False)
        self.to_out = nn.Sequential(nn.Linear(inner_dim, dim), nn.Dropout(dropout)) if project_out else nn.Identity()

    def forward(self, x):
        x = self.norm(x)
        qkv = self.to_qkv(x).chunk(3, dim=-1)
        q, k, v = map(lambda t: rearrange(t, 'b n (h d) -> b h n d', h=self.heads), qkv)
        dots = torch.matmul(q, k.transpose(-1, -2)) * self.scale
        attn = self.attend(dots)
        attn = self.dropout(attn)
        out = torch.matmul(attn, v)
        out = rearrange(out, 'b h n d -> b n (h d)')
        return self.to_out(out)


INIT_ARGS = {
    'dim': 16,
    'heads': 2,
    'dim_head': 8,
    'dropout': 0.1,
}

ARGS = {
    'x': torch.randn(2, 5, 16),
}

if __name__ == '__main__':
    attention = Attention(**INIT_ARGS)
    output = attention(**ARGS)
    print(f"Output shape: {output.shape}")
    print(f"Expected shape: (2, 5, 16)")
Setup block drafted by
a language model, class construct-then-call prompt, model not recorded
Imports
einops, 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 (2, 5, 16) — shape (2, 5, 16) 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: torch and numpy seeded to 0 by the harness immediately before the class was constructed from INIT_ARGS (fixture_check.py)
Attention Ran
ran on a synthesized input
jankrepl/mildlyoverfitted/github_adventures/vision_transformer/custom.py
code served (permissive licence) · get_code("e526ae2dd17da9d3")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, class construct-then-call prompt, model not recorded) and returned Tensor, ndim 3, dtype family float; no output shape is stated. The image it ran in was not recorded. If your copy returns the same type and ndim 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

# INIT_ARGS: parameters for Attention.__init__
INIT_ARGS = {
    'dim': 8,
    'n_heads': 2,
    'qkv_bias': True,
    'attn_p': 0.1,
    'proj_p': 0.1
}

# ARGS: parameters for Attention.forward
# x shape: (n_samples, n_patches + 1, dim)
# Using n_samples=2, n_patches+1=5 (so 5 tokens total), dim=8 (must match INIT_ARGS['dim'])
ARGS = {
    'x': torch.randn(2, 5, 8)
}
Setup block drafted by
a language model, class construct-then-call prompt, model not recorded
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 — no output shape is stated: observe_signature.py observed this class with its constructor sizes canonicalised where it could, which the node does not record, so its shape is not stated as this setup block's
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: torch and numpy seeded to 0 by the harness immediately before the class was constructed from INIT_ARGS (fixture_check.py)
Attention Ran
ran on a synthesized input
skchen1993/TrangFG/models/modeling.py
code served (permissive licence) · get_code("4112d886f96a0258")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, class construct-then-call prompt, model not recorded) and returned tuple. 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 math
import torch
import torch.nn as nn
from torch.nn import CrossEntropyLoss, Dropout, Softmax, Linear, Conv2d, LayerNorm

class Attention(nn.Module):

    def __init__(self, config):
        super(Attention, self).__init__()
        self.num_attention_heads = config.transformer['num_heads']
        self.attention_head_size = int(config.hidden_size / self.num_attention_heads)
        self.all_head_size = self.num_attention_heads * self.attention_head_size
        self.query = Linear(config.hidden_size, self.all_head_size)
        self.key = Linear(config.hidden_size, self.all_head_size)
        self.value = Linear(config.hidden_size, self.all_head_size)
        self.out = Linear(config.hidden_size, config.hidden_size)
        self.attn_dropout = Dropout(config.transformer['attention_dropout_rate'])
        self.proj_dropout = Dropout(config.transformer['attention_dropout_rate'])
        self.softmax = Softmax(dim=-1)

    def transpose_for_scores(self, x):
        new_x_shape = x.size()[:-1] + (self.num_attention_heads, self.attention_head_size)
        x = x.view(*new_x_shape)
        return x.permute(0, 2, 1, 3)

    def forward(self, hidden_states):
        mixed_query_layer = self.query(hidden_states)
        mixed_key_layer = self.key(hidden_states)
        mixed_value_layer = self.value(hidden_states)
        query_layer = self.transpose_for_scores(mixed_query_layer)
        key_layer = self.transpose_for_scores(mixed_key_layer)
        value_layer = self.transpose_for_scores(mixed_value_layer)
        attention_scores = torch.matmul(query_layer, key_layer.transpose(-1, -2))
        attention_scores = attention_scores / math.sqrt(self.attention_head_size)
        attention_probs = self.softmax(attention_scores)
        weights = attention_probs
        attention_probs = self.attn_dropout(attention_probs)
        context_layer = torch.matmul(attention_probs, value_layer)
        context_layer = context_layer.permute(0, 2, 1, 3).contiguous()
        new_context_layer_shape = context_layer.size()[:-2] + (self.all_head_size,)
        context_layer = context_layer.view(*new_context_layer_shape)
        attention_output = self.out(context_layer)
        attention_output = self.proj_dropout(attention_output)
        return (attention_output, weights)


class Config:
    def __init__(self, hidden_size, num_heads, attention_dropout_rate):
        self.hidden_size = hidden_size
        self.transformer = {
            'num_heads': num_heads,
            'attention_dropout_rate': attention_dropout_rate
        }


INIT_ARGS = {
    'config': Config(hidden_size=8, num_heads=2, attention_dropout_rate=0.1)
}

ARGS = {
    'hidden_states': torch.randn(2, 5, 8)
}

if __name__ == '__main__':
    attention = Attention(**INIT_ARGS)
    attention.eval()
    output, weights = attention(**ARGS)
    print("Output shape:", output.shape)
    print("Weights shape:", weights.shape)
    print("Test passed!")
Setup block drafted by
a language model, class construct-then-call prompt, model not recorded
Imports
torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type tuple — a tuple output has no array shape of its own; none is 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: torch and numpy seeded to 0 by the harness immediately before the class was constructed from INIT_ARGS (fixture_check.py)
Attention Ran
ran on a synthesized input
kamalkraj/Vision-Transformer/model.py
code served (permissive licence) · get_code("5dba6c3975d89f90")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, class construct-then-call prompt, model not recorded) and returned EagerTensor, ndim 3, dtype family float, shape (2, 3, 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 tensorflow as tf
import numpy as np
from einops.layers.tensorflow import Rearrange

class Attention(tf.keras.Model):

    def __init__(self, dim, heads=8):
        super().__init__()
        self.heads = heads
        self.scale = dim ** (-0.5)
        self.to_qkv = tf.keras.layers.Dense(dim * 3, use_bias=False)
        self.to_out = tf.keras.layers.Dense(dim)
        self.rearrange_qkv = Rearrange('b n (qkv h d) -> qkv b h n d', qkv=3, h=self.heads)
        self.rearrange_out = Rearrange('b h n d -> b n (h d)')

    def call(self, x):
        qkv = self.to_qkv(x)
        qkv = self.rearrange_qkv(qkv)
        q = qkv[0]
        k = qkv[1]
        v = qkv[2]
        dots = tf.einsum('bhid,bhjd->bhij', q, k) * self.scale
        attn = tf.nn.softmax(dots, axis=-1)
        out = tf.einsum('bhij,bhjd->bhid', attn, v)
        out = self.rearrange_out(out)
        out = self.to_out(out)
        return out


INIT_ARGS = {
    'dim': 4,
    'heads': 2,
}

ARGS = {
    'x': tf.constant(np.random.randn(2, 3, 4).astype(np.float32)),
}

METHOD = 'call'

if __name__ == '__main__':
    model = Attention(**INIT_ARGS)
    output = model(**ARGS)
    print(f"Output shape: {output.shape}")
    print(f"Output: {output}")
Setup block drafted by
a language model, class construct-then-call prompt, model not recorded
Imports
einops, numpy, tensorflow — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type EagerTensor, ndim 3, dtype family float, shape (2, 3, 4) — shape (2, 3, 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: torch and numpy seeded to 0 by the harness immediately before the class was constructed from INIT_ARGS (fixture_check.py)
AttentionHead Ran
ran on a synthesized input
tintn/vision-transformer-from-scratch/vit.py
code served (permissive licence) · get_code("b4bfa3287132b6de")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, class construct-then-call prompt, model not recorded) and returned tuple. 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 math
import torch
from torch import nn

class AttentionHead(nn.Module):
    """
    A single attention head.
    This module is used in the MultiHeadAttention module.

    """

    def __init__(self, hidden_size, attention_head_size, dropout, bias=True):
        super().__init__()
        self.hidden_size = hidden_size
        self.attention_head_size = attention_head_size
        self.query = nn.Linear(hidden_size, attention_head_size, bias=bias)
        self.key = nn.Linear(hidden_size, attention_head_size, bias=bias)
        self.value = nn.Linear(hidden_size, attention_head_size, bias=bias)
        self.dropout = nn.Dropout(dropout)

    def forward(self, x):
        query = self.query(x)
        key = self.key(x)
        value = self.value(x)
        attention_scores = torch.matmul(query, key.transpose(-1, -2))
        attention_scores = attention_scores / math.sqrt(self.attention_head_size)
        attention_probs = nn.functional.softmax(attention_scores, dim=-1)
        attention_probs = self.dropout(attention_probs)
        attention_output = torch.matmul(attention_probs, value)
        return (attention_output, attention_probs)


INIT_ARGS = {
    'hidden_size': 4,
    'attention_head_size': 3,
    'dropout': 0.1,
    'bias': True
}

ARGS = {
    'x': torch.randn(2, 5, 4)
}

if __name__ == '__main__':
    attention_head = AttentionHead(**INIT_ARGS)
    output, probs = attention_head(**ARGS)
    print(f"Output shape: {output.shape}")
    print(f"Attention probs shape: {probs.shape}")
Setup block drafted by
a language model, class construct-then-call prompt, model not recorded
Imports
torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type tuple — a tuple output has no array shape of its own; none is 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: torch and numpy seeded to 0 by the harness immediately before the class was constructed from INIT_ARGS (fixture_check.py)
AttentionModel Ran
ran on a synthesized input · constructed an object; no result was computed
YousefGamal220/Vision-Transformers/vision_transformer.py
pointer only (licence: NONE) · get_code("b527c73fd851cfee")
How it ran

The body of this sample is withheld: GitHub detected no licence in this paper's repository, YousefGamal220/Vision-Transformers 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.

Augmentation Ran
ran on a synthesized input · constructed an object; no result was computed
uzi0espil/research-papers-implementation/Vision Transformer/models.py
pointer only (licence: NONE) · get_code("436acd4bdbe997d2")
How it ran

The body of this sample is withheld: GitHub detected no licence in this paper's repository, uzi0espil/research-papers-implementation 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.

Block Ran
ran on a synthesized input · constructed an object; no result was computed
mahmoodlab/hipt/HIPT_4K/vision_transformer.py
pointer only (licence: NOASSERTION) · get_code("65e124fb59929e7b")
How it ran

The body of this sample is withheld: GitHub could not classify the licence of this paper's repository, mahmoodlab/hipt (NOASSERTION). 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.

Block Ran
ran on a synthesized input · constructed an object; no result was computed
nateraw/lightning-vision-transformer/vit.py
code served (permissive licence) · get_code("82e3e86f7ef279d6")
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
from torch import nn

torch.manual_seed(0)

# Block expects:
# - dim: int (embedding dimension)
# - heads: int (number of attention heads)
# - dropout_p: float (dropout probability, optional, defaults to 0.0)

ARGS = {
    "dim": 4,
    "heads": 2,
    "dropout_p": 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 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
Block Ran
ran on a synthesized input · constructed an object; no result was computed
naver-ai/pflayer/vit_pf.py
code served (permissive licence) · get_code("111794c24e7fff19")
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
from timm.models.layers import DropPath
from timm.models.vision_transformer import Attention, Mlp

torch.manual_seed(0)

ARGS = {
    'dim': 4,
    'num_heads': 2,
    '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,
    'attn_type': 'max',
    'kernel_size': 3,
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
einops, 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
Block Ran
ran on a synthesized input · constructed an object; no result was computed
nachiket273/Vision_transformer_pytorch/vit.py
pointer only (licence: NONE) · get_code("908f6f29e84e7834")
How it ran

The body of this sample is withheld: GitHub detected no licence in this paper's repository, nachiket273/Vision_transformer_pytorch 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.

Block Ran
ran on a synthesized input · constructed an object; no result was computed
arkel23/PyTorch-Pretrained-ViT/pytorch_pretrained_vit/model.py
pointer only (licence: NONE) · get_code("d6d3c10e6aeb535b")
How it ran

The body of this sample is withheld: GitHub detected no licence in this paper's repository, arkel23/PyTorch-Pretrained-ViT 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.

Block Ran
ran on a synthesized input · constructed an object; no result was computed
junyongyou/triq/src/vit_iqa/ViT_pytorch/models/modeling.py
code served (permissive licence) · get_code("4af23178d3041345")
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
from torch.nn import LayerNorm

torch.manual_seed(0)

class Config:
    def __init__(self):
        self.hidden_size = 16
        self.transformer = {
            'num_heads': 4,
            'attention_dropout_rate': 0.1,
            'mlp_dim': 32,
            'dropout_rate': 0.1,
        }

config = Config()
vis = False

ARGS = {
    'config': config,
    'vis': vis,
}
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 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
Block Ran
ran on a synthesized input
HzcIrving/DeepLearning_PlayGround/VIT/Model.py
code served (permissive licence) · get_code("0c8c99ad8b44657f")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, class construct-then-call prompt, model not recorded) and returned tuple. 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 math
import torch
import torch.nn as nn
from torch.nn import CrossEntropyLoss, Dropout, Softmax, Linear, Conv2d, LayerNorm


def swish(x):
    return x * torch.sigmoid(x)


ACT2FN = {'gelu': torch.nn.functional.gelu, 'relu': torch.nn.functional.relu, 'swish': swish}


class Attention(nn.Module):

    def __init__(self, config, vis=False):
        super(Attention, self).__init__()
        self.vis = vis
        self.num_attention_heads = config.transformer['num_heads']
        self.attention_head_size = int(config.hidden_size / self.num_attention_heads)
        self.all_head_size = self.num_attention_heads * self.attention_head_size
        self.query = Linear(config.hidden_size, self.all_head_size)
        self.key = Linear(config.hidden_size, self.all_head_size)
        self.value = Linear(config.hidden_size, self.all_head_size)
        self.out = Linear(config.hidden_size, config.hidden_size)
        self.attn_dropout = Dropout(config.transformer['attention_dropout_rate'])
        self.proj_dropout = Dropout(config.transformer['attention_dropout_rate'])
        self.softmax = Softmax(dim=-1)

    def transpose_for_scores(self, x):
        new_x_shape = x.size()[:-1] + (self.num_attention_heads, self.attention_head_size)
        x = x.view(*new_x_shape)
        return x.permute(0, 2, 1, 3)

    def forward(self, hidden_states):
        mixed_query_layer = self.query(hidden_states)
        mixed_key_layer = self.key(hidden_states)
        mixed_value_layer = self.value(hidden_states)
        query_layer = self.transpose_for_scores(mixed_query_layer)
        key_layer = self.transpose_for_scores(mixed_key_layer)
        value_layer = self.transpose_for_scores(mixed_value_layer)
        attention_scores = torch.matmul(query_layer, key_layer.transpose(-1, -2))
        attention_scores = attention_scores / math.sqrt(self.attention_head_size)
        attention_probs = self.softmax(attention_scores)
        weights = attention_probs if self.vis else None
        attention_probs = self.attn_dropout(attention_probs)
        context_layer = torch.matmul(attention_probs, value_layer)
        context_layer = context_layer.permute(0, 2, 1, 3).contiguous()
        new_context_layer_shape = context_layer.size()[:-2] + (self.all_head_size,)
        context_layer = context_layer.view(*new_context_layer_shape)
        attention_output = self.out(context_layer)
        attention_output = self.proj_dropout(attention_output)
        return (attention_output, weights)


class Mlp(nn.Module):

    def __init__(self, config):
        super(Mlp, self).__init__()
        self.fc1 = Linear(config.hidden_size, config.transformer['mlp_dim'])
        self.fc2 = Linear(config.transformer['mlp_dim'], config.hidden_size)
        self.act_fn = ACT2FN['gelu']
        self.dropout = Dropout(config.transformer['dropout_rate'])
        self._init_weights()

    def _init_weights(self):
        nn.init.xavier_uniform_(self.fc1.weight)
        nn.init.xavier_uniform_(self.fc2.weight)
        nn.init.normal_(self.fc1.bias, std=1e-06)
        nn.init.normal_(self.fc2.bias, std=1e-06)

    def forward(self, x):
        x = self.fc1(x)
        x = self.act_fn(x)
        x = self.dropout(x)
        x = self.fc2(x)
        x = self.dropout(x)
        return x


class Block(nn.Module):

    def __init__(self, config, vis):
        super(Block, self).__init__()
        self.hidden_size = config.hidden_size
        self.attention_norm = LayerNorm(config.hidden_size, eps=1e-06)
        self.ffn_norm = LayerNorm(config.hidden_size, eps=1e-06)
        self.ffn = Mlp(config)
        self.attn = Attention(config, vis)

    def forward(self, x):
        h = x
        x = self.attention_norm(x)
        x, weights = self.attn(x)
        x = x + h
        h = x
        x = self.ffn_norm(x)
        x = self.ffn(x)
        x = x + h
        return (x, weights)


class Config:
    def __init__(self):
        self.hidden_size = 8
        self.transformer = {
            'num_heads': 2,
            'attention_dropout_rate': 0.1,
            'dropout_rate': 0.1,
            'mlp_dim': 16
        }


INIT_ARGS = {
    'config': Config(),
    'vis': False
}

ARGS = {
    'x': torch.randn(2, 5, 8)
}

if __name__ == '__main__':
    block = Block(**INIT_ARGS)
    output, weights = block(**ARGS)
    print("Output shape:", output.shape)
    print("Weights:", weights)
Setup block drafted by
a language model, class construct-then-call prompt, model not recorded
Imports
torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type tuple — a tuple output has no array shape of its own; none is 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: torch and numpy seeded to 0 by the harness immediately before the class was constructed from INIT_ARGS (fixture_check.py)
Block Ran
ran on a synthesized input · constructed an object; no result was computed
wangguanan/light-reid/lightreid/models/backbones/transformers/vit_timm.py
pointer only (licence: NONE) · get_code("f9eebdcbcec2008d")
How it ran

The body of this sample is withheld: GitHub detected no licence in this paper's repository, wangguanan/light-reid 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.

Block Ran
ran on a synthesized input · constructed an object; no result was computed
lukemelas/PyTorch-Pretrained-ViT/pytorch_pretrained_vit/model.py
pointer only (licence: NONE) · get_code("dd163b043f6772c8")
How it ran

The body of this sample is withheld: GitHub detected no licence in this paper's repository, lukemelas/PyTorch-Pretrained-ViT 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.

Block Ran
ran on a synthesized input
jankrepl/mildlyoverfitted/github_adventures/vision_transformer/custom.py
code served (permissive licence) · get_code("c559706fd8342db1")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, class construct-then-call prompt, model not recorded) and returned Tensor, ndim 3, dtype family float, shape (2, 3, 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 torch.nn as nn

# Import the classes (assuming they're defined above or in scope)
class Attention(nn.Module):
    def __init__(self, dim, n_heads=12, qkv_bias=True, attn_p=0.0, proj_p=0.0):
        super().__init__()
        self.n_heads = n_heads
        self.dim = dim
        self.head_dim = dim // n_heads
        self.scale = self.head_dim ** (-0.5)
        self.qkv = nn.Linear(dim, dim * 3, bias=qkv_bias)
        self.attn_drop = nn.Dropout(attn_p)
        self.proj = nn.Linear(dim, dim)
        self.proj_drop = nn.Dropout(proj_p)

    def forward(self, x):
        n_samples, n_tokens, dim = x.shape
        if dim != self.dim:
            raise ValueError
        qkv = self.qkv(x)
        qkv = qkv.reshape(n_samples, n_tokens, 3, self.n_heads, self.head_dim)
        qkv = qkv.permute(2, 0, 3, 1, 4)
        q, k, v = (qkv[0], qkv[1], qkv[2])
        k_t = k.transpose(-2, -1)
        dp = q @ k_t * self.scale
        attn = dp.softmax(dim=-1)
        attn = self.attn_drop(attn)
        weighted_avg = attn @ v
        weighted_avg = weighted_avg.transpose(1, 2)
        weighted_avg = weighted_avg.flatten(2)
        x = self.proj(weighted_avg)
        x = self.proj_drop(x)
        return x

class MLP(nn.Module):
    def __init__(self, in_features, hidden_features, out_features, p=0.0):
        super().__init__()
        self.fc1 = nn.Linear(in_features, hidden_features)
        self.act = nn.GELU()
        self.fc2 = nn.Linear(hidden_features, out_features)
        self.drop = nn.Dropout(p)

    def forward(self, x):
        x = self.fc1(x)
        x = self.act(x)
        x = self.drop(x)
        x = self.fc2(x)
        x = self.drop(x)
        return x

class Block(nn.Module):
    def __init__(self, dim, n_heads, mlp_ratio=4.0, qkv_bias=True, p=0.0, attn_p=0.0):
        super().__init__()
        self.norm1 = nn.LayerNorm(dim, eps=1e-06)
        self.attn = Attention(dim, n_heads=n_heads, qkv_bias=qkv_bias, attn_p=attn_p, proj_p=p)
        self.norm2 = nn.LayerNorm(dim, eps=1e-06)
        hidden_features = int(dim * mlp_ratio)
        self.mlp = MLP(in_features=dim, hidden_features=hidden_features, out_features=dim)

    def forward(self, x):
        x = x + self.attn(self.norm1(x))
        x = x + self.mlp(self.norm2(x))
        return x

INIT_ARGS = {
    'dim': 4,
    'n_heads': 2,
    'mlp_ratio': 4.0,
    'qkv_bias': True,
    'p': 0.0,
    'attn_p': 0.0,
}

ARGS = {
    'x': torch.randn(2, 3, 4),
}

if __name__ == '__main__':
    block = Block(**INIT_ARGS)
    output = block(**ARGS)
    print(f"Output shape: {output.shape}")
    print(f"Expected shape: (2, 3, 4)")
    assert output.shape == (2, 3, 4), f"Shape mismatch: {output.shape}"
    print("Test passed!")
Setup block drafted by
a language model, class construct-then-call prompt, model not recorded
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 (2, 3, 4) — shape (2, 3, 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: torch and numpy seeded to 0 by the harness immediately before the class was constructed from INIT_ARGS (fixture_check.py)
Block Ran
ran on a synthesized input
skchen1993/TrangFG/models/modeling.py
code served (permissive licence) · get_code("8711444686518b7c")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, class construct-then-call prompt, model not recorded) and returned tuple. 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 torch.nn import LayerNorm, Linear, Dropout, Softmax
import math

def gelu(x):
    return torch.nn.functional.gelu(x)

ACT2FN = {'gelu': gelu, 'relu': torch.nn.functional.relu}

class Attention(nn.Module):
    def __init__(self, config):
        super(Attention, self).__init__()
        self.num_attention_heads = config.transformer['num_heads']
        self.attention_head_size = int(config.hidden_size / self.num_attention_heads)
        self.all_head_size = self.num_attention_heads * self.attention_head_size
        self.query = Linear(config.hidden_size, self.all_head_size)
        self.key = Linear(config.hidden_size, self.all_head_size)
        self.value = Linear(config.hidden_size, self.all_head_size)
        self.out = Linear(config.hidden_size, config.hidden_size)
        self.attn_dropout = Dropout(config.transformer['attention_dropout_rate'])
        self.proj_dropout = Dropout(config.transformer['attention_dropout_rate'])
        self.softmax = Softmax(dim=-1)

    def transpose_for_scores(self, x):
        new_x_shape = x.size()[:-1] + (self.num_attention_heads, self.attention_head_size)
        x = x.view(*new_x_shape)
        return x.permute(0, 2, 1, 3)

    def forward(self, hidden_states):
        mixed_query_layer = self.query(hidden_states)
        mixed_key_layer = self.key(hidden_states)
        mixed_value_layer = self.value(hidden_states)
        query_layer = self.transpose_for_scores(mixed_query_layer)
        key_layer = self.transpose_for_scores(mixed_key_layer)
        value_layer = self.transpose_for_scores(mixed_value_layer)
        attention_scores = torch.matmul(query_layer, key_layer.transpose(-1, -2))
        attention_scores = attention_scores / math.sqrt(self.attention_head_size)
        attention_probs = self.softmax(attention_scores)
        weights = attention_probs
        attention_probs = self.attn_dropout(attention_probs)
        context_layer = torch.matmul(attention_probs, value_layer)
        context_layer = context_layer.permute(0, 2, 1, 3).contiguous()
        new_context_layer_shape = context_layer.size()[:-2] + (self.all_head_size,)
        context_layer = context_layer.view(*new_context_layer_shape)
        attention_output = self.out(context_layer)
        attention_output = self.proj_dropout(attention_output)
        return (attention_output, weights)

class Mlp(nn.Module):
    def __init__(self, config):
        super(Mlp, self).__init__()
        self.fc1 = Linear(config.hidden_size, config.transformer['mlp_dim'])
        self.fc2 = Linear(config.transformer['mlp_dim'], config.hidden_size)
        self.act_fn = ACT2FN['gelu']
        self.dropout = Dropout(config.transformer['dropout_rate'])
        self._init_weights()

    def _init_weights(self):
        nn.init.xavier_uniform_(self.fc1.weight)
        nn.init.xavier_uniform_(self.fc2.weight)
        nn.init.normal_(self.fc1.bias, std=1e-06)
        nn.init.normal_(self.fc2.bias, std=1e-06)

    def forward(self, x):
        x = self.fc1(x)
        x = self.act_fn(x)
        x = self.dropout(x)
        x = self.fc2(x)
        x = self.dropout(x)
        return x

class Block(nn.Module):
    def __init__(self, config):
        super(Block, self).__init__()
        self.hidden_size = config.hidden_size
        self.attention_norm = LayerNorm(config.hidden_size, eps=1e-06)
        self.ffn_norm = LayerNorm(config.hidden_size, eps=1e-06)
        self.ffn = Mlp(config)
        self.attn = Attention(config)

    def forward(self, x):
        h = x
        x = self.attention_norm(x)
        x, weights = self.attn(x)
        x = x + h
        h = x
        x = self.ffn_norm(x)
        x = self.ffn(x)
        x = x + h
        return (x, weights)

class Config:
    def __init__(self, hidden_size, num_heads, mlp_dim, attention_dropout_rate, dropout_rate):
        self.hidden_size = hidden_size
        self.transformer = {
            'num_heads': num_heads,
            'mlp_dim': mlp_dim,
            'attention_dropout_rate': attention_dropout_rate,
            'dropout_rate': dropout_rate
        }

INIT_ARGS = {
    'config': Config(
        hidden_size=8,
        num_heads=2,
        mlp_dim=16,
        attention_dropout_rate=0.1,
        dropout_rate=0.1
    )
}

ARGS = {
    'x': torch.randn(2, 5, 8)
}
Setup block drafted by
a language model, class construct-then-call prompt, model not recorded
Imports
torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type tuple — a tuple output has no array shape of its own; none is 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: torch and numpy seeded to 0 by the harness immediately before the class was constructed from INIT_ARGS (fixture_check.py)
BlockChunk Ran
ran on a synthesized input · constructed an object; no result was computed
OML-Team/open-metric-learning/oml/models/vit_dino/external_v2/vision_transformer.py
code served (permissive licence) · get_code("9af82963dffa88ab")
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, BlockChunk: 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)

# BlockChunk expects a sequence of nn.Module instances (blocks)
# It iterates through them in forward(), calling each one sequentially

# Create small stand-in blocks
class SimpleBlock(nn.Module):
    def __init__(self, in_dim, out_dim):
        super().__init__()
        self.linear = nn.Linear(in_dim, out_dim)
    
    def forward(self, x):
        return self.linear(x)

# Build a BlockChunk with a few simple blocks
block1 = SimpleBlock(4, 3)
block2 = SimpleBlock(3, 5)
block3 = SimpleBlock(5, 4)

# Create the list of blocks to pass to BlockChunk
blocks = [block1, block2, block3]

ARGS = {
    "modules": blocks
}
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 BlockChunk — 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 BlockChunk output the recorded ndim 1 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
BuildingBlock Ran
ran on a synthesized input · constructed an object; no result was computed
YousefGamal220/Vision-Transformers/vision_transformer.py
pointer only (licence: NONE) · get_code("126556b716f982c1")
How it ran

The body of this sample is withheld: GitHub detected no licence in this paper's repository, YousefGamal220/Vision-Transformers 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.

ClassToken Ran
ran on a synthesized input · constructed an object; no result was computed
TheTensorDude/vision_transformer_tf/vit.py
code served (permissive licence) · get_code("5283ae7455001543")
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, ClassToken: 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 tensorflow as tf
import numpy as np

# Set seed for reproducibility
tf.random.set_seed(0)
np.random.seed(0)

# Create a small input tensor for testing
# Shape: (batch_size=2, sequence_length=3, embedding_dimension=4)
input_tensor = tf.constant(
    np.random.randn(2, 3, 4).astype(np.float32)
)

# Define ARGS dictionary with all parameters for ClassToken
ARGS = {
    'embedding_dimension': 4,
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
numpy, tensorflow — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type ClassToken — 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 ClassToken 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
ClassToken Ran
ran on a synthesized input · constructed an object; no result was computed
uzi0espil/research-papers-implementation/Vision Transformer/models.py
pointer only (licence: NONE) · get_code("17713a3cee05e6cf")
How it ran

The body of this sample is withheld: GitHub detected no licence in this paper's repository, uzi0espil/research-papers-implementation 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.

ClassificationHead Ran
ran on a synthesized input · constructed an object; no result was computed
drumpt/ViT/model.py
pointer only (licence: NONE) · get_code("2bfce24bf8846119")
How it ran

The body of this sample is withheld: GitHub detected no licence in this paper's repository, drumpt/ViT 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.

Classifier Ran
ran on a synthesized input
s-chh/pytorch-scratch-vision-transformer-vit/model.py
code served (permissive licence) · get_code("97bb28e127fe8a6e")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, class construct-then-call prompt, model not recorded) and returned Tensor, ndim 2, dtype family float; no output shape is stated. The image it ran in was not recorded. If your copy returns the same type and ndim 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

INIT_ARGS = {
    'embed_dim': 4,
    'n_classes': 3,
}

ARGS = {
    'x': torch.randn(2, 5, 4),
}

if __name__ == '__main__':
    classifier = nn.Module.__new__(type('Classifier', (nn.Module,), {
        '__init__': lambda self, embed_dim, n_classes: (
            super(type(self), self).__init__(),
            setattr(self, 'fc1', nn.Linear(embed_dim, embed_dim)),
            setattr(self, 'activation', nn.Tanh()),
            setattr(self, 'fc2', nn.Linear(embed_dim, n_classes)),
        )[-1],
        'forward': lambda self, x: (
            self.fc2(self.activation(self.fc1(x[:, 0, :])))
        ),
    }))
    classifier.__init__(**INIT_ARGS)
    output = classifier(**ARGS)
    print(f"Output shape: {output.shape}")
    print(f"Expected shape: (2, 3)")
Setup block drafted by
a language model, class construct-then-call prompt, model not recorded
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 2, dtype family float — no output shape is stated: observe_signature.py observed this class with its constructor sizes canonicalised where it could, which the node does not record, so its shape is not stated as this setup block's
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: torch and numpy seeded to 0 by the harness immediately before the class was constructed from INIT_ARGS (fixture_check.py)
ClassyHead Ran
ran on a synthesized input · constructed an object; no result was computed
facebookresearch/ClassyVision/classy_vision/models/vision_transformer.py
code served (permissive licence) · get_code("423c8d43bb402561")
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, ClassyHead: 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 typing import Optional, Any, Dict

torch.manual_seed(0)

class SimpleClassyHead(nn.Module):
    """Concrete implementation of ClassyHead for testing"""
    
    def __init__(self, unique_id: Optional[str] = None, num_classes: Optional[int] = None):
        super().__init__()
        self.unique_id = unique_id or self.__class__.__name__
        self.num_classes = num_classes
        self.linear = nn.Linear(4, num_classes if num_classes else 10)
    
    @classmethod
    def from_config(cls, config: Dict[str, Any]) -> 'SimpleClassyHead':
        return cls(
            unique_id=config.get('unique_id'),
            num_classes=config.get('num_classes')
        )
    
    def forward(self, x):
        return self.linear(x)

ARGS = {
    'unique_id': 'head_1',
    'num_classes': 5
}
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 ClassyHead — 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 ClassyHead 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
ContrastiveLoss Ran
ran on a synthesized input · constructed an object; no result was computed
ludics/ViT-Retri/vit_retri/models/modeling.py
code served (permissive licence) · get_code("33a1d26b73f77059")
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, ContrastiveLoss: 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)

class ContrastiveLoss(nn.Module):

    def __init__(self, margin=0.5):
        super(ContrastiveLoss, self).__init__()
        self.margin = margin

    def forward(self, inputs_col, targets_col, inputs_row, target_row):
        n = inputs_col.size(0)
        sim_mat = torch.matmul(inputs_col, inputs_row.t())
        epsilon = 1e-05
        loss = list()
        neg_count = list()
        for i in range(n):
            pos_pair_ = torch.masked_select(sim_mat[i], targets_col[i] == target_row)
            pos_pair_ = torch.masked_select(pos_pair_, pos_pair_ < 1 - epsilon)
            neg_pair_ = torch.masked_select(sim_mat[i], targets_col[i] != target_row)
            neg_pair = torch.masked_select(neg_pair_, neg_pair_ > self.margin)
            pos_loss = torch.sum(-pos_pair_ + 1)
            if len(neg_pair) > 0:
                neg_loss = torch.sum(neg_pair)
                neg_count.append(len(neg_pair))
            else:
                neg_loss = 0
            loss.append(pos_loss + neg_loss)
        loss = sum(loss) / n
        return loss

# Create small tensors for testing
batch_size_col = 2
batch_size_row = 3
embedding_dim = 4

inputs_col = torch.randn(batch_size_col, embedding_dim)
targets_col = torch.tensor([0, 1], dtype=torch.long)

inputs_row = torch.randn(batch_size_row, embedding_dim)
target_row = torch.tensor([0, 1, 0], dtype=torch.long)

ARGS = {
    "margin": 0.5
}
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 ContrastiveLoss — 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 ContrastiveLoss 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
ConvLayer Ran
ran on a synthesized input · constructed an object; no result was computed
arkel23/PyTorch-Pretrained-ViT/pytorch_pretrained_vit/model.py
pointer only (licence: NONE) · get_code("bac5c11bc0553d22")
How it ran

The body of this sample is withheld: GitHub detected no licence in this paper's repository, arkel23/PyTorch-Pretrained-ViT 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.

ConvNormActivation Ran
ran on a synthesized input · constructed an object; no result was computed
pytorch/vision/torchvision/models/vision_transformer.py
code served (permissive licence) · get_code("4776b51b196152a8")
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, ConvNormActivation: 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 collections.abc import Sequence

torch.manual_seed(0)

ARGS = {
    'in_channels': 3,
    'out_channels': 16,
    'kernel_size': 3,
    'stride': 1,
    'padding': None,
    'groups': 1,
    'norm_layer': nn.BatchNorm2d,
    'activation_layer': nn.ReLU,
    'dilation': 1,
    'inplace': True,
    'bias': None,
    'conv_layer': nn.Conv2d,
}
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 ConvNormActivation — 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 ConvNormActivation output the recorded ndim 1 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
ConvPatchingStem Ran
ran on a synthesized input · constructed an object; no result was computed
arkel23/PyTorch-Pretrained-ViT/pytorch_pretrained_vit/model.py
pointer only (licence: NONE) · get_code("2a3546412a06424f")
How it ran

The body of this sample is withheld: GitHub detected no licence in this paper's repository, arkel23/PyTorch-Pretrained-ViT 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.

ConvStemConfig Ran
ran on a synthesized input · constructed an object; no result was computed
pytorch/vision/torchvision/models/vision_transformer.py
code served (permissive licence) · get_code("1212a18351c16c06")
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, ConvStemConfig: 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 = {
    "out_channels": 64,
    "kernel_size": 7,
    "stride": 2,
    "norm_layer": nn.BatchNorm2d,
    "activation_layer": nn.ReLU,
}
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 ConvStemConfig — 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 ConvStemConfig output the recorded ndim 1 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
ConvStemLayer Ran
ran on a synthesized input · constructed an object; no result was computed
facebookresearch/ClassyVision/classy_vision/models/vision_transformer.py
code served (permissive licence) · get_code("886721604390e021")
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, ConvStemLayer: 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

torch.manual_seed(0)

ARGS = {
    "kernel": 3,
    "stride": 1,
    "out_channels": 64,
}
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 ConvStemLayer — 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 ConvStemLayer output the recorded ndim 1 and dtype family int 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
CustomSwinTransformer Ran
ran on a synthesized input · constructed an object; no result was computed
mujiyantosvc/Facial-Expression-Recognition-FER-for-Mental-Health-Detection-/utilities/train_model.py
code served (permissive licence) · get_code("ff3b3cb2fa5e8545")
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, CustomSwinTransformer: 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 timm

torch.manual_seed(0)

ARGS = {
    'pretrained': False,
    'num_classes': 7
}
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 CustomSwinTransformer — 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 CustomSwinTransformer 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
DropPath Ran
ran on a synthesized input · constructed an object; no result was computed
mahmoodlab/hipt/HIPT_4K/vision_transformer.py
pointer only (licence: NOASSERTION) · get_code("ad5f80b54573c0e0")
How it ran

The body of this sample is withheld: GitHub could not classify the licence of this paper's repository, mahmoodlab/hipt (NOASSERTION). 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.

DropPath Ran
ran on a synthesized input · constructed an object; no result was computed
OML-Team/open-metric-learning/oml/models/vit_dino/external_v2/vision_transformer.py
code served (permissive licence) · get_code("1d3ee770ca7b30c9")
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, DropPath: 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)

# DropPath.__init__ takes drop_prob as a parameter
# The forward method calls drop_path(x, self.drop_prob, self.training)
# So we need to test the DropPath module with a tensor input

# Create a small test tensor with batch size 2 and feature dimension 4
x = torch.randn(2, 4)

# Define ARGS for DropPath.__init__
ARGS = {
    'drop_prob': 0.5
}
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 DropPath — 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 DropPath 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
DropPath Ran
ran on a synthesized input · constructed an object; no result was computed
SHI-Labs/Compact-Transformers/src/vit.py
code served (permissive licence) · get_code("e96ac00ca379ee0e")
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, DropPath: 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)

# DropPath.__init__ takes drop_prob as a parameter
# The forward method calls drop_path(x, self.drop_prob, self.training)
# So we need to provide a drop_prob value (float or None)

ARGS = {
    "drop_prob": 0.2
}
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 DropPath — 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 DropPath 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
EffLayer Ran
ran on a synthesized input · constructed an object; no result was computed
naver-ai/pflayer/vit_pf.py
code served (permissive licence) · get_code("6809cf195b936e15")
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, EffLayer: 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)

# The EffLayer expects:
# - dim: integer for embedding dimension
# - mlp_ratio: integer for expansion ratio
# - bias: boolean for linear layer bias
# - kernel_size: integer for pooling kernel
# - proj_drop: float for dropout rate

ARGS = {
    'dim': 4,
    'mlp_ratio': 3,
    'bias': True,
    'kernel_size': 3,
    'proj_drop': 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 EffLayer — 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 EffLayer 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
EffTransformer Ran
ran on a synthesized input · constructed an object; no result was computed
naver-ai/pflayer/vit_pf.py
code served (permissive licence) · get_code("2522fc9fcfe416c4")
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, EffTransformer: 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 functools import partial

torch.manual_seed(0)

ARGS = {
    'img_size': 224,
    'patch_size': 16,
    'in_chans': 3,
    'num_classes': 10,
    'embed_dim': 64,
    'depth': 2,
    'num_heads': 4,
    'mlp_ratio': 4.0,
    'qkv_bias': True,
    'qk_scale': None,
    'representation_size': None,
    'drop_rate': 0.0,
    'attn_drop_rate': 0.0,
    'drop_path_rate': 0.0,
    'hybrid_backbone': None,
    'norm_layer': None,
    'attn_type': 'max'
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
einops, timm, torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type EffTransformer — 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 EffTransformer 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
EmbedLayer Ran
ran on a synthesized input
s-chh/pytorch-scratch-vision-transformer-vit/model.py
code served (permissive licence) · get_code("236da9f27dd5c92f")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, class construct-then-call prompt, model not recorded) and returned Tensor, ndim 3, dtype family float, shape (2, 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 torch.nn as nn

class EmbedLayer(nn.Module):
    """
    Class for Embedding an Image.
    It breaks image into patches and embeds patches using a Conv2D Operation (Works same as the Linear layer).
    Next, a learnable positional embedding vector is added to all the patch embeddings to provide spatial position.
    Finally, a classification token is added which is used to classify the image.

    Parameters:
        n_channels (int) : Number of channels of the input image
        embed_dim  (int) : Embedding dimension
        image_size (int) : Image size
        patch_size (int) : Patch size
        dropout  (float) : dropout value

    Input:
        x (tensor): Image Tensor of shape B, C, IW, IH
    
    Returns:
        Tensor: Embedding of the image of shape B, S, E
    """

    def __init__(self, n_channels, embed_dim, image_size, patch_size, dropout=0.0):
        super().__init__()
        self.conv1 = nn.Conv2d(n_channels, embed_dim, kernel_size=patch_size, stride=patch_size)
        self.pos_embedding = nn.Parameter(torch.zeros(1, (image_size // patch_size) ** 2, embed_dim), requires_grad=True)
        self.cls_token = nn.Parameter(torch.zeros(1, 1, embed_dim), requires_grad=True)
        self.dropout = nn.Dropout(dropout)

    def forward(self, x):
        B = x.shape[0]
        x = self.conv1(x)
        x = x.reshape([B, x.shape[1], -1])
        x = x.permute(0, 2, 1)
        x = x + self.pos_embedding
        x = torch.cat((torch.repeat_interleave(self.cls_token, B, 0), x), dim=1)
        x = self.dropout(x)
        return x


INIT_ARGS = {
    'n_channels': 3,
    'embed_dim': 4,
    'image_size': 8,
    'patch_size': 2,
    'dropout': 0.1
}

ARGS = {
    'x': torch.randn(2, 3, 8, 8)
}

if __name__ == '__main__':
    model = EmbedLayer(**INIT_ARGS)
    output = model(**ARGS)
    print(f"Output shape: {output.shape}")
    print(f"Expected shape: (2, 17, 4)")
Setup block drafted by
a language model, class construct-then-call prompt, model not recorded
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 (2, 17, 4) — shape (2, 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: torch and numpy seeded to 0 by the harness immediately before the class was constructed from INIT_ARGS (fixture_check.py)
EmbeddingStem Ran
ran on a synthesized input · constructed an object; no result was computed
gupta-abhay/ViT/vit/vit.py
code served (permissive licence) · get_code("0bff27d821be8b25")
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, EmbeddingStem: 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)

ARGS = {
    'image_size': 224,
    'patch_size': 16,
    'channels': 3,
    'embedding_dim': 768,
    'hidden_dims': [64, 128, 256],
    'conv_patch': False,
    'linear_patch': True,
    'conv_stem': False,
    'conv_stem_original': True,
    'conv_stem_scaled_relu': False,
    'position_embedding_dropout': 0.1,
    'cls_head': True,
}
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 EmbeddingStem — 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 EmbeddingStem 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
Embeddings Ran
ran on a synthesized input
skchen1993/TrangFG/models/modeling.py
code served (permissive licence) · get_code("6cdae3f419a63138")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, class construct-then-call prompt, model not recorded) and returned Tensor, ndim 3, dtype family float, shape (2, 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 torch.nn as nn
from torch.nn import CrossEntropyLoss, Dropout, Softmax, Linear, Conv2d, LayerNorm
from torch.nn.modules.utils import _pair

class Embeddings(nn.Module):
    """Construct the embeddings from patch, position embeddings.
    """

    def __init__(self, config, img_size, in_channels=3):
        super(Embeddings, self).__init__()
        self.hybrid = None
        img_size = _pair(img_size)
        patch_size = _pair(config.patches['size'])
        if config.split == 'non-overlap':
            n_patches = img_size[0] // patch_size[0] * (img_size[1] // patch_size[1])
            self.patch_embeddings = Conv2d(in_channels=in_channels, out_channels=config.hidden_size, kernel_size=patch_size, stride=patch_size)
        elif config.split == 'overlap':
            n_patches = ((img_size[0] - patch_size[0]) // config.slide_step + 1) * ((img_size[1] - patch_size[1]) // config.slide_step + 1)
            self.patch_embeddings = Conv2d(in_channels=in_channels, out_channels=config.hidden_size, kernel_size=patch_size, stride=(config.slide_step, config.slide_step))
        self.position_embeddings = nn.Parameter(torch.zeros(1, n_patches + 1, config.hidden_size))
        self.cls_token = nn.Parameter(torch.zeros(1, 1, config.hidden_size))
        self.dropout = Dropout(config.transformer['dropout_rate'])

    def forward(self, x):
        B = x.shape[0]
        cls_tokens = self.cls_token.expand(B, -1, -1)
        if self.hybrid:
            x = self.hybrid_model(x)
        x = self.patch_embeddings(x)
        x = x.flatten(2)
        x = x.transpose(-1, -2)
        x = torch.cat((cls_tokens, x), dim=1)
        embeddings = x + self.position_embeddings
        embeddings = self.dropout(embeddings)
        return embeddings


config = type('Config', (), {
    'patches': {'size': 2},
    'split': 'non-overlap',
    'hidden_size': 4,
    'transformer': {'dropout_rate': 0.1}
})()

INIT_ARGS = {
    'config': config,
    'img_size': 8,
    'in_channels': 3
}

ARGS = {
    'x': torch.randn(2, 3, 8, 8)
}

model = Embeddings(**INIT_ARGS)
output = model(**ARGS)
Setup block drafted by
a language model, class construct-then-call prompt, model not recorded
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 (2, 17, 4) — shape (2, 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: torch and numpy seeded to 0 by the harness immediately before the class was constructed from INIT_ARGS (fixture_check.py)
Embeddings Ran
ran on a synthesized input
tintn/vision-transformer-from-scratch/vit.py
code served (permissive licence) · get_code("fe1bfe65727fc610")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, class construct-then-call prompt, model not recorded) and returned Tensor, ndim 3, dtype family float, shape (2, 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
from torch import nn

class PatchEmbeddings(nn.Module):
    """
    Convert the image into patches and then project them into a vector space.
    """

    def __init__(self, config):
        super().__init__()
        self.image_size = config['image_size']
        self.patch_size = config['patch_size']
        self.num_channels = config['num_channels']
        self.hidden_size = config['hidden_size']
        self.num_patches = (self.image_size // self.patch_size) ** 2
        self.projection = nn.Conv2d(self.num_channels, self.hidden_size, kernel_size=self.patch_size, stride=self.patch_size)

    def forward(self, x):
        x = self.projection(x)
        x = x.flatten(2).transpose(1, 2)
        return x

class Embeddings(nn.Module):
    """
    Combine the patch embeddings with the class token and position embeddings.
    """

    def __init__(self, config):
        super().__init__()
        self.config = config
        self.patch_embeddings = PatchEmbeddings(config)
        self.cls_token = nn.Parameter(torch.randn(1, 1, config['hidden_size']))
        self.position_embeddings = nn.Parameter(torch.randn(1, self.patch_embeddings.num_patches + 1, config['hidden_size']))
        self.dropout = nn.Dropout(config['hidden_dropout_prob'])

    def forward(self, x):
        x = self.patch_embeddings(x)
        batch_size, _, _ = x.size()
        cls_tokens = self.cls_token.expand(batch_size, -1, -1)
        x = torch.cat((cls_tokens, x), dim=1)
        x = x + self.position_embeddings
        x = self.dropout(x)
        return x


INIT_ARGS = {
    'config': {
        'image_size': 8,
        'patch_size': 2,
        'num_channels': 3,
        'hidden_size': 4,
        'hidden_dropout_prob': 0.1
    }
}

ARGS = {
    'x': torch.randn(2, 3, 8, 8)
}
Setup block drafted by
a language model, class construct-then-call prompt, model not recorded
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 (2, 17, 4) — shape (2, 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: torch and numpy seeded to 0 by the harness immediately before the class was constructed from INIT_ARGS (fixture_check.py)
Encoder Ran
ran on a synthesized input · constructed an object; no result was computed
nachiket273/VisTrans/vistrans/models/vit.py
code served (permissive licence) · get_code("f8b85038ed9400ec")
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, Encoder: 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 functools import partial
from copy import deepcopy

torch.manual_seed(0)

# Create a minimal encoder_layer that satisfies the usage in Encoder
class MinimalEncoderLayer(nn.Module):
    def __init__(self, embed_dim):
        super().__init__()
        self.embed_dim = embed_dim
        self.linear = nn.Linear(embed_dim, embed_dim)
    
    def forward(self, x):
        return self.linear(x)

# Construct the arguments
embed_dim = 4
num_layers = 2

encoder_layer = MinimalEncoderLayer(embed_dim=embed_dim)
norm_layer = partial(nn.LayerNorm, eps=1e-06)

ARGS = {
    'encoder_layer': encoder_layer,
    'num_layers': num_layers,
    'norm_layer': norm_layer,
}
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 Encoder — 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 Encoder 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
Encoder Ran
ran on a synthesized input · constructed an object; no result was computed
sangHa0411/VIT/model.py
pointer only (licence: NONE) · get_code("663995617b3eb222")
How it ran

The body of this sample is withheld: GitHub detected no licence in this paper's repository, sangHa0411/VIT 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.

Encoder Ran
ran on a synthesized input · constructed an object; no result was computed
facebookresearch/ClassyVision/classy_vision/models/vision_transformer.py
code served (permissive licence) · get_code("cd17efa4361858a7")
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, Encoder: 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 = {
    'seq_length': 8,
    'num_layers': 2,
    'num_heads': 2,
    'hidden_dim': 4,
    'mlp_dim': 8,
    'dropout_rate': 0.1,
    'attention_dropout_rate': 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 Encoder — 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 Encoder 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
Encoder Ran
ran on a synthesized input · constructed an object; no result was computed
mtancak/PyTorch-ViT-Visual-Transformer/model.py
pointer only (licence: NONE) · get_code("5ab5e4d0ab686651")
How it ran

The body of this sample is withheld: GitHub detected no licence in this paper's repository, mtancak/PyTorch-ViT-Visual-Transformer 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.

Encoder Ran
ran on a synthesized input · constructed an object; no result was computed
asyml/vision-transformer-pytorch/src/model.py
code served (permissive licence) · get_code("87a7da8255824960")
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, Encoder: 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 dict with all parameters for Encoder.__init__
ARGS = {
    "num_patches": 16,
    "emb_dim": 8,
    "mlp_dim": 32,
    "num_layers": 2,
    "num_heads": 2,
    "dropout_rate": 0.1,
    "attn_dropout_rate": 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 Encoder — 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 Encoder 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
Encoder Ran
ran on a synthesized input
s-chh/pytorch-scratch-vision-transformer-vit/model.py
code served (permissive licence) · get_code("92f27ff91aeb4722")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, class construct-then-call prompt, model not recorded) and returned Tensor, ndim 3, dtype family float; no output shape is stated. The image it ran in was not recorded. If your copy returns the same type and ndim 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

INIT_ARGS = {
    'embed_dim': 4,
    'n_attention_heads': 2,
    'forward_mul': 2,
    'dropout': 0.0
}

ARGS = {
    'x': torch.randn(2, 3, 4)
}
Setup block drafted by
a language model, class construct-then-call prompt, model not recorded
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 — no output shape is stated: observe_signature.py observed this class with its constructor sizes canonicalised where it could, which the node does not record, so its shape is not stated as this setup block's
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: torch and numpy seeded to 0 by the harness immediately before the class was constructed from INIT_ARGS (fixture_check.py)
EncoderBlock Ran
ran on a synthesized input · constructed an object; no result was computed
pytorch/vision/torchvision/models/vision_transformer.py
code served (permissive licence) · get_code("98bf127d64416382")
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, EncoderBlock: 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 functools import partial

torch.manual_seed(0)

ARGS = {
    "num_heads": 4,
    "hidden_dim": 8,
    "mlp_dim": 16,
    "dropout": 0.1,
    "attention_dropout": 0.1,
    "norm_layer": partial(nn.LayerNorm, eps=1e-06),
}
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 EncoderBlock — 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 EncoderBlock 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

Showing the first 60. An agent gets every one from get_harvested_code_for_paper("2010.11929").

Also present in other papers' code

Of 419 samples lifted from this paper's linked repositories, 419 carry a function identity and 0 do not. Of the 405 distinct functions with an identity, 71 are also present in other papers whose code we hold (26 with at least one paper dated earlier, 3 the same month, 57 later) and 334 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
brick of this paper's assembly: helper
224 other papers
2 dated earlier, 221 later, 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
2012.12877 (2020-12)
Training data-efficient image transformers & distillation through attention
and 221 more not named here
swish
brick of this paper's assembly: helper
206 other papers
47 dated earlier, 5 the same month, 153 later, 1 same year, order not determinable · 44 only as an assembly brick
1408.5882 (2014-08)
Convolutional Neural Networks for Sentence Classification
1805.12114 (2018-05)
Deep Reinforcement Learning in a Handful of Trials using Probabilistic Dynamics Models
1809.01357 (2018-09)
Zero Shot Learning for Code Education: Rubric Sampling with Deep Learning Inference
and 203 more not named here
str2bool 175 other papers
22 dated earlier, 1 the same month, 152 later · 2 only as an assembly brick
1406.6247 (2014-06)
Recurrent Models of Visual Attention
1603.09382 (2016-03)
Deep Networks with Stochastic Depth
1710.10196 (2017-10)
Progressive Growing of GANs for Improved Quality, Stability, and Variation
and 172 more not named here
pair
brick of this paper's assembly: helper
90 other papers
1 dated earlier, 88 later, 1 undated · 8 only as an assembly brick
2004.13649 (2020-04)
Image Augmentation Is All You Need: Regularizing Deep Reinforcement Learning from Pixels
2103.15691 (2021-03)
ViViT: A Video Vision Transformer
2103.17239 (2021-03)
Going deeper with Image Transformers
and 87 more not named here
clones
brick of this paper's assembly: helper
79 other papers
25 dated earlier, 1 the same month, 53 later · 11 only as an assembly brick
1411.4555 (2014-11)
Show and Tell: A Neural Image Caption Generator
1612.00563 (2016-12)
Self-critical Sequence Training for Image Captioning
1706.03762 (2017-06)
Attention Is All You Need
and 76 more not named here
DropPath
brick of this paper's assembly: helper, model
47 other papers
1 dated earlier, 46 later · 33 only as an assembly brick
2003.12039 (2020-03)
RAFT: Recurrent All-Pairs Field Transforms for Optical Flow
2105.14432 (2021-05)
TransMatcher: Deep Image Matching Through Transformers for Generalizable Person Re-identification
2108.10257 (2021-08)
SwinIR: Image Restoration Using Swin Transformer
and 44 more not named here
np2th
brick of this paper's assembly: helper
35 other papers
35 later · 5 only as an assembly brick
2102.04306 (2021-02)
TransUNet: Transformers Make Strong Encoders for Medical Image Segmentation
2103.07976 (2021-03)
TransFG: A Transformer Architecture for Fine-grained Recognition
2103.12091 (2021-03)
Transformer-Based Attention Networks for Continuous Pixel-Wise Prediction
and 32 more not named here
timestep_embedding 29 other papers
1 dated earlier, 28 later · 9 only as an assembly brick
2006.11239 (2020-06)
Denoising Diffusion Probabilistic Models
2103.11161 (2021-03)
MonteFloor: Extending MCTS for Reconstructing Accurate Large-Scale Floor Plans
2209.12152 (2022-09)
All are Worth Words: A ViT Backbone for Diffusion Models
and 26 more not named here
named_apply
brick of this paper's assembly: helper
26 other papers
24 later, 2 undated
2204.07683 (2022-04)
Safe Self-Refinement for Transformer-based Domain Adaptation
2304.07193 (2023-04)
DINOv2: Learning Robust Visual Features without Supervision
2309.16588 (2023-09)
Vision Transformers Need Registers
and 23 more not named here
get_1d_sincos_pos_embed_from_grid
brick of this paper's assembly: helper
25 other papers
25 later · 16 only as an assembly brick
2111.06377 (2021-11)
Masked Autoencoders Are Scalable Vision Learners
2301.01296 (2023-01)
TinyMIM: An Empirical Study of Distilling MIM Pre-trained Models
2303.05675 (2023-03)
HumanBench: Towards General Human-centric Perception with Projector Assisted Pretraining
and 22 more not named here
drop_add_residual_stochastic_depth
brick of this paper's assembly: helper
21 other papers
19 later, 2 undated
2304.07193 (2023-04)
DINOv2: Learning Robust Visual Features without Supervision
2312.02366 (2023-12)
Evaluating General Purpose Vision Foundation Models for Medical Image Analysis: An Experimental Study of DINOv2 on Radiology Benchmarks
2402.03138 (2024-02)
Just Cluster It: An Approach for Exploration in High-Dimensions using Clustering and Pre-Trained Representations
and 18 more not named here
Block
brick of this paper's assembly: model
12 other papers
12 later · 4 only as an assembly brick
2101.11986 (2021-01)
Tokens-to-Token ViT: Training Vision Transformers from Scratch on ImageNet
2103.10455 (2021-03)
3D Human Pose Estimation with Spatial and Temporal Transformers
2104.12099 (2021-04)
Visual Saliency Transformer
and 9 more not named here
_log_api_usage_once
brick of this paper's assembly: helper
8 other papers
4 dated earlier, 4 later · 1 only as an assembly brick
1512.03385 (2015-12)
Deep Residual Learning for Image Recognition
1603.09382 (2016-03)
Deep Networks with Stochastic Depth
1905.11946 (2019-05)
EfficientNet: Rethinking Model Scaling for Convolutional Neural Networks
and 5 more not named here
Attention
brick of this paper's assembly: model
7 other papers
7 later · 5 only as an assembly brick
2301.08243 (2023-01)
Self-Supervised Learning from Images with a Joint-Embedding Predictive Architecture
2306.09347 (2023-06)
Segment Any Point Cloud Sequences by Distilling Vision Foundation Models
2312.12619 (2023-12)
Hierarchical Vision Transformers for Context-Aware Prostate Cancer Grading in Whole Slide Images
and 4 more not named here
unpatchify 6 other papers
6 later · 1 only as an assembly brick
2209.12152 (2022-09)
All are Worth Words: A ViT Backbone for Diffusion Models
2302.10586 (2023-02)
Diffusion Models and Semi-Supervised Learners Benefit Mutually with Few Labels
2310.13545 (2023-10)
ScaleLong: Towards More Stable Training of Diffusion Model via Scaling Network Long Skip Connection
and 3 more not named here
patchify 5 other papers
5 later
2209.12152 (2022-09)
All are Worth Words: A ViT Backbone for Diffusion Models
2302.10586 (2023-02)
Diffusion Models and Semi-Supervised Learners Benefit Mutually with Few Labels
2306.11363 (2023-06)
Masked Diffusion Models Are Fast Distribution Learners
and 2 more not named here
PatchEmbed
brick of this paper's assembly: model
4 other papers
4 later · 3 only as an assembly brick
2012.12877 (2020-12)
Training data-efficient image transformers & distillation through attention
2306.09347 (2023-06)
Segment Any Point Cloud Sequences by Distilling Vision Foundation Models
2503.12035 (2025-03)
MOS: Modeling Object-Scene Associations in Generalized Category Discovery
and 1 more not named here
as_tuple
brick of this paper's assembly: helper
4 other papers
4 later
Yu_PhysFormer_Facial_Video-Based_Physiological_Measurement_With_Temporal_Difference_Transformer_CVPR_2022_paper (2022 (year only))
PhysFormer: Facial Video-based Physiological Measurement with Temporal Difference Transformer
2308.04016 (2023-08)
Hierarchical Visual Primitive Experts for Compositional Zero-Shot Learning
2311.08236 (2023-11)
MeLo: Low-rank Adaptation is Better than Fine-tuning for Medical Image Diagnosis
and 1 more not named here
init_weights_vit_timm
brick of this paper's assembly: helper
4 other papers
4 later · 1 only as an assembly brick
2304.07193 (2023-04)
DINOv2: Learning Robust Visual Features without Supervision
2403.08568 (2024-03)
Consistent Prompting for Rehearsal-Free Continual Learning
2404.00228 (2024-04)
InfLoRA: Interference-Free Low-Rank Adaptation for Continual Learning
and 1 more not named here
Encoder
brick of this paper's assembly: model
3 other papers
3 later
2103.12091 (2021-03)
Transformer-Based Attention Networks for Continuous Pixel-Wise Prediction
2103.15691 (2021-03)
ViViT: A Video Vision Transformer
2203.08243 (2022-03)
Unified Visual Transformer Compression

Shown: the 20 functions present in the most other papers. 51 more shared functions are not listed here.

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-23.

Repositories linked to this paper

More are linked than shown here.

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

Abstract

While the Transformer architecture has become the de-facto standard for natural language processing tasks, its applications to computer vision remain limited. In vision, attention is either applied in conjunction with convolutional networks, or used to replace certain components of convolutional networks while keeping their overall structure in place. We show that this reliance on CNNs is not necessary and a pure transformer applied directly to sequences of image patches can perform very well on image classification tasks. When pre-trained on large amounts of data and transferred to multiple mid-sized or small image recognition benchmarks (ImageNet, CIFAR-100, VTAB, etc.), Vision Transformer (ViT) attains excellent results compared to state-of-the-art convolutional networks while requiring substantially fewer computational resources to train. 1

For agents

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

get_harvested_code_for_paper("2010.11929")
get_code_for_paper("2010.11929")
have("2010.11929")

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

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

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

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

Connect an agent — have() is free.