SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 2009.09687 · AAAI · 2021

Contrastive Clustering

Xi Peng, Joey Zhou, Peng Hu, Zitao Liu, Dezhong Peng, Yunfan Li

arXiv · PDF · Open in the Atlas

Code that ran

7 of 7 samples (functions and classes) lifted from this paper's linked repositories executed on a synthesized input in Syntology's jail (2 of them constructed an object rather than computing a result; 1 honoured the contract we drafted, 0 violated it and 3 have no contract verdict; 3 failures of our instrument; 0 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/2009.09687.json · badge: /api/ran/2009.09687.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
Yunfan-Li/Contrastive-Clustering canonical (classifier label)
classifier basis: census
5 ran · 0 no recorded run
XLearning-SCU/2021-AAAI-CC community
Papers with Code archive
1 ran · 0 no recorded run
hoper-j/contrastive-disentangling community
Papers with Code archive
1 ran · 0 no recorded run
FunctionStatusWhere it lives
InstanceLoss Ran
ran on a synthesized input · constructed an object; no result was computed
XLearning-SCU/2021-AAAI-CC/modules/contrastive_loss.py
code served (permissive licence) · get_code("56840f79645c3849")
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, InstanceLoss: 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)

# Parameters for InstanceLoss
batch_size = 2
temperature = 0.07
device = 'cpu'

# Create arguments dict
ARGS = {
    'batch_size': batch_size,
    'temperature': temperature,
    'device': device
}
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 InstanceLoss — 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 InstanceLoss 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
InstanceLoss Ran
ran on a synthesized input · constructed an object; no result was computed
hoper-j/contrastive-disentangling/loss.py
code served (permissive licence) · get_code("6870e3e8058896be")
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, InstanceLoss: 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)

# Parameters for InstanceLoss
batch_size = 2
temperature = 0.07
device = 'cpu'

# Create sample latent representations
# z1 and z2 should be tensors of shape (batch_size, feature_dim)
feature_dim = 4
z1 = torch.randn(batch_size, feature_dim)
z2 = torch.randn(batch_size, feature_dim)

ARGS = {
    'batch_size': batch_size,
    'temperature': temperature,
    'device': device
}
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 InstanceLoss — 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 InstanceLoss 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
calculate_cost_matrix Ran
ran; our contract draft was wrong, not the code
Yunfan-Li/Contrastive-Clustering/evaluation/evaluation.py
pointer only (licence: MIT); the stored copy get_code serves, from XiaojianDing/2025-NeurIPS-HSACC, is pointer only (licence: NONE) · get_code("f6d031f1affc8b74")
How it ran

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

get_cluster_labels_from_indices Ran
ran, honoured the contract we drafted
Yunfan-Li/Contrastive-Clustering/evaluation/evaluation.py
pointer only (licence: MIT); the stored copy get_code serves, from hhdxwen/pcl, is pointer only (licence: NONE) · get_code("c5807f4f8acc5c0b")
How it ran

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

get_resnet Ran
ran; our contract draft was wrong, not the code
Yunfan-Li/Contrastive-Clustering/modules/resnet.py
code served (permissive licence) · get_code("95c0bf40098a2477")
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 ResNet. 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 torchvision.models.resnet import BasicBlock

torch.manual_seed(0)

ARGS = {
    'name': 'ResNet18'
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
torch, torchvision — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type ResNet — a ResNet output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a ResNet 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
inference Ran
ran on a synthesized input
Yunfan-Li/Contrastive-Clustering/cluster.py
code served (permissive licence) · get_code("5464d6586c9a5abf")
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. 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 numpy as np

torch.manual_seed(0)

# Define a minimal model with forward_cluster method
class MinimalClusterModel(nn.Module):
    def __init__(self):
        super().__init__()
        self.linear = nn.Linear(4, 3)
    
    def forward_cluster(self, x):
        return self.linear(x)

# Create model
model = MinimalClusterModel()

# Create a minimal data loader (list of tuples)
loader = [
    (torch.randn(2, 4), torch.tensor([0, 1])),
    (torch.randn(2, 4), torch.tensor([1, 0])),
    (torch.randn(2, 4), torch.tensor([0, 1])),
]

# Set device to CPU
device = torch.device('cpu')

ARGS = {
    'loader': loader,
    'model': model,
    'device': device,
}
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 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: none by the harness; any seed is in the setup block
yaml_config_hook Ran
ran; our contract draft was wrong, not the code
Yunfan-Li/Contrastive-Clustering/utils/yaml_config_hook.py
pointer only (licence: MIT); the stored copy get_code serves, from hhdxwen/pcl, is pointer only (licence: NONE) · get_code("5f0e459393da7338")
How it ran

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

Also present in other papers' code

Of 7 samples lifted from this paper's linked repositories, 7 carry a function identity and 0 do not. Of the 7 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 3 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
calculate_cost_matrix 9 other papers
1 dated earlier, 8 later
1902.02693 (2019-02)
StampNet: unsupervised multi-class object discovery
2110.07402 (2021-10)
Self-Supervised Learning by Estimating Twin Class Distributions
2301.11045 (2023-01)
Incomplete Multi-view Clustering via Prototype-based Imputation
and 6 more not named here
get_cluster_labels_from_indices 5 other papers
5 later
2110.07402 (2021-10)
Self-Supervised Learning by Estimating Twin Class Distributions
2310.00377 (2023-10)
Mitigating the Effect of Incidental Correlations on Part-based Learning
2310.11989 (2023-10)
Image Clustering with External Guidance
and 2 more not named here
yaml_config_hook 3 other papers
3 later
2112.07173 (2021-12)
On the use of Cortical Magnification and Saccades as Biological Proxies for Data Augmentation
2202.02943 (2022-02)
Learning fair representation with a parametric integral probability metric
2412.13690 (2024-12)
Personalized Clustering via Targeted Representation Learning
get_resnet 1 other paper
1 later
2407.05246 (2024-07)
Deep Online Probability Aggregation Clustering

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

In this paper, we propose an online clustering method called Contrastive Clustering (CC) which explicitly performs the instance-and cluster-level contrastive learning. To be specific, for a given dataset, the positive and negative instance pairs are constructed through data augmentations and then projected into a feature space. Therein, the instance-and cluster-level contrastive learning are respectively conducted in the row and column space by maximizing the similarities of positive pairs while minimizing those of negative ones. Our key observation is that the rows of the feature matrix could be regarded as soft labels of instances, and accordingly the columns could be further regarded as cluster representations. By simultaneously optimizing the instance-and cluster-level contrastive loss, the model jointly learns representations and cluster assignments in an end-to-end manner. Besides, the proposed method could timely compute the cluster assignment for each individual, even when the data is presented in streams. Extensive experimental results show that CC remarkably outperforms 17 competitive clustering methods on six challenging image benchmarks. In particular, CC achieves an NMI of 0.705 (0.431) on the CIFAR-10 (CIFAR-100) dataset, which is an up to 19% (39%) performance improvement compared with the best baseline. The code is available at https://github.com/XLearning-SCU/2021-AAAI-CC.

For agents

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

get_harvested_code_for_paper("2009.09687")
get_code_for_paper("2009.09687")
have("2009.09687")

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

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

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

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

Connect an agent — have() is free.