SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 2207.02842 · 2022

When does Bias Transfer in Transfer Learning?

arXiv · PDF · Open in the Atlas

Code that ran

7 of 10 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 7 have no contract verdict; 0 failures of our instrument; 3 no recorded run), measured 2026-11-23; 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/2207.02842.json · badge: /api/ran/2207.02842.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
MadryLab/bias-transfer canonical (classifier label)
classifier basis not recorded on the link
7 ran · 3 no recorded run
FunctionStatusWhere it lives
build_model Ran
ran on a synthesized input
MadryLab/bias-transfer/src/models.py
code served (permissive licence) · get_code("e528e1ef2fec63df")
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 TransferNetwork. 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
import torchvision.models as torch_models
import copy

torch.manual_seed(0)

# Build a minimal backbone that works with the TransferNetwork
class MinimalBackbone(nn.Module):
    def __init__(self):
        super().__init__()
        self.conv = nn.Conv2d(3, 64, kernel_size=3, padding=1)
        self.pool = nn.AdaptiveAvgPool2d((1, 1))
    
    def forward(self, x, **fwd_args):
        x = self.conv(x)
        x = self.pool(x)
        return x

# Build a minimal source model
class MinimalSourceModel(nn.Module):
    def __init__(self, num_classes=1000, pretrained=False):
        super().__init__()
        self.features = nn.Sequential(
            nn.Conv2d(3, 64, kernel_size=3, padding=1),
            nn.ReLU(inplace=True),
            nn.AdaptiveAvgPool2d((1, 1))
        )
        self.fc = nn.Linear(64, num_classes)
    
    def forward(self, x):
        x = self.features(x)
        x = torch.flatten(x, 1)
        x = self.fc(x)
        return x
    
    def children(self):
        return [self.features, self.fc]

# Construct model_building_args for 'transfer' stage
model_building_args_transfer = {
    'model_stage': 'transfer',
    'params': {
        'source_checkpoint': None,
        'num_classes': 10,
        'freeze_backbone': False,
        'arch': 'resnet18',
        'pretrained': False
    }
}

# Construct model_building_args for 'source' stage
model_building_args_source = {
    'model_stage': 'source',
    'params': {
        'arch': 'resnet18',
        'num_classes': 1000,
        'pretrained': False
    }
}

ARGS = {
    'model_building_args': model_building_args_transfer
}
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 TransferNetwork — a TransferNetwork output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a TransferNetwork 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_source_model Ran
ran on a synthesized input
MadryLab/bias-transfer/src/models.py
code served (permissive licence) · get_code("db3563326e1ddc10")
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. 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
import torchvision.models as torch_models

torch.manual_seed(0)

# The function calls torch_models.__dict__[arch](num_classes=num_classes, pretrained=pretrained).cuda()
# We need to provide:
# - arch: a string key that exists in torch_models.__dict__ and is callable
# - num_classes: an integer
# - pretrained: a boolean

# Check what architectures are available in torchvision.models
# Common ones include 'resnet18', 'resnet50', 'vgg16', 'alexnet', etc.
# We'll use 'resnet18' as it's small and commonly available

ARGS = {
    'arch': 'resnet18',
    'num_classes': 10,
    'pretrained': False
}
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
convert_fastargs Ran
ran on a synthesized input
MadryLab/bias-transfer/src/config_parse_utils.py
code served (permissive licence) · get_code("2bd9ba841b22a533")
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.

from types import SimpleNamespace

def convert_fastargs(fast_args):
    args_dict = {}
    fast_args_vars = vars(fast_args)
    for key, value in fast_args_vars.items():
        if isinstance(value, SimpleNamespace):
            args_dict.update(convert_fastargs(value))
        else:
            args_dict[key] = value
    return args_dict

# Construct valid arguments for convert_fastargs
# The function expects a SimpleNamespace object with attributes
# Some attributes can be nested SimpleNamespace objects, others are regular values

nested_namespace = SimpleNamespace(
    nested_key1="nested_value1",
    nested_key2=42
)

