SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 2304.05919 · CVPR · 2023

Hard Patches Mining for Masked Image Modeling

Jin Xie, Zhaoxiang Zhang, Haochen Wang, Junsong Fan, Yuxi Wang, Kaiyou Song

arXiv · PDF · Open in the Atlas

Code that ran

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

"Ran" means the function executed on a synthesized input and returned a value. It is not a reproduction of the paper's results. This record, dated, as JSON: /api/ran/2304.05919.json · badge: /api/ran/2304.05919.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
haochen-wang409/hpm canonical (classifier label)
classifier basis: census
1 ran · 3 no recorded run
Haochen-Wang409/HPM community
Papers with Code archive
0 ran · 1 no recorded run
FunctionStatusWhere it lives
forward_features_dino Ran
ran on a synthesized input
haochen-wang409/hpm/engine_pretrain.py
code served (permissive licence) · get_code("632d641fabe00eb8")
How it ran

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

torch.manual_seed(0)

# Create a minimal DINO-like model with required attributes and methods
class MinimalPatchEmbed(nn.Module):
    def __init__(self, img_size=8, patch_size=4, in_chans=3, embed_dim=4):
        super().__init__()
        self.patch_size = patch_size
        self.num_patches = (img_size // patch_size) ** 2
        self.proj = nn.Linear(in_chans * patch_size * patch_size, embed_dim)
    
    def forward(self, x):
        # x shape: (B, C, H, W) -> (B, num_patches, embed_dim)
        B = x.shape[0]
        x = x.reshape(B, 3, 2, 4, 2, 4)  # (B, C, H//patch_size, patch_size, W//patch_size, patch_size)
        x = x.permute(0, 2, 4, 1, 3, 5).contiguous()  # (B, H//patch_size, W//patch_size, C, patch_size, patch_size)
        x = x.reshape(B, self.num_patches, -1)  # (B, num_patches, C*patch_size*patch_size)
        x = self.proj(x)
        return x

class MinimalBlock(nn.Module):
    def __init__(self, embed_dim=4):
        super().__init__()
        self.linear = nn.Linear(embed_dim, embed_dim)
    
    def forward(self, x):
        return self.linear(x)

class MinimalDINOModel(nn.Module):
    def __init__(self, embed_dim=4, num_blocks=2):
        super().__init__()
        self.patch_embed = MinimalPatchEmbed(img_size=8, patch_size=4, in_chans=3, embed_dim=embed_dim)
        self.cls_token = nn.Parameter(torch.randn(1, 1, embed_dim))
        num_patches = self.patch_embed.num_patches
        self.pos_embed = nn.Parameter(torch.randn(1, num_patches + 1, embed_dim))
        self.pos_drop = nn.Dropout(0.0)
        self.blocks = nn.ModuleList([MinimalBlock(embed_dim) for _ in range(num_blocks)])
        self.norm = nn.LayerNorm(embed_dim)
    
    def forward(self, x):
        return forward_features_dino(self, x)

def forward_features_dino(model, x):
    B = x.shape[0]
    x = model.patch_embed(x)
    cls_tokens = model.cls_token.expand(B, -1, -1)
    x = torch.cat((cls_tokens, x), dim=1)
    x = x + model.pos_embed
    x = model.pos_drop(x)
    for blk in model.blocks:
        x = blk(x)
    x = model.norm(x)
    return x[:, 1:, :]

# Create model and input
model = MinimalDINOModel(embed_dim=4, num_blocks=2)
x = torch.randn(2, 3, 8, 8)  # (batch=2, channels=3, height=8, width=8)

ARGS = {
    "model": model,
    "x": x
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type Tensor, ndim 3, dtype family float, shape (2, 4, 4) — shape (2, 4, 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
MaskedAutoencoderViT Not yet run
unverified (harvested, no recorded run)
Haochen-Wang409/HPM/models_mae_learn_loss.py
code served (permissive licence) · get_code("d88b08a86f1b802d")
How it ran

no invocation recorded.

build_model Not yet run
unverified (harvested, no recorded run)
haochen-wang409/hpm/models_clip.py
code served (permissive licence) · get_code("39e6b23b55f376ea")
How it ran

no invocation recorded.

forward_features Not yet run
unverified (harvested, no recorded run)
haochen-wang409/hpm/engine_pretrain.py
code served (permissive licence) · get_code("f21bce0c57b13edf")
How it ran

no invocation recorded.

knn_classifier Not yet run
unverified (harvested, no recorded run)
haochen-wang409/hpm/main_knn.py
code served (permissive licence) · get_code("ab5c235c1a0730f0")
How it ran

no invocation recorded.

Also present in other papers' code

Of 5 samples lifted from this paper's linked repositories, 5 carry a function identity and 0 do not. Of the 5 distinct functions with an identity, 1 are also present in other papers whose code we hold (1 with at least one paper dated earlier, 0 the same month, 1 later) and 4 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
build_model 53 other papers
7 dated earlier, 46 later
2107.06383 (2021-07)
How Much Can CLIP Benefit Vision-and-Language Tasks?
2210.01115 (2022-10)
LASP: Text-to-Text Optimization for Language-Aware Soft Prompting of Vision & Language Models
2211.09552 (2022-11)
UniFormerV2: Spatiotemporal Learning by Arming Image ViTs with Video UniFormer
and 50 more not named 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-22.

Repositories linked to this paper

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

Abstract

Masked image modeling (MIM) has attracted much research attention due to its promising potential for learning scalable visual representations. In typical approaches, models usually focus on predicting specific contents of masked patches, and their performances are highly related to pre-defined mask strategies. Intuitively, this procedure can be considered as training a student (the model) on solving given problems (predict masked patches). However, we argue that the model should not only focus on solving given problems, but also stand in the shoes of a teacher to produce a more challenging problem by itself. To this end, we propose Hard Patches Mining (HPM), a brand-new framework for MIM pre-training. We observe that the reconstruction loss can naturally be the metric of the difficulty of the pretraining task. Therefore, we introduce an auxiliary loss predictor, predicting patch-wise losses first and deciding where to mask next. It adopts a relative relationship learning strategy to prevent overfitting to exact reconstruction loss values. Experiments under various settings demonstrate the effectiveness of HPM in constructing masked images. Furthermore, we empirically find that solely introducing the loss prediction objective leads to powerful representations, verifying the efficacy of the ability to be aware of where is hard to reconstruct. 1

For agents

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

get_harvested_code_for_paper("2304.05919")
get_code_for_paper("2304.05919")
have("2304.05919")

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

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

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

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

Connect an agent — have() is free.