SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 2105.06422 · 2021

Causally motivated Shortcut Removal Using Auxiliary Labels

arXiv · PDF · Open in the Atlas

Code that ran

7 of 11 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; 3 honoured the contract we drafted, 0 violated it and 0 have no contract verdict; 4 failures of our instrument; 4 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/2105.06422.json · badge: /api/ran/2105.06422.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
mymakar/causally_motivated_shortcut_removal canonical (classifier label)
classifier basis: census
7 ran · 4 no recorded run
FunctionStatusWhere it lives
compute_pred_loss Ran
ran; the contract check could not run (RAISES, DEP_MISSING or TIMEOUT)
mymakar/causally_motivated_shortcut_removal/shared/evaluation_metrics.py
code served (permissive licence) · get_code("f5d713c3ef15f625")
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 EagerTensor, 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 tensorflow as tf
import numpy as np

# Set random seed for reproducibility
np.random.seed(0)
tf.random.set_seed(0)

# Create small tensors for the function
batch_size = 2
num_labels = 4
label_ind = 1

# labels: shape (batch_size, num_labels) - contains binary labels
labels = tf.constant([
    [0.0, 1.0, 0.0, 1.0],
    [1.0, 0.0, 1.0, 0.0]
], dtype=tf.float32)

# logits: shape (batch_size, 1) - raw model outputs for binary classification
logits = tf.constant([
    [0.5],
    [-0.3]
], dtype=tf.float32)

# sample_weights: shape (batch_size,) - weights for each sample
sample_weights = tf.constant([1.0, 2.0], dtype=tf.float32)

# params: configuration dict with required keys
params = {
    'label_ind': label_ind,
    'weighted_mmd': 'False'
}

