SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 2010.09515 · ICLR · 2021

Improving Transformation Invariance in Contrastive Representation Learning

Tom Rainforth, Adam Foster, Rattana Pukdee

arXiv · PDF · Open in the Atlas

Code that ran

3 of 4 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 3 have no contract verdict; 0 failures of our instrument; 1 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/2010.09515.json · badge: /api/ran/2010.09515.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
ae-foster/invclr canonical (classifier label)
classifier basis: census
3 ran · 1 no recorded run
FunctionStatusWhere it lives
encode_train_set Ran
ran on a synthesized input
ae-foster/invclr/evaluate/lbfgs.py
code served (permissive licence) · get_code("3615fd781c0e7e45")
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

torch.manual_seed(0)

# Create a simple neural network that outputs representations
class SimpleNet(nn.Module):
    def __init__(self):
        super(SimpleNet, self).__init__()
        self.linear = nn.Linear(4, 8)
    
    def forward(self, x):
        return self.linear(x)

# Create a data loader as a list of (inputs, targets) tuples
# Each batch: inputs shape (2, 4), targets shape (2,)
clftrainloader = [
    (torch.randn(2, 4), torch.tensor([0, 1])),
    (torch.randn(2, 4), torch.tensor([1, 0])),
    (torch.randn(2, 4), torch.tensor([0, 0])),
]

device = 'cpu'
net = SimpleNet()

ARGS = {
    'clftrainloader': clftrainloader,
    'device': device,
    'net': net,
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
torch, tqdm — 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
encode_train_set_transformed Ran
ran on a synthesized input
ae-foster/invclr/evaluate/lbfgs.py
code served (permissive licence) · get_code("d34f37712dd92487")
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

torch.manual_seed(0)

# Create a minimal neural network that takes inputs and returns a representation
class MinimalNet(nn.Module):
    def __init__(self, input_dim=3, output_dim=5):
        super().__init__()
        self.linear = nn.Linear(input_dim, output_dim)
    
    def forward(self, x):
        return self.linear(x)

# Create a minimal col_distort object with sample_random_numbers method
class MinimalColDistort:
    def sample_random_numbers(self, shape, device):
        # Return random numbers matching the input shape for distortion
        return torch.randn(shape, device=device)

# Create a batch_transform function
def batch_transform(inputs, random_numbers):
    # Simple transformation: add a small scaled random noise
    return inputs + 0.01 * random_numbers

# Create a minimal data loader as a list of (inputs, targets) tuples
# Batch size 2, input dimension 3, 2 batches total
batch1_inputs = torch.randn(2, 3)
batch1_targets = torch.tensor([0, 1])

batch2_inputs = torch.randn(2, 3)
batch2_targets = torch.tensor([1, 0])

clftrainloader = [
    (batch1_inputs, batch1_targets),
    (batch2_inputs, batch2_targets)
]

# Construct the arguments dictionary
ARGS = {
    'clftrainloader': clftrainloader,
    'device': torch.device('cpu'),
    'net': MinimalNet(input_dim=3, output_dim=5),
    'col_distort': MinimalColDistort(),
    'batch_transform': batch_transform
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
torch, tqdm — 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
train_clf Ran
ran on a synthesized input
ae-foster/invclr/evaluate/lbfgs.py
code served (permissive licence) · get_code("d6204b19819b6764")
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 Linear. 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 small tensors for X and y
batch_size = 2
representation_dim = 4
num_classes = 3

X = torch.randn(batch_size, representation_dim)
y = torch.randint(0, num_classes, (batch_size,))

device = 'cpu'
reg_weight = 0.001
n_lbfgs_steps = 2

ARGS = {
    'X': X,
    'y': y,
    'representation_dim': representation_dim,
    'num_classes': num_classes,
    'device': device,
    'reg_weight': reg_weight,
    'n_lbfgs_steps': n_lbfgs_steps
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
torch, tqdm — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type Linear — a Linear output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a Linear 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 Not yet run
unverified (harvested, no recorded run)
ae-foster/invclr/invclr.py
code served (permissive licence) · get_code("e85d165d8a854a57")
How it ran

no invocation recorded.

Also present in other papers' code

Of 4 samples lifted from this paper's linked repositories, 4 carry a function identity and 0 do not. Of the 4 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, 0 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
encode_train_set 1 other paper
1 dated earlier
2002.05709 (2020-02)
A Simple Framework for Contrastive Learning of Visual Representations

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

We propose methods to strengthen the invariance properties of representations obtained by contrastive learning. While existing approaches implicitly induce a degree of invariance as representations are learned, we look to more directly enforce invariance in the encoding process. To this end, we first introduce a training objective for contrastive learning that uses a novel regularizer to control how the representation changes under transformation. We show that representations trained with this objective perform better on downstream tasks and are more robust to the introduction of nuisance transformations at test time. Second, we propose a change to how test time representations are generated by introducing a feature averaging approach that combines encodings from multiple transformations of the original input, finding that this leads to across the board performance gains. Finally, we introduce the novel Spirograph dataset to explore our ideas in the context of a differentiable generative process with multiple downstream tasks, showing that our techniques for learning invariance are highly beneficial.

For agents

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

get_harvested_code_for_paper("2010.09515")
get_code_for_paper("2010.09515")
have("2010.09515")

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

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

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

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

Connect an agent — have() is free.