SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 2111.09886 · 2021

SimMIM: a Simple Framework for Masked Image Modeling

Jianmin Bao, Zheng Zhang, Han Hu, Qi Dai, Yue Cao, Zhenda Xie, Yutong Lin, Zhuliang Yao

arXiv · PDF · Open in the Atlas

Code that ran

9 of 14 samples (functions and classes) lifted from this paper's linked repositories executed on a synthesized input in Syntology's jail (7 of them constructed an object rather than computing a result; 0 honoured the contract we drafted, 0 violated it and 8 have no contract verdict; 1 failure of our instrument; 5 no recorded run), 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/2111.09886.json · badge: /api/ran/2111.09886.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
impiga/plain-detr community
Papers with Code archive
7 ran · 5 no recorded run
microsoft/simmim community
Papers with Code archive
1 ran · 0 no recorded run
Hazqeel09/ellzaf_ml community
Papers with Code archive
1 ran · 0 no recorded run
FunctionStatusWhere it lives
GlobalAttention Ran
ran on a synthesized input · constructed an object; no result was computed
impiga/plain-detr/models/swin_transformer_v2.py
code served (permissive licence) · get_code("b0e55e16e4ab4b04")
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, GlobalAttention: the run constructed the object and did not call it, so no result was computed. The image it ran in was not recorded. The code mentions cuda, and the harness aliases cuda to the CPU for every sample; whether this run needed that is not recorded. If your copy returns the same type on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

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

torch.manual_seed(0)

ARGS = {
    'dim': 4,
    'num_heads': 2,
    'qkv_bias': True,
    'attn_drop': 0.1,
    'proj_drop': 0.1,
    'pretrained_window_size': [0, 0],
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
numpy, timm, torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type GlobalAttention — 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 GlobalAttention 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
LayerNormFP32 Ran
ran on a synthesized input
impiga/plain-detr/models/swin_transformer_v2.py
code served (permissive licence) · get_code("6d0ff69e341e91b6")
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
import torch.nn.functional as F
from torch import Tensor, Size
from typing import Union, List

_shape_t = Union[int, List[int], Size]

class LayerNormFP32(nn.LayerNorm):

    def __init__(self, normalized_shape: _shape_t, eps: float=1e-05, elementwise_affine: bool=True) -> None:
        super(LayerNormFP32, self).__init__(normalized_shape, eps, elementwise_affine)

    def forward(self, input: Tensor) -> Tensor:
        return F.layer_norm(input.float(), self.normalized_shape, self.weight.float(), self.bias.float(), self.eps).type_as(input)


INIT_ARGS = {
    'normalized_shape': 4,
    'eps': 1e-05,
    'elementwise_affine': True
}

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

if __name__ == '__main__':
    layer_norm = LayerNormFP32(**INIT_ARGS)
    output = layer_norm(**ARGS)
    print(f"Output shape: {output.shape}")
    print(f"Output dtype: {output.dtype}")
    print(f"Output:\n{output}")
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)
LinearFP32 Ran
ran on a synthesized input · constructed an object; no result was computed
impiga/plain-detr/models/swin_transformer_v2.py
code served (permissive licence) · get_code("ef982aba178be7dd")
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, LinearFP32: 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 import Tensor

torch.manual_seed(0)

class LinearFP32(nn.Linear):
    def __init__(self, in_features, out_features, bias=True):
        super(LinearFP32, self).__init__(in_features, out_features, bias)

    def forward(self, input: Tensor) -> Tensor:
        import torch.nn.functional as F
        return F.linear(input.float(), self.weight.float(), self.bias.float() if self.bias is not None else None)

ARGS = {
    'in_features': 4,
    'out_features': 3,
    'bias': True
}
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 LinearFP32 — 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 LinearFP32 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
PatchEmbed Ran
ran on a synthesized input · constructed an object; no result was computed
impiga/plain-detr/models/swin_transformer_v2.py
code served (permissive licence) · get_code("804ddd3c6093f073")
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, PatchEmbed: the run constructed the object and did not call it, so no result was computed. The image it ran in was not recorded. If your copy returns the same type on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

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

torch.manual_seed(0)

# Construct a small normalization layer that works with the PatchEmbed forward pass
norm_layer = nn.LayerNorm

ARGS = {
    'patch_size': 4,
    'in_chans': 3,
    'embed_dim': 96,
    'norm_layer': norm_layer,
}
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 PatchEmbed — 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 PatchEmbed 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
PatchMerging Ran
ran on a synthesized input · constructed an object; no result was computed
impiga/plain-detr/models/swin_transformer_v2.py
code served (permissive licence) · get_code("a5518beb9daf7d60")
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, PatchMerging: the run constructed the object and did not call it, so no result was computed. The image it ran in was not recorded. If your copy returns the same type on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import torch
import torch.nn as nn

torch.manual_seed(0)