fast_args = SimpleNamespace(
    key1="value1",
    key2=123,
    key3=3.14,
    nested=nested_namespace,
    key4=[1, 2, 3],
    key5={"dict": "value"}
)

ARGS = {
    "fast_args": fast_args
}
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 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
evaluate_model Ran
ran on a synthesized input
MadryLab/bias-transfer/src/eval_utils.py
code served (permissive licence) · get_code("8e3e794b7f3dd5f7")
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)

# Build a minimal model that satisfies the function's usage
class MinimalModel(nn.Module):
    def __init__(self, num_classes=10):
        super().__init__()
        self.linear = nn.Linear(4, num_classes)
    
    def forward(self, x):
        return self.linear(x)

# Create a minimal data loader (list of (x, y) tuples)
# batch_size=2, input_dim=4, num_classes=10
loader = [
    (torch.randn(2, 4), torch.randint(0, 10, (2,))),
    (torch.randn(2, 4), torch.randint(0, 10, (2,))),
]

# Create model instance
model = MinimalModel(num_classes=10)

ARGS = {
    'model': model,
    'loader': loader,
    'num_classes': 10,
    'granularity': 'global',
    'name': None,
}
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 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
get_optimizer_and_lr_scheduler Ran
ran on a synthesized input
MadryLab/bias-transfer/src/optimizers.py
code served (permissive licence) · get_code("194c6951a2cf7d0e")
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 torch.nn as nn
from torch.optim import SGD
from torch.optim.lr_scheduler import LambdaLR, MultiStepLR, StepLR
import numpy as np

torch.manual_seed(0)

class SimpleModel(nn.Module):
    def __init__(self):
        super().__init__()
        self.linear = nn.Linear(4, 3)
    
    def forward(self, x):
        return self.linear(x)

model = SimpleModel()

training_args_constant = {
    'lr_scheduler': 'constant',
    'lr': 0.01,
    'weight_decay': 1e-4,
    'momentum': 0.9,
}

training_args_steplr = {
    'lr_scheduler': 'steplr',
    'lr': 0.01,
    'weight_decay': 1e-4,
    'momentum': 0.9,
    'step_size': 10,
    'gamma': 0.1,
}

training_args_multisteplr = {
    'lr_scheduler': 'multisteplr',
    'lr': 0.01,
    'weight_decay': 1e-4,
    'momentum': 0.9,
    'lr_milestones': [5, 10],
    'gamma': 0.1,
}

training_args_cyclic = {
    'lr_scheduler': 'cyclic',
    'lr': 0.01,
    'weight_decay': 1e-4,
    'momentum': 0.9,
    'epochs': 20,
    'lr_peak_epoch': 10,
}

ARGS = {
    'training_args': training_args_cyclic,
    'model': model,
    'iters_per_epoch': 1,
}
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, 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
inv_norm Ran
ran on a synthesized input
MadryLab/bias-transfer/src/loaders.py
code served (permissive licence) · get_code("93ab68302cd1eac2")
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 Compose. 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 numpy as np
from torchvision.transforms import Normalize, Compose

DS_TO_MEAN = {'IMAGENET': np.array([0.485, 0.456, 0.406]), 'CALTECH101': np.array([0.0, 0.0, 0.0]), 'CALTECH256': np.array([0.0, 0.0, 0.0]), 'CIFAR10': np.array([0.4914, 0.4822, 0.4465]), 'CIFAR100': np.array([0.5071, 0.4867, 0.4408]), 'CHESTXRAY14': np.array([0.485, 0.456, 0.406]), 'SUN397': np.array([0.0, 0.0, 0.0]), 'AIRCRAFT': np.array([0.0, 0.0, 0.0]), 'BIRDSNAP': np.array([0.0, 0.0, 0.0]), 'FLOWERS': np.array([0.0, 0.0, 0.0]), 'FOOD': np.array([0.0, 0.0, 0.0]), 'PETS': np.array([0.0, 0.0, 0.0]), 'STANFORD_CARS': np.array([0.0, 0.0, 0.0])}

