SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 2202.00455 · CVPR · 2022

HCSC: Hierarchical Contrastive Selective Coding

Bingbing Ni, Minghao Xu, Yi Xu, Jiawen Li, Zhenbang Sun, Yuanfan Guo, Xuanyu Zhu

arXiv · PDF · Open in the Atlas

Code that ran

4 of 10 samples (functions and classes) lifted from this paper's linked repositories executed on a synthesized input in Syntology's jail (1 of them constructed an object rather than computing a result; 0 honoured the contract we drafted, 0 violated it and 4 have no contract verdict; 0 failures of our instrument; 6 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/2202.00455.json · badge: /api/ran/2202.00455.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
hirl-team/hcsc canonical (classifier label)
classifier basis not recorded on the link
3 ran · 6 no recorded run
gyfastas/HCSC community
Papers with Code archive
1 ran · 0 no recorded run
FunctionStatusWhere it lives
HCSC Ran
ran on a synthesized input · constructed an object; no result was computed
gyfastas/HCSC/hcsc/hcsc.py
code served (permissive licence) · get_code("9010c3dc1ba6a609")
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, HCSC: 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

torch.manual_seed(0)

class SimpleEncoder(nn.Module):
    """Minimal encoder that satisfies how HCSC uses it."""
    def __init__(self, num_classes=128):
        super().__init__()
        self.conv = nn.Conv2d(3, 8, kernel_size=3, padding=1)
        self.pool = nn.AdaptiveAvgPool2d((1, 1))
        self.fc = nn.Linear(8, num_classes)
    
    def forward(self, x):
        x = self.conv(x)
        x = self.pool(x)
        x = x.view(x.size(0), -1)
        x = self.fc(x)
        return x

class SimpleLogger:
    """Minimal logger stand-in."""
    def __init__(self):
        self.data = {}
    
    def log(self, key, value):
        self.data[key] = value

ARGS = {
    'base_encoder': SimpleEncoder,
    'dim': 128,
    'queue_length': 256,
    'm': 0.999,
    'T': 0.2,
    'mlp': True,
    'multi_crop': False,
    'instance_selection': True,
    'proto_selection': True,
    'selection_on_local': True,
    'logger': SimpleLogger(),
}
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 HCSC — 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 HCSC 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
build_augmentation Ran
ran on a synthesized input
hirl-team/hcsc/hcsc/loader.py
code served (permissive licence) · get_code("eab4f42136dd4c6e")
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 tuple, ndim 1, 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 random
from torchvision import transforms

torch.manual_seed(0)
random.seed(0)

class Args:
    def __init__(self, multi_crop=False, aug_plus=True, size_crops=None, nmb_crops=None, 
                 min_scale_crops=None, max_scale_crops=None):
        self.multi_crop = multi_crop
        self.aug_plus = aug_plus
        self.size_crops = size_crops if size_crops is not None else [224, 96]
        self.nmb_crops = nmb_crops if nmb_crops is not None else [1, 2]
        self.min_scale_crops = min_scale_crops if min_scale_crops is not None else [0.14, 0.05]
        self.max_scale_crops = max_scale_crops if max_scale_crops is not None else [1.0, 0.4]

ARGS = {
    "args": Args(
        multi_crop=False,
        aug_plus=True,
        size_crops=[224, 96],
        nmb_crops=[1, 2],
        min_scale_crops=[0.14, 0.05],
        max_scale_crops=[1.0, 0.4]
    )
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
PIL, torch, torchvision — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type tuple, ndim 1, dtype family float — a tuple output has no array shape of its own; none is stated
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
read_object_labels Ran
ran on a synthesized input
hirl-team/hcsc/eval_cls_voc.py
code served (permissive licence) · get_code("f8b64824ae02e7c2")
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 dict. 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 os
import os.path
import tempfile
import numpy as np

# Create a temporary directory structure to simulate VOC dataset
temp_dir = tempfile.mkdtemp()
voc_dir = os.path.join(temp_dir, 'VOCdevkit', 'VOC2012', 'ImageSets', 'Main')
os.makedirs(voc_dir, exist_ok=True)

# Create dummy label files for each object category
object_categories = ['aeroplane', 'bicycle', 'bird', 'boat', 'bottle', 'bus', 'car', 'cat', 'chair', 'cow', 'diningtable', 'dog', 'horse', 'motorbike', 'person', 'pottedplant', 'sheep', 'sofa', 'train', 'tvmonitor']

# Create sample label files
for category in object_categories:
    file_path = os.path.join(voc_dir, category + '_trainval.txt')
    with open(file_path, 'w') as f:
        f.write('image_001 1\n')
        f.write('image_002 -1\n')
        f.write('image_003 0\n')

ARGS = {
    'root': temp_dir,
    'dataset': 'VOC2012',
    'set': 'trainval'
}
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 dict — a dict output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a dict 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
read_object_labels_csv Ran
ran on a synthesized input
hirl-team/hcsc/eval_cls_voc.py
code served (permissive licence) · get_code("7a4a381127a3d05b")
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 list. 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 csv
import numpy as np
import torch
import tempfile
import os

torch.manual_seed(0)

# Create a temporary CSV file with test data
temp_dir = tempfile.mkdtemp()
csv_file = os.path.join(temp_dir, "test_labels.csv")

with open(csv_file, 'w', newline='') as f:
    writer = csv.writer(f)
    # Write header
    writer.writerow(['image_name', 'label1', 'label2', 'label3'])
    # Write data rows
    writer.writerow(['image1.jpg', '0.5', '0.2', '0.8'])
    writer.writerow(['image2.jpg', '0.1', '0.9', '0.3'])

ARGS = {
    'file': csv_file,
    'header': True
}
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 list — a list 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: none by the harness; any seed is in the setup block
build_optimizer Not yet run
unverified (harvested, no recorded run)
hirl-team/hcsc/pretrain.py
code served (permissive licence) · get_code("65e7ca9c4ca143e3")
How it ran

no invocation recorded.

cifar10 Not yet run
unverified (harvested, no recorded run)
hirl-team/hcsc/hcsc/loader.py
code served (permissive licence) · get_code("361ad75f42c5ed05")
How it ran

no invocation recorded.

cifar100 Not yet run
unverified (harvested, no recorded run)
hirl-team/hcsc/hcsc/loader.py
code served (permissive licence) · get_code("4af58a90cc3abb60")
How it ran

no invocation recorded.

concat_all_gather Not yet run
unverified (harvested, no recorded run)
hirl-team/hcsc/hcsc/hcsc.py
code served (permissive licence) · get_code("73cecca9f3575f09")
How it ran

no invocation recorded.

knn_classifier Not yet run
unverified (harvested, no recorded run)
hirl-team/hcsc/eval_knn.py
code served (permissive licence) · get_code("661c1e5b701aeb47")
How it ran

no invocation recorded.

read_image_label Not yet run
unverified (harvested, no recorded run)
hirl-team/hcsc/eval_cls_voc.py
code served (permissive licence) · get_code("10a11520a355ee66")
How it ran

no invocation recorded.

Also present in other papers' code

Of 10 samples lifted from this paper's linked repositories, 10 carry a function identity and 0 do not. Of the 10 distinct functions with an identity, 2 are also present in other papers whose code we hold (1 with at least one paper dated earlier, 1 the same month, 2 later) and 8 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
concat_all_gather
brick of this paper's assembly: helper
138 other papers
36 dated earlier, 3 the same month, 97 later, 2 same year, order not determinable · 33 only as an assembly brick
1710.09412 (2017-10)
mixup: BEYOND EMPIRICAL RISK MINIMIZATION
1905.04899 (2019-05)
CutMix: Regularization Strategy to Train Strong Classifiers with Localizable Features
1905.12794 (2019-05)
Fashion IQ: A New Dataset Towards Retrieving Images by Natural Language Feedback
and 135 more not named here
knn_classifier 1 other paper
1 later
2303.06670 (2023-03)
Extending global-local view alignment for self-supervised learning with remote sensing imagery

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

Hierarchical semantic structures naturally exist in an image dataset, in which several semantically relevant image clusters can be further integrated into a larger cluster with coarser-grained semantics. Capturing such structures with image representations can greatly benefit the semantic understanding on various downstream tasks. Existing contrastive representation learning methods lack such an important model capability. In addition, the negative pairs used in these methods are not guaranteed to be semantically distinct, which could further hamper the structural correctness of learned image representations. To tackle these limitations, we propose a novel contrastive learning framework called Hierarchical Contrastive Selective Coding (HCSC). In this framework, a set of hierarchical prototypes are constructed and also dynamically updated to represent the hierarchical semantic structures underlying the data in the latent space. To make image representations better fit such semantic structures, we employ and further improve conventional instance-wise and prototypical contrastive learning via an elaborate pair selection scheme. This scheme seeks to select more diverse positive pairs with similar semantics and more precise negative pairs with truly distinct semantics. On extensive downstream tasks, we verify the state-of-the-art performance of HCSC and also the effectiveness of major model components. We are continually building a comprehensive model zoo (see supplementary material). Our source code and model weights are available at https://github.com/gyfastas/HCSC.

For agents

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

get_harvested_code_for_paper("2202.00455")
get_code_for_paper("2202.00455")
have("2202.00455")

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

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

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

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

Connect an agent — have() is free.