SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 2004.11362 · 2020

Supervised Contrastive Learning

Yonglong Tian, Dilip Krishnan, Piotr Teterwak, Aaron Sarna, Aaron Maschinot, Chen Wang, Prannay Khosla, Mit Phillip, Isola Mit

arXiv · PDF · Open in the Atlas

Code that ran

17 of 23 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; 2 honoured the contract we drafted, 0 violated it and 10 have no contract verdict; 5 failures of our instrument; 6 no recorded run), measured 2026-11-21; 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/2004.11362.json · badge: /api/ran/2004.11362.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
PaperCodeReview/SupCL-TF community (classifier label)
classifier basis not recorded on the link
6 ran · 1 no recorded run
davidczy/supcon_gamma community (classifier label)
classifier basis not recorded on the link
3 ran · 1 no recorded run
XG293/SupConLoss community (classifier label)
classifier basis not recorded on the link
2 ran · 2 no recorded run
sidtandon2014/fw-shapley community (classifier label)
classifier basis not recorded on the link
2 ran · 1 no recorded run
alexk1704/scclv2 community (classifier label)
classifier basis not recorded on the link
2 ran · 0 no recorded run
raymin0223/self-contrastive-learning reimplementation (classifier label)
classifier basis: classifier_2025
1 ran · 1 no recorded run
Liut2016/ecg-supcontrast reimplementation (classifier label)
classifier basis: classifier_2025
1 ran · 0 no recorded run
FunctionStatusWhere it lives
conv3x3x3 Ran
ran; our contract draft was wrong, not the code
davidczy/supcon_gamma/networks/ThreeDResnet.py
code served (permissive licence) · get_code("c3b215555357b9d1")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Sonnet 4.5, prompt python_fixture_v1) and returned Conv3d. 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)

# The function conv3x3x3 creates a 3D convolution layer
# Parameters:
# - in_planes: number of input channels
# - out_planes: number of output channels  
# - stride: stride for the convolution (default=1)

# We need to provide distinct values for in_planes and out_planes
in_planes = 3
out_planes = 5
stride = 2

ARGS = {
    'in_planes': in_planes,
    'out_planes': out_planes,
    'stride': stride
}
Setup block drafted by
a language model, Claude Sonnet 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 Conv3d — a Conv3d output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a Conv3d 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
create_model Ran
ran on a synthesized input
PaperCodeReview/SupCL-TF/model.py
code served (permissive licence) · get_code("6ea12cd09e4f96c6")
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 Functional. 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
from tensorflow.keras.layers import Dense, Activation, Lambda
from tensorflow.keras.models import Model
import logging

# Create a minimal logger that satisfies the logger.info() call
class MinimalLogger:
    def info(self, msg):
        pass

# Create a minimal args object with all required attributes
class Args:
    def __init__(self):
        self.backbone = 'vgg16'
        self.img_size = 224
        self.classes = 10
        self.loss = 'crossentropy'
        self.snapshot = None