ARGS = {
    'labels': labels,
    'logits': logits,
    'sample_weights': sample_weights,
    'params': params
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
numpy, tensorflow — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type EagerTensor, 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
decode_number Ran
ran, honoured the contract we drafted
mymakar/causally_motivated_shortcut_removal/chexpert/data_builder.py
code served (permissive licence) · get_code("bccc96ebed03600f")
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 EagerTensor, ndim 1, dtype family float, shape (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 tensorflow as tf

# The function decode_number takes a 'label' parameter
# It expands dims and converts strings to numbers
# So label should be a string tensor

label = tf.constant("123.45")

ARGS = {
    "label": label
}
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 EagerTensor, ndim 1, dtype family float, shape (1,) — shape (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
extract_weights Ran
ran, honoured the contract we drafted
mymakar/causally_motivated_shortcut_removal/shared/train_utils.py
code served (permissive licence) · get_code("30b2e469555255e7")
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 3, 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 tensorflow as tf
import numpy as np

# Create sample tensors for balanced and unbalanced weights
# Shape: (batch_size=2, num_weight_types=3)
balanced_weights = tf.constant([
    [0.5, 0.3, 0.2],
    [0.4, 0.4, 0.2]
], dtype=tf.float32)

unbalanced_weights = tf.constant([
    [0.6, 0.2, 0.2],
    [0.7, 0.1, 0.2]
], dtype=tf.float32)

# Create labels dictionary with both weight options
labels = {
    'balanced_weights': balanced_weights,
    'unbalanced_weights': unbalanced_weights
}

# Create params dictionary with both True case
params_weighted_balanced = {
    'weighted_mmd': 'True',
    'balanced_weights': 'True'
}

# Create params dictionary with both False case
params_unweighted = {
    'weighted_mmd': 'False',
    'balanced_weights': 'False'
}

# Define ARGS for the function call
ARGS = {
    'labels': labels,
    'params': params_weighted_balanced
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
numpy, tensorflow — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type tuple, ndim 3, 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
flatten_dict Ran
ran; our contract draft was wrong, not the code
mymakar/causally_motivated_shortcut_removal/shared/train_utils.py
code served (permissive licence) · get_code("3e2e16445f6f92e6")
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

# Analyze the function: it takes a nested dictionary and flattens it
# Parameters: dd (dict to flatten), separator (str), prefix (str)
# The function recursively flattens nested dicts, using separator to join keys

# Create a nested dictionary with eval metrics as the docstring suggests
nested_dict = {
    'train': {
        'loss': 0.523,
        'accuracy': 0.94,
        'metrics': {
            'f1': 0.91,
            'precision': 0.89
        }
    },
    'val': {
        'loss': 0.612,
        'accuracy': 0.91
    },
    'test_score': 0.88
}

ARGS = {
    'dd': nested_dict,
    'separator': '_',
    'prefix': ''
}
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
get_last_saved_model Ran
ran; our contract draft was wrong, not the code
mymakar/causally_motivated_shortcut_removal/shared/get_sigma.py
code served (permissive licence) · get_code("36df5a80dc755620")
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 _WrapperFunction. 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 shutil
from pathlib import Path
import tensorflow as tf

# Create a temporary directory structure with a saved model
temp_dir = tempfile.mkdtemp()
estimator_dir = temp_dir

# Create subdirectories with numeric names (like TensorFlow Estimator does)
model_dir_1 = Path(estimator_dir) / "1000"
model_dir_1.mkdir(parents=True, exist_ok=True)

model_dir_2 = Path(estimator_dir) / "2000"
model_dir_2.mkdir(parents=True, exist_ok=True)

# Create a simple TensorFlow saved model in the latest directory
class SimpleModel(tf.Module):
    def __init__(self):
        super(SimpleModel, self).__init__()
    
    @tf.function(input_signature=[
        tf.TensorSpec(shape=[None, 4], dtype=tf.float32)
    ])
    def serving_default(self, x):
        return tf.reduce_sum(x, axis=1, keepdims=True)

# Save the model to the latest directory
model = SimpleModel()
concrete_func = model.serving_default.get_concrete_function(
    tf.TensorSpec(shape=[None, 4], dtype=tf.float32)
)
tf.saved_model.save(
    model,
    str(model_dir_2),
    signatures={'serving_default': concrete_func}
)

ARGS = {
    'estimator_dir': estimator_dir
}
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 _WrapperFunction — a _WrapperFunction output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a _WrapperFunction 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
map_to_image_label Ran
ran; our contract draft was wrong, not the code
mymakar/causally_motivated_shortcut_removal/chexpert/data_builder.py
code served (permissive licence) · get_code("12b5a06366dc915e")
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 tensorflow as tf
import tempfile
import os
from PIL import Image
import numpy as np

# Create a temporary directory and a small test JPEG image
temp_dir = tempfile.mkdtemp()
img_array = np.random.randint(0, 256, (32, 32, 3), dtype=np.uint8)
img = Image.fromarray(img_array)
img_path = os.path.join(temp_dir, "test_image.jpg")
img.save(img_path)

# Define arguments for map_to_image_label
# x: tuple with chest_image path, y0 label, y1 label, and optionally 6 weight values
# pixel: size for image resizing

x_without_weights = (
    img_path,
    "0.5",
    "0.7"
)

x_with_weights = (
    img_path,
    "0.5",
    "0.7",
    "1.2",  # unbalanced_weights_pos
    "0.8",  # unbalanced_weights_neg
    "1.0",  # unbalanced_weights_both
    "1.1",  # balanced_weights_pos
    "0.9",  # balanced_weights_neg
    "1.0"   # balanced_weights_both
)

pixel = 64

ARGS = {
    "x": x_with_weights,
    "pixel": pixel
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
PIL, numpy, tensorflow — 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
read_decode_jpg Ran
ran, honoured the contract we drafted
mymakar/causally_motivated_shortcut_removal/chexpert/data_builder.py
code served (permissive licence) · get_code("1406483012c2b867")
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 EagerTensor, ndim 3, dtype family int, shape (4, 3, 3) 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 tempfile
import os
import numpy as np
from PIL import Image

# Create a temporary JPEG file for testing
temp_dir = tempfile.mkdtemp()
temp_image_path = os.path.join(temp_dir, "test_image.jpg")

# Create a small test image (4x3 RGB) and save as JPEG
img_array = np.random.randint(0, 256, (4, 3, 3), dtype=np.uint8)
img = Image.fromarray(img_array, mode='RGB')
img.save(temp_image_path, format='JPEG')

ARGS = {
    "file_path": temp_image_path
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
PIL, numpy, tensorflow — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type EagerTensor, ndim 3, dtype family int, shape (4, 3, 3) — shape (4, 3, 3) 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
create_architecture Not yet run
unverified (harvested, no recorded run)
mymakar/causally_motivated_shortcut_removal/shared/architectures.py
code served (permissive licence) · get_code("ef3ba340df457610")
How it ran

no invocation recorded.

get_optimal_model_classic Not yet run
unverified (harvested, no recorded run)
mymakar/causally_motivated_shortcut_removal/shared/cross_validation.py
code served (permissive licence) · get_code("031fc88b30375099")
How it ran

no invocation recorded.

read_decode_png Not yet run
unverified (harvested, no recorded run)
mymakar/causally_motivated_shortcut_removal/waterbirds/data_builder.py
code served (permissive licence) · get_code("570c66778860579a")
How it ran

no invocation recorded.

reshape_results Not yet run
unverified (harvested, no recorded run)
mymakar/causally_motivated_shortcut_removal/shared/cross_validation.py
code served (permissive licence) · get_code("3715e0dc12e4f657")
How it ran

no invocation recorded.

Also present in other papers' code

Of 11 samples lifted from this paper's linked repositories, 11 carry a function identity and 0 do not. Of the 11 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 11 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

Shortcut learning, in which models make use of easy-to-represent but unstable associations, is a major failure mode for robust machine learning. We study a flexible, causally-motivated approach to training robust predictors by discouraging the use of specific shortcuts, focusing on a common setting where a robust predictor could achieve optimal \emph{iid} generalization in principle, but is overshadowed by a shortcut predictor in practice. Our approach uses auxiliary labels, typically available at training time, to enforce conditional independences implied by the causal graph. We show both theoretically and empirically that causally-motivated regularization schemes (a) lead to more robust estimators that generalize well under distribution shift, and (b) have better finite sample efficiency compared to usual regularization schemes, even when no shortcut is present. Our analysis highlights important theoretical properties of training techniques commonly used in the causal inference, fairness, and disentanglement literatures. Our code is available at https://github.com/mymakar/causally_motivated_shortcut_removal

For agents

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

get_harvested_code_for_paper("2105.06422")
get_code_for_paper("2105.06422")
have("2105.06422")

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

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

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

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

Connect an agent — have() is free.