# Create a minimal norm_layer that works with LayerNorm
norm_layer = nn.LayerNorm

# Create input tensor: (B=2, H*W=12, C=4)
# Using H=3, W=4 to have distinct spatial dimensions
B, H, W, C = 2, 3, 4, 4
x = torch.randn(B, H * W, C)

ARGS = {
    'dim': C,
    '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 PatchMerging — 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 PatchMerging 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
SimMIM Ran
ran on a synthesized input · constructed an object; no result was computed
microsoft/simmim/models/simmim.py
code served (permissive licence) · get_code("fddc32909150f889")
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, SimMIM: the run constructed the object and did not call it, so no result was computed. The image it ran in was not recorded. If your copy returns the same type on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import torch
import torch.nn as nn

torch.manual_seed(0)

# Create a minimal encoder that satisfies the interface
class MinimalEncoder(nn.Module):
    def __init__(self):
        super().__init__()
        self.num_features = 16  # output channels from encoder
        self.in_chans = 3  # input channels (RGB)
        self.patch_size = 4  # patch size for spatial downsampling
        # Simple conv layer to produce output with num_features channels
        self.conv = nn.Conv2d(3, self.num_features, kernel_size=3, padding=1)
    
    def forward(self, x, mask):
        # x: (batch, 3, H, W)
        # mask: (batch, H//patch_size, W//patch_size)
        # output: (batch, num_features, H//patch_size, W//patch_size)
        z = self.conv(x)
        # Downsample to match mask spatial dims (simulate patch embedding)
        z = nn.functional.adaptive_avg_pool2d(z, (z.size(2)//self.patch_size, z.size(3)//self.patch_size))
        return z
    
    def no_weight_decay(self):
        return set()
    
    def no_weight_decay_keywords(self):
        return set()

# Create encoder instance
encoder = MinimalEncoder()
encoder_stride = 4

# Create input tensors
batch_size = 2
in_chans = 3
height = 16  # spatial height
width = 16  # spatial width
mask_h = height // encoder_stride
mask_w = width // encoder_stride

# Input image tensor (batch_size, channels, height, width)
x = torch.randn(batch_size, in_chans, height, width)

# Mask tensor (batch_size, mask_h, mask_w) - binary mask for which patches to reconstruct
mask = torch.randint(0, 2, (batch_size, mask_h, mask_w)).float()

ARGS = {
    'encoder': encoder,
    'encoder_stride': encoder_stride,
}
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 SimMIM — 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 SimMIM 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
SimMIM Ran
ran on a synthesized input · constructed an object; no result was computed
Hazqeel09/ellzaf_ml/ellzaf_ml/models/simmim.py
code served (permissive licence) · get_code("9ce7427c4503c13e")
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, SimMIM: the run constructed the object and did not call it, so no result was computed. The image it ran in was not recorded. If your copy returns the same type on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import torch
import torch.nn as nn

torch.manual_seed(0)

# Create a minimal encoder that satisfies the SimMIM requirements
class MinimalEncoder(nn.Module):
    def __init__(self):
        super().__init__()
        self.in_chans = 3
        self.patch_size = 16
        self.num_features = 8
        self.conv = nn.Conv2d(3, self.num_features, kernel_size=1)
    
    def forward(self, x, mask):
        # x shape: (batch, channels, height, width)
        # mask shape: (batch, num_patches_h, num_patches_w)
        # Return encoded features: (batch, num_features, height//patch_size, width//patch_size)
        return self.conv(x)
    
    def no_weight_decay(self):
        return set()
    
    def no_weight_decay_keywords(self):
        return set()

# Create encoder instance
encoder = MinimalEncoder()

# encoder_stride is used in the decoder for PixelShuffle
# It should match the upsampling factor
encoder_stride = 16

ARGS = {
    "encoder": encoder,
    "encoder_stride": encoder_stride,
}
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 SimMIM — 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 SimMIM 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
WindowAttention Ran
ran on a synthesized input · constructed an object; no result was computed
impiga/plain-detr/models/swin_transformer_v2.py
code served (permissive licence) · get_code("5eec152e243ad651")
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, WindowAttention: the run constructed the object and did not call it, so no result was computed. The image it ran in was not recorded. The code mentions cuda, and the harness aliases cuda to the CPU for every sample; whether this run needed that is not recorded. If your copy returns the same type 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 numpy as np

torch.manual_seed(0)

ARGS = {
    'dim': 64,
    'window_size': (7, 7),
    'num_heads': 8,
    'qkv_bias': True,
    'attn_drop': 0.1,
    'proj_drop': 0.1,
    'pretrained_window_size': [0, 0],
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
numpy, torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type WindowAttention — 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 WindowAttention 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
custom_normalize Ran
ran; our contract draft was wrong, not the code
impiga/plain-detr/models/swin_transformer_v2.py
code served (permissive licence) · get_code("4e2c8a04e709451b")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned Tensor, ndim 2, dtype family float, shape (2, 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

torch.manual_seed(0)

# Create a small input tensor (batch_size=2, features=4)
input_tensor = torch.randn(2, 4)

# The function uses:
# - input.norm(p, dim, keepdim=True) - needs a tensor
# - input / (denom + eps) - standard division
# - torch.div(input, denom + eps, out=out) - needs out to be a tensor or None
# Create an output tensor with the same shape as input
out_tensor = torch.zeros_like(input_tensor)

ARGS = {
    "input": input_tensor,
    "p": 2,
    "dim": 1,
    "eps": 1e-12,
    "out": out_tensor
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type Tensor, ndim 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
BasicLayer Not yet run
unverified (harvested, no recorded run)
impiga/plain-detr/models/swin_transformer_v2.py
code served (permissive licence) · get_code("590e8cc54154effc")
How it ran

no invocation recorded.

SwinTransformerBlock Not yet run
unverified (harvested, no recorded run)
impiga/plain-detr/models/swin_transformer_v2.py
code served (permissive licence) · get_code("bcf8d3634776d004")
How it ran

no invocation recorded.

SwinTransformerGlobalBlock Not yet run
unverified (harvested, no recorded run)
impiga/plain-detr/models/swin_transformer_v2.py
code served (permissive licence) · get_code("deaa894233f1e3da")
How it ran

no invocation recorded.

SwinTransformerV2 Not yet run
unverified (harvested, no recorded run)
impiga/plain-detr/models/swin_transformer_v2.py
code served (permissive licence) · get_code("d346a9e5a95c653f")
How it ran

no invocation recorded.

load_swinv2_checkpoint Not yet run
unverified (harvested, no recorded run)
impiga/plain-detr/models/swin_transformer_v2.py
code served (permissive licence) · get_code("6feca106254274b3")
How it ran

no invocation recorded.

Also present in other papers' code

Of 14 samples lifted from this paper's linked repositories, 14 carry a function identity and 0 do not. Of the 14 distinct functions with an identity, 4 are also present in other papers whose code we hold (1 with at least one paper dated earlier, 0 the same month, 4 later) and 10 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
PatchEmbed
brick of this paper's assembly: model
6 other papers
2 dated earlier, 4 later · 3 only as an assembly brick
2103.14030 (2021-03)
Swin Transformer: Hierarchical Vision Transformer using Shifted Windows
2104.06399 (2021-04)
Co-Scale Conv-Attentional Image Transformers
2208.03792 (2022-08)
Domain Randomization-Enhanced Depth Simulation and Restoration for Perceiving and Grasping Specular and Transparent Objects
and 3 more not named here
LayerNormFP32
brick of this paper's assembly: helper
1 other paper
1 later · 1 only as an assembly brick
2310.02642 (2023-10)
GET: Group Event Transformer for Event-Based Vision
LinearFP32
brick of this paper's assembly: helper
1 other paper
1 later · 1 only as an assembly brick
2310.02642 (2023-10)
GET: Group Event Transformer for Event-Based Vision
custom_normalize
brick of this paper's assembly: helper
1 other paper
1 later · 1 only as an assembly brick
2310.02642 (2023-10)
GET: Group Event Transformer for Event-Based Vision

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

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

Abstract

This paper presents SimMIM, a simple framework for masked image modeling. We have simplified recently proposed relevant approaches, without the need for special designs, such as block-wise masking and tokenization via discrete VAE or clustering. To investigate what makes a masked image modeling task learn good representations, we systematically study the major components in our framework, and find that the simple designs of each component have revealed very strong representation learning performance: 1) random masking of the input image with a moderately large masked patch size (e.g., 32) makes a powerful pre-text task; 2) predicting RGB values of raw pixels by direct regression performs no worse than the patch classification approaches with complex designs; 3) the prediction head can be as light as a linear layer, with no worse performance than heavier ones. Using ViT-B, our approach achieves 83.8% top-1 fine-tuning accuracy on ImageNet-1K by pre-training also on this dataset, surpassing previous best approach by +0.6%. When applied to a larger model with about 650 million parameters, SwinV2-H, it achieves 87.1% top-1 accuracy on ImageNet-1K using only ImageNet-1K data. We also leverage this approach to address the data-hungry issue faced by large-scale model training, that a 3B model (SwinV2-G) is successfully trained to achieve state-of-the-art accuracy on four representative vision benchmarks using 40× less labelled data than that in previous practice (JFT-3B). The code is available at https://github.com/microsoft/SimMIM . * Equal. Zhenda, Yutong, Zhuliang are long-term interns at MSRA.

For agents

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

get_harvested_code_for_paper("2111.09886")
get_code_for_paper("2111.09886")
have("2111.09886")

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

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

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

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

Connect an agent — have() is free.