ARGS = {
    'args': Args(),
    'logger': MinimalLogger()
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
tensorflow — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type Functional — a Functional output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a Functional 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
crossentropy Ran
ran on a synthesized input
PaperCodeReview/SupCL-TF/loss.py
code served (permissive licence) · get_code("e42d6851a241a214")
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 function. 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

class ArgsConfig:
    def __init__(self, classes):
        self.classes = classes

# Test case 1: binary classification (classes == 1)
ARGS = {
    "args": ArgsConfig(classes=1)
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
tensorflow — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type function — a function output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a function 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
default_loader Ran
ran; the contract check could not run (RAISES, DEP_MISSING or TIMEOUT)
sidtandon2014/fw-shapley/src/shapley/embedding/custom_loader.py
pointer only (licence: Apache-2.0); the stored copy get_code serves, from NA-HMC/NA-HMC, is pointer only (licence: NONE) · get_code("7bf07d5f59aae36d")
How it ran

The body of this sample is withheld: this paper's link allows the body inline (Apache-2.0), but get_code serves the stored copy, first harvested from NA-HMC/NA-HMC, 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.

downsample_basic_block Ran
ran; our contract draft was wrong, not the code
davidczy/supcon_gamma/networks/ThreeDResnet.py
code served (permissive licence) · get_code("43c0211ff8dbca5f")
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) and returned Tensor, ndim 5, dtype family float, shape (2, 8, 2, 2, 2) as a later run recorded it. 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, 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.functional as F
from torch.autograd import Variable

torch.manual_seed(0)

# Create a small 5D tensor (batch_size=2, channels=4, depth=3, height=3, width=3)
# This matches the expected input for a 3D convolution operation
x = torch.randn(2, 4, 3, 3, 3)

# planes should be greater than the number of input channels (4)
# so that zero padding can be added
planes = 8

# stride for the pooling operation
stride = 2

ARGS = {
    "x": x,
    "planes": planes,
    "stride": stride
}
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 5, dtype family float, shape (2, 8, 2, 2, 2) — shape (2, 8, 2, 2, 2) 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
fetch_dataset Ran
ran on a synthesized input
PaperCodeReview/SupCL-TF/dataloader.py
code served (permissive licence) · get_code("104ecf80bfd973ca")
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 _TensorDataset. 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 tempfile
import os

# Create a temporary file to use as the path parameter
temp_dir = tempfile.mkdtemp()
temp_file = os.path.join(temp_dir, "test.txt")

# Write some test data to the temporary file
with open(temp_file, "w") as f:
    f.write("test data content")

# Define the arguments
ARGS = {
    "path": temp_file,
    "y": tf.constant(42, dtype=tf.int32)
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
tensorflow — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type _TensorDataset — a _TensorDataset output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a _TensorDataset 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
get_fine_tuning_parameters Ran
ran on a synthesized input
davidczy/supcon_gamma/networks/ThreeDResnet.py
code served (permissive licence) · get_code("49df9db56daeba4a")
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, 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 torch.nn as nn

torch.manual_seed(0)

class SimpleModel(nn.Module):
    def __init__(self):
        super().__init__()
        self.encoder_layer1 = nn.Linear(4, 3)
        self.encoder_layer2 = nn.Linear(3, 2)
        self.decoder_layer1 = nn.Linear(2, 3)
        self.classifier = nn.Linear(3, 2)
    
    def forward(self, x):
        return x

model = SimpleModel()

ARGS = {
    'model': model,
    'ft_prefixes': 'encoder,classifier'
}
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 list, ndim 1, dtype family float — a list 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
get_logger Ran
ran on a synthesized input
PaperCodeReview/SupCL-TF/common.py
code served (permissive licence) · get_code("e9cdcc13fe49820c")
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 Logger. 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 sys
import logging

# The function get_logger takes a single parameter: name (a string)
# It uses this name to create a logger via logging.getLogger(name)
# No complex objects needed - just a simple string

ARGS = {
    "name": "test_logger"
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
none outside the standard library — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type Logger — a Logger output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a Logger 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
obtain_contrastive_loss Ran
ran; the contract check could not run (RAISES, DEP_MISSING or TIMEOUT)
Liut2016/ecg-supcontrast/losses.py
code served (permissive licence) · get_code("909920018e1f3cef")
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) and returned Tensor, ndim 0, dtype family float, shape () 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 numpy as np

torch.manual_seed(0)

# Create latent embeddings: (batch_size=2, hidden_dim=4, num_views=3)
latent_embeddings = torch.randn(2, 4, 3, dtype=torch.float32)

# Create patient IDs list
pids = ['patient_1', 'patient_2']

# Trial type
trial = 'CMC'

ARGS = {
    'latent_embeddings': latent_embeddings,
    'pids': pids,
    'trial': trial
}
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 0, dtype family float, shape () — shape () 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
pil_loader Ran
ran, honoured the contract we drafted
sidtandon2014/fw-shapley/src/shapley/embedding/custom_loader.py
code served (permissive licence) · get_code("f321f54723433661")
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) and returned Image. 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 numpy as np
from PIL import Image
import io
import os
import tempfile

# Create a temporary directory for test files
temp_dir = tempfile.mkdtemp()

# Create a simple RGB image and save it to a temporary file
img = Image.new('RGB', (10, 10), color=(73, 109, 137))
test_image_path = os.path.join(temp_dir, 'test_image.jpg')
img.save(test_image_path)

ARGS = {
    'path': test_image_path
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1
Imports
PIL, numpy, torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type Image — a Image output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a Image output the recorded ndim 3 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
read_img Ran
ran on a synthesized input
alexk1704/scclv2/src/cl_replay/api/utils/convert_ds.py
code served (permissive licence) · get_code("1fd4a495ba449048")
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 ndarray, ndim 4, dtype family int, shape (2, 28, 28, 1) 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 gzip
import struct
import numpy as np
import io

# Create a minimal valid gzip file containing MNIST-like image data
def create_test_gzip_file():
    # Create in-memory buffer
    buffer = io.BytesIO()
    
    with gzip.GzipFile(fileobj=buffer, mode='wb') as f:
        # Write header: magic_no, num_images, rows, cols
        magic_no = 2051  # Standard MNIST magic number for images
        num_images = 2
        rows = 28
        cols = 28
        
        header = struct.pack('>IIII', magic_no, num_images, rows, cols)
        f.write(header)
        
        # Write image data: 2 images of 28x28 pixels
        image_data = np.random.randint(0, 256, (num_images, 28, 28), dtype=np.uint8)
        f.write(image_data.tobytes())
    
    buffer.seek(0)
    return buffer

# Create the test file
test_buffer = create_test_gzip_file()
test_file_path = "/tmp/test_images.gz"

# Write buffer to actual file path for gzip.open to read
with open(test_file_path, 'wb') as f:
    f.write(test_buffer.getvalue())

ARGS = {
    'file': test_file_path
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
numpy — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type ndarray, ndim 4, dtype family int, shape (2, 28, 28, 1) — shape (2, 28, 28, 1) 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
read_labels Ran
ran on a synthesized input
alexk1704/scclv2/src/cl_replay/api/utils/convert_ds.py
code served (permissive licence) · get_code("f4731b89be918d6f")
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 ndarray, ndim 1, dtype family int, shape (10,) 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 gzip
import struct
import numpy as np
import tempfile
import os

# Create a temporary gzip file with valid MNIST-like label data
temp_dir = tempfile.mkdtemp()
temp_file = os.path.join(temp_dir, "labels.gz")

# Write a valid gzip file with magic number and labels
with gzip.open(temp_file, 'wb') as f:
    magic_no = 2049  # MNIST magic number for labels
    num_labels = 10
    f.write(struct.pack('>II', magic_no, num_labels))
    # Write 10 label bytes
    labels_data = np.array([0, 1, 2, 3, 4, 5, 6, 7, 8, 9], dtype=np.uint8)
    f.write(labels_data.tobytes())

ARGS = {
    "file": temp_file
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
numpy — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type ndarray, ndim 1, dtype family int, shape (10,) — shape (10,) 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
set_dataset Ran
ran on a synthesized input
PaperCodeReview/SupCL-TF/dataloader.py
code served (permissive licence) · get_code("221d06a1b512b025")
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 os
import tempfile
import pandas as pd
import numpy as np

# Create a temporary directory and CSV files for testing
temp_dir = tempfile.mkdtemp()

# Create sample training and validation CSV files
train_data = pd.DataFrame({
    'col1': [1, 2, 3],
    'col2': ['a', 'b', 'c'],
    'col3': [1.5, 2.5, 3.5]
})
val_data = pd.DataFrame({
    'col1': [4, 5],
    'col2': ['d', 'e'],
    'col3': [4.5, 5.5]
})

dataset_name = 'test_dataset'
train_data.to_csv(os.path.join(temp_dir, f'{dataset_name}_trainset.csv'), index=False)
val_data.to_csv(os.path.join(temp_dir, f'{dataset_name}_valset.csv'), index=False)

# Create a simple args class
class Args:
    def __init__(self, data_path, dataset):
        self.data_path = data_path
        self.dataset = dataset

args_instance = Args(data_path=temp_dir, dataset=dataset_name)

ARGS = {
    'args': args_instance
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
numpy, pandas — 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
set_optimizer Ran
ran; our contract draft was wrong, not the code
XG293/SupConLoss/util.py
pointer only (licence: BSD-2-Clause); the stored copy get_code serves, from deeplearning-wisc/haloscope, is pointer only (licence: NONE) · get_code("a44a1925c2c778ba")
How it ran

The body of this sample is withheld: this paper's link allows the body inline (BSD-2-Clause), but get_code serves the stored copy, first harvested from deeplearning-wisc/haloscope, 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.

supervised_contrastive Ran
ran on a synthesized input
PaperCodeReview/SupCL-TF/loss.py
code served (permissive licence) · get_code("852634a603bdd4fa")
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 function. 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

class Args:
    def __init__(self):
        self.temperature = 0.07

def create_setup():
    args = Args()
    batch_size_per_replica = 2
    
    return args, batch_size_per_replica

args, batch_size_per_replica = create_setup()

ARGS = {
    "args": args,
    "batch_size_per_replica": batch_size_per_replica
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
tensorflow — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type function — a function output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a function 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
train Ran
ran, honoured the contract we drafted
raymin0223/self-contrastive-learning/main_represent.py
code served (permissive licence) · get_code("d8660dac176225e1")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Sonnet 4.5, prompt python_fixture_v1) and returned float, ndim 0, dtype family float; no output shape is stated. 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 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.optim as optim
from collections import namedtuple

torch.manual_seed(0)

# Stand-in for AverageMeter
class AverageMeter:
    def __init__(self):
        self.val = 0
        self.avg = 0
        self.sum = 0
        self.count = 0
    
    def update(self, val, n=1):
        self.val = val
        self.sum += val * n
        self.count += n
        self.avg = self.sum / self.count

# Stand-in for warmup_learning_rate
def warmup_learning_rate(opt, epoch, idx, length, optimizer):
    pass

# Make warmup_learning_rate available in the function's scope
import sys
sys.modules[__name__].warmup_learning_rate = warmup_learning_rate
sys.modules[__name__].AverageMeter = AverageMeter

# Simple model that returns features in the expected format
class SimpleModel(nn.Module):
    def __init__(self, opt):
        super().__init__()
        self.opt = opt
        self.fc = nn.Linear(3, 8)
        
    def forward(self, x):
        # x shape: (batch, channels, height, width) or (2*batch, ...) if multiview
        batch_size = x.shape[0]
        x_flat = x.view(batch_size, -1)
        features = self.fc(x_flat)
        
        if self.opt.method == 'Con':
            # Return tuple where [1] contains concatenated features
            return (None, features)
        elif self.opt.method == 'SupCon':
            if self.opt.multiview:
                # Return tuple where [1] contains concatenated features
                return (None, features)
            else:
                # Return tuple where [1] contains features
                return (None, features)
        elif self.opt.method == 'SelfCon':
            if not self.opt.multiview:
                # f1 is a list of features, f2 is a single feature tensor
                bsz = batch_size
                f1 = [features[:bsz//2], features[bsz//2:]]
                f2 = features
                return (f1, f2)
            else:
                # f1 is a list of features, f2 is concatenated features
                bsz = batch_size // 2
                f1 = [features[:bsz], features[bsz:]]
                f2 = features
                return (f1, f2)
        else:
            return features

# Simple criterion
class SimpleCriterion(nn.Module):
    def __init__(self):
        super().__init__()
    
    def forward(self, features, labels=None, supcon_s=False, selfcon_s_FG=False, selfcon_m_FG=False):
        # Just return a dummy loss
        return torch.mean(features) * 0.1

# Options object
class Opt:
    def __init__(self):
        self.method = 'SupCon'
        self.multiview = True
        self.precision = False
        self.print_freq = 10
        self.label = False
        self.alpha = None

opt = Opt()

# Create model
model = SimpleModel(opt)

# Create criterion
criterion = SimpleCriterion()

# Create optimizer
optimizer = optim.SGD(model.parameters(), lr=0.01)

# Create train_loader: list of (images, labels) tuples
# For multiview, images should be a list of two tensors
train_loader = []
for i in range(3):
    if opt.multiview:
        img1 = torch.randn(2, 1, 3, 1)  # batch=2, channels=1, height=3, width=1
        img2 = torch.randn(2, 1, 3, 1)
        images = [img1, img2]
    else:
        images = torch.randn(2, 1, 3, 1)
    labels = torch.randint(0, 5, (2,))
    train_loader.append((images, labels))

epoch = 1

ARGS = {
    'train_loader': train_loader,
    'model': model,
    'criterion': criterion,
    'optimizer': optimizer,
    'epoch': epoch,
    'opt': opt
}
Setup block drafted by
a language model, Claude Sonnet 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 float, ndim 0, dtype family float — no output shape is stated: observe_signature.py could not observe it (fixture:KeyError)
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
wrn28_10 Ran
ran on a synthesized input
XG293/SupConLoss/networks/wide_resnet.py
code served (permissive licence) · get_code("5e3536a0b5948376")
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 WideResNet. 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 = {
    "num_classes": 200,
    "loss_type": "dist"
}
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 WideResNet — a WideResNet output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a WideResNet 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
accimage_loader Not yet run
unverified (harvested, no recorded run)
sidtandon2014/fw-shapley/src/shapley/embedding/custom_loader.py
pointer only (licence: Apache-2.0); the stored copy get_code serves, from RobustBench/robustbench, is pointer only (licence: NOASSERTION) · get_code("404fb2b2daa1ae78")
How it ran

The body of this sample is withheld: this paper's link allows the body inline (Apache-2.0), but get_code serves the stored copy, first harvested from RobustBench/robustbench, and GitHub could not classify the licence of that repository (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. No invocation recorded.

accuracy Not yet run
unverified (harvested, no recorded run)
XG293/SupConLoss/util.py
pointer only (licence: BSD-2-Clause); the stored copy get_code serves, from boone891214/MEST, is pointer only (licence: NONE) · get_code("913d82af53065418")
How it ran

The body of this sample is withheld: this paper's link allows the body inline (BSD-2-Clause), but get_code serves the stored copy, first harvested from boone891214/MEST, 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. No invocation recorded.

search_same Not yet run
unverified (harvested, no recorded run)
PaperCodeReview/SupCL-TF/common.py
code served (permissive licence) · get_code("d04d43e439b0324a")
How it ran

no invocation recorded.

set_loader Not yet run
unverified (harvested, no recorded run)
XG293/SupConLoss/main_ce.py
pointer only (licence: BSD-2-Clause); the stored copy get_code serves, from dongguanting/dpa-rag, is pointer only (licence: NONE) · get_code("2297ed2ca4911b7c")
How it ran

The body of this sample is withheld: this paper's link allows the body inline (BSD-2-Clause), but get_code serves the stored copy, first harvested from dongguanting/dpa-rag, 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. No invocation recorded.

set_loader Not yet run
unverified (harvested, no recorded run)
davidczy/supcon_gamma/main_supcon_thick.py
code served (permissive licence) · get_code("750f33f8190dba7b")
How it ran

no invocation recorded.

train Not yet run
unverified (harvested, no recorded run)
raymin0223/self-contrastive-learning/main_linear.py
code served (permissive licence) · get_code("18ee2c887bb737f7")
How it ran

no invocation recorded.

Also present in other papers' code

Of 23 samples lifted from this paper's linked repositories, 23 carry a function identity and 0 do not. Of the 23 distinct functions with an identity, 9 are also present in other papers whose code we hold (8 with at least one paper dated earlier, 3 the same month, 8 later) and 14 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
accuracy 80 other papers
31 dated earlier, 4 the same month, 45 later
1307.0414 (2013-07)
Challenges in Representation Learning: A report on three machine learning contests
1412.6553 (2014-12)
Speeding-up Convolutional Neural Networks Using Fine-tuned CP-Decomposition
1503.02531 (2015-03)
Distilling the Knowledge in a Neural Network
and 77 more not named here
pil_loader 66 other papers
8 dated earlier, 1 the same month, 57 later
1502.03044 (2015-02)
Show, Attend and Tell: Neural Image Caption Generation with Visual Attention
1710.10196 (2017-10)
Progressive Growing of GANs for Improved Quality, Stability, and Variation
1711.02512 (2017-11)
Fine-tuning CNN Image Retrieval with No Human Annotation
and 63 more not named here
accimage_loader 39 other papers
8 dated earlier, 31 later
1702.00758 (2017-02)
HashNet: Deep Learning to Hash by Continuation
1711.02512 (2017-11)
Fine-tuning CNN Image Retrieval with No Human Annotation
1805.00907 (2018-05)
Glow: Graph Lowering Compiler Techniques for Neural Networks
and 36 more not named here
default_loader 28 other papers
3 dated earlier, 25 later
1907.02665 (2019-07)
Blind Image Quality Assessment Using A Deep Bilinear Convolutional Neural Network
2003.05033 (2020-03)
Generalized Energy Based Models
2003.13659 (2020-03)
Exploiting Deep Generative Prior for Versatile Image Restoration and Manipulation
and 25 more not named here
conv3x3x3 19 other papers
7 dated earlier, 1 the same month, 11 later
1711.08580 (2017-11)
3D Anisotropic Hybrid Network: Transferring Convolutional Features from 2D Images to 3D Anisotropic Volumes
1711.09577 (2017-11)
Can Spatiotemporal 3D CNNs Retrace the History of 2D CNNs and ImageNet?
1908.01373 (2019-08)
Unsupervised Microvascular Image Segmentation Using an Active Contours Mimicking Neural Network
and 16 more not named here
downsample_basic_block 15 other papers
7 dated earlier, 8 later
1705.07750 (2017-05)
Quo Vadis, Action Recognition? A New Model and the Kinetics Dataset
1711.09577 (2017-11)
Can Spatiotemporal 3D CNNs Retrace the History of 2D CNNs and ImageNet?
1908.01373 (2019-08)
Unsupervised Microvascular Image Segmentation Using an Active Contours Mimicking Neural Network
and 12 more not named here
set_optimizer 9 other papers
2 dated earlier, 7 later
1901.07659 (2019-01)
A Machine Learning Benchmark for Facies Classification
1906.05849 (2019-06)
Contrastive Multiview Coding
2106.05258 (2021-06)
Generative Models as a Data Source for Multiview Representation Learning
and 6 more not named here
set_loader 3 other papers
3 later
2308.10239 (2023-08)
From Global to Local: Multi-scale Out-of-distribution Detection
2311.01196 (2023-11)
Combating Bilateral Edge Noise for Robust Link Prediction
2406.18676 (2024-06)
Understand What LLM Needs: Dual Preference Alignment for Retrieval-Augmented Generation
get_logger 2 other papers
2 dated earlier
2003.04297 (2020-03)
Improved Baselines with Momentum Contrastive Learning
2003.13678 (2020-03)
Designing Network Design Spaces

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

Repositories linked to this paper

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

Abstract

Contrastive learning applied to self-supervised representation learning has seen a resurgence in recent years, leading to state of the art performance in the unsupervised training of deep image models. Modern batch contrastive approaches subsume or significantly outperform traditional contrastive losses such as triplet, max-margin and the N-pairs loss. In this work, we extend the self-supervised batch contrastive approach to the fully-supervised setting, allowing us to effectively leverage label information. Clusters of points belonging to the same class are pulled together in embedding space, while simultaneously pushing apart clusters of samples from different classes. We analyze two possible versions of the supervised contrastive (SupCon) loss, identifying the best-performing formulation of the loss. On ResNet-200, we achieve top-1 accuracy of 81.4% on the Ima-geNet dataset, which is 0.8% above the best number reported for this architecture. We show consistent outperformance over cross-entropy on other datasets and two ResNet variants. The loss shows benefits for robustness to natural corruptions, and is more stable to hyperparameter settings such as optimizers and data augmentations. Our loss function is simple to implement and reference TensorFlow code is released at https://t.ly/supcon 1 .

For agents

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

get_harvested_code_for_paper("2004.11362")
get_code_for_paper("2004.11362")
have("2004.11362")

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

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

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

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

Connect an agent — have() is free.