SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 2106.07847 · ICML · 2022

Learning Stable Classifiers by Transferring Unstable Features

Regina Barzilay, Shiyu Chang, Yujia Bao

arXiv · PDF · Open in the Atlas

Code that ran

5 of 8 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; 1 honoured the contract we drafted, 0 violated it and 0 have no contract verdict; 4 failures of our instrument; 3 no recorded run), measured 2026-11-22; 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/2106.07847.json · badge: /api/ran/2106.07847.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
YujiaBao/Tofu marked official in Papers with Code
Papers with Code archive
5 ran · 2 no recorded run
facebookresearch/DomainBed community
Papers with Code archive
0 ran · 1 no recorded run
FunctionStatusWhere it lives
compute_l2 Ran
ran, honoured the contract we drafted
YujiaBao/Tofu/src/tofu/partition.py
code served (permissive licence) · get_code("700c01294a7fec4e")
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 2, dtype family float, shape (3, 2) 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

torch.manual_seed(0)

# Create support set: support_size x ebd_dim
XS = torch.randn(2, 4)

# Create query set: query_size x ebd_dim
XQ = torch.randn(3, 4)

ARGS = {
    "XS": XS,
    "XQ": XQ,
}
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 2, dtype family float, shape (3, 2) — shape (3, 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
squeeze_batch Ran
ran; our contract draft was wrong, not the code
YujiaBao/Tofu/src/tofu/partition.py
code served (permissive licence) · get_code("baef20e5a997fba1")
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 torch
import numpy as np

torch.manual_seed(0)

# The function squeeze_batch takes a batch (dict) where each value has length 1
# It asserts that each value v has len(v) == 1, then extracts v[0]
# So we need a dict where values are sequences/lists/tensors with exactly 1 element

batch = {
    "input_ids": [torch.tensor([[1, 2, 3, 4]])],
    "attention_mask": [torch.tensor([[1, 1, 1, 0]])],
    "labels": [torch.tensor([5])],
    "embeddings": [np.array([[0.1, 0.2, 0.3, 0.4]])],
    "metadata": [{"key": "value"}],
}

ARGS = {
    "batch": batch,
}
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
test_partition_loop Ran
ran; the contract check could not run (RAISES, DEP_MISSING or TIMEOUT)
YujiaBao/Tofu/src/tofu/partition.py
code served (permissive licence) · get_code("adc6863235236e3b")
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. 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)

# Define a simple embedding model
class EmbeddingModel(nn.Module):
    def __init__(self, input_dim, output_dim):
        super().__init__()
        self.linear = nn.Linear(input_dim, output_dim)
    
    def forward(self, x):
        return self.linear(x)

# Create the embedding model
ebd_model = EmbeddingModel(input_dim=5, output_dim=4)

# Create model dict with 'ebd' key
model = {'ebd': ebd_model}

# Create test loaders - each loader is a list of batches
# Each batch is a dict with 'X' key containing a list with one tensor
# We need n_group_pairs loaders (pairs of positive/negative)
n_group_pairs = 2

def create_batch(seq_len, feature_dim):
    """Create a batch dict with 'X' key"""
    return {'X': [torch.randn(seq_len, feature_dim)]}

# Create test_loaders with 4 loaders (2 pairs)
test_loaders = []
for i in range(n_group_pairs * 2):
    # Each loader is a list of batches
    loader = [create_batch(seq_len=3 + i, feature_dim=5) for _ in range(2)]
    test_loaders.append(loader)

# Create args with threshold parameter
class Args:
    def __init__(self):
        self.thres = 1.0

args = Args()

ARGS = {
    'test_loaders': test_loaders,
    'model': model,
    'ep': 0,
    'args': args
}
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 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
to_cuda Ran
ran; the contract check could not run (RAISES, DEP_MISSING or TIMEOUT)
YujiaBao/Tofu/src/tofu/partition.py
code served (permissive licence) · get_code("74b1657df849913d")
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. 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

torch.manual_seed(0)

# The function to_cuda expects a dict where values have a .cuda() method
# We'll create a dict with tensors as values
d = {
    'tensor1': torch.randn(2, 4),
    'tensor2': torch.randn(3, 5),
    'tensor3': torch.randn(2, 2)
}

ARGS = {
    'd': d
}
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 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
train_partition_loop Ran
ran; the contract check could not run (RAISES, DEP_MISSING or TIMEOUT)
YujiaBao/Tofu/src/tofu/partition.py
code served (permissive licence) · get_code("05430ad3df65e1b7")
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. 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)