DS_TO_STD = {'IMAGENET': np.array([0.229, 0.224, 0.225]), 'CALTECH101': np.array([1.0, 1.0, 1.0]), 'CALTECH256': np.array([1.0, 1.0, 1.0]), 'CIFAR10': np.array([0.2023, 0.1994, 0.201]), 'CIFAR100': np.array([0.2675, 0.2565, 0.2761]), 'CHESTXRAY14': np.array([0.229, 0.224, 0.225]), 'SUN397': np.array([1.0, 1.0, 1.0]), 'AIRCRAFT': np.array([1.0, 1.0, 1.0]), 'BIRDSNAP': np.array([1.0, 1.0, 1.0]), 'FLOWERS': np.array([1.0, 1.0, 1.0]), 'FOOD': np.array([1.0, 1.0, 1.0]), 'PETS': np.array([1.0, 1.0, 1.0]), 'STANFORD_CARS': np.array([1.0, 1.0, 1.0])}

def inv_norm(ds_name):
    DATASET_MEAN = DS_TO_MEAN[ds_name.upper()]
    DATASET_STD = DS_TO_STD[ds_name.upper()]
    return Compose([Normalize(mean=[0.0, 0.0, 0.0], std=1 / DATASET_STD), Normalize(mean=-DATASET_MEAN, std=[1.0, 1.0, 1.0])])

ARGS = {
    'ds_name': 'IMAGENET'
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
numpy, torchvision — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type Compose — a Compose output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a Compose 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_yaml Ran
ran on a synthesized input
MadryLab/bias-transfer/src/config_parse_utils.py
code served (permissive licence) · get_code("d7853049a9701459")
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 tempfile
import os
import yaml

# Create a temporary YAML file
temp_dir = tempfile.mkdtemp()
yaml_file_path = os.path.join(temp_dir, "test.yaml")

# Write a simple valid YAML file
test_yaml_content = {
    "name": "test",
    "version": 1.0,
    "config": {
        "learning_rate": 0.001,
        "batch_size": 32
    }
}

with open(yaml_file_path, 'w') as f:
    yaml.dump(test_yaml_content, f)

ARGS = {
    "yaml_dir": yaml_file_path
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
yaml — 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
build_transfer_model Not yet run
unverified (harvested, no recorded run)
MadryLab/bias-transfer/src/models.py
code served (permissive licence) · get_code("f41852bd75e525c2")
How it ran

no invocation recorded.

get_spurious_indices Not yet run
unverified (harvested, no recorded run)
MadryLab/bias-transfer/src/embed_spurious.py
code served (permissive licence) · get_code("21db9a02a5e09164")
How it ran

no invocation recorded.

get_training_loaders Not yet run
unverified (harvested, no recorded run)
MadryLab/bias-transfer/src/facial_recognition.py
code served (permissive licence) · get_code("7f16e0e5db7b1569")
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, 0 are also present in other papers whose code we hold (0 with at least one paper dated earlier, 0 the same month, 0 later) and 10 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.

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

Repositories linked to this paper

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

Abstract

Using transfer learning to adapt a pre-trained "source model" to a downstream "target task" can dramatically increase performance with seemingly no downside. In this work, we demonstrate that there can exist a downside after all: bias transfer, or the tendency for biases of the source model to persist even after adapting the model to the target class. Through a combination of synthetic and natural experiments, we show that bias transfer both (a) arises in realistic settings (such as when pre-training on ImageNet or other standard datasets) and (b) can occur even when the target dataset is explicitly de-biased. As transfer-learned models are increasingly deployed in the real world, our work highlights the importance of understanding the limitations of pre-trained source models. Code is available at https://github.com/MadryLab/bias-transfer

For agents

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

get_harvested_code_for_paper("2207.02842")
get_code_for_paper("2207.02842")
have("2207.02842")

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

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

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

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

Connect an agent — have() is free.