# Define a small embedding model
class EmbeddingModel(nn.Module):
    def __init__(self, input_dim, output_dim):
        super().__init__()
        self.linear = nn.Linear(input_dim, output_dim)
    
    def forward(self, x):
        return self.linear(x)

# Create model dict with embedding model
model = {
    'ebd': EmbeddingModel(input_dim=5, output_dim=4)
}

# Create optimizer
opt = torch.optim.SGD(model['ebd'].parameters(), lr=0.01)

# Create train_loaders as a list of data loaders
# Structure: [ENV_e0_LABEL_y0_correct, ENV_e0_LABEL_y0_mistake, ENV_e0_LABEL_y1_correct, ENV_e0_LABEL_y1_mistake,
#             ENV_e1_LABEL_y0_correct, ENV_e1_LABEL_y0_mistake, ENV_e1_LABEL_y1_correct, ENV_e1_LABEL_y1_mistake]
# Each loader yields batches of {'X': tensor}

def create_loader(batch_size=1, num_batches=1, input_dim=5):
    """Create a simple data loader"""
    loader = []
    for _ in range(num_batches):
        batch = {
            'X': [torch.randn(batch_size, input_dim)]
        }
        loader.append(batch)
    return loader

train_loaders = [
    create_loader(batch_size=2, num_batches=1, input_dim=5),
    create_loader(batch_size=2, num_batches=1, input_dim=5),
    create_loader(batch_size=2, num_batches=1, input_dim=5),
    create_loader(batch_size=2, num_batches=1, input_dim=5),
    create_loader(batch_size=2, num_batches=1, input_dim=5),
    create_loader(batch_size=2, num_batches=1, input_dim=5),
    create_loader(batch_size=2, num_batches=1, input_dim=5),
    create_loader(batch_size=2, num_batches=1, input_dim=5),
]

# Create args object
class Args:
    def __init__(self):
        self.thres = 1.0

args = Args()

# Epoch number
ep = 1

ARGS = {
    'train_loaders': train_loaders,
    'model': model,
    'opt': opt,
    'ep': ep,
    'args': args
}
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 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
Transfer Not yet run
unverified (harvested, no recorded run)
facebookresearch/DomainBed/domainbed/algorithms.py
code served (permissive licence) · get_code("dfeb27642b0d47c1")
How it ran

no invocation recorded.

print_partition_res Not yet run
unverified (harvested, no recorded run)
YujiaBao/Tofu/src/tofu/partition.py
code served (permissive licence) · get_code("c88898ab5483d71f")
How it ran

no invocation recorded.

train_partition Not yet run
unverified (harvested, no recorded run)
YujiaBao/Tofu/src/tofu/partition.py
code served (permissive licence) · get_code("ce0be0da6677ca80")
How it ran

no invocation recorded.

Also present in other papers' code

Of 8 samples lifted from this paper's linked repositories, 8 carry a function identity and 0 do not. Of the 8 distinct functions with an identity, 2 are also present in other papers whose code we hold (2 with at least one paper dated earlier, 0 the same month, 0 later) and 6 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
squeeze_batch
brick of this paper's assembly: helper
1 other paper
1 dated earlier · 1 only as an assembly brick
2105.12628 (2021-05)
Predict then Interpolate: A Simple Algorithm to Learn Stable Classifiers
to_cuda
brick of this paper's assembly: helper
1 other paper
1 dated earlier · 1 only as an assembly brick
2105.12628 (2021-05)
Predict then Interpolate: A Simple Algorithm to Learn Stable Classifiers

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

While unbiased machine learning models are essential for many applications, bias is a humandefined concept that can vary across tasks. Given only input-label pairs, algorithms may lack sufficient information to distinguish stable (causal) features from unstable (spurious) features. However, related tasks often share similar biases -an observation we may leverage to develop stable classifiers in the transfer setting. In this work, we explicitly inform the target classifier about unstable features in the source tasks. Specifically, we derive a representation that encodes the unstable features by contrasting different data environments in the source task. We achieve robustness by clustering data of the target task according to this representation and minimizing the worstcase risk across these clusters. We evaluate our method on both text and image classifications. Empirical results demonstrate that our algorithm is able to maintain robustness on the target task for both synthetically generated environments and real-world environments. Our code is available at https://github.com/YujiaBao/Tofu.

For agents

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

get_harvested_code_for_paper("2106.07847")
get_code_for_paper("2106.07847")
have("2106.07847")

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

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

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

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

Connect an agent — have() is free.