SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 2105.04857 · 2021

Leveraging Sparse Linear Layers for Debuggable Deep Networks

arXiv · PDF · Open in the Atlas

Code that ran

9 of 13 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; 8 failures of our instrument; 4 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/2105.04857.json · badge: /api/ran/2105.04857.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/DebuggableDeepNetworks canonical (classifier label)
classifier basis: census
6 ran · 4 no recorded run
MadryLab/glm_saga canonical (classifier label)
classifier basis: census
3 ran · 0 no recorded run
FunctionStatusWhere it lives
DATASETS Ran
ran; our contract draft was wrong, not the code
MadryLab/DebuggableDeepNetworks/language/datasets.py
code served (permissive licence) · get_code("dbe7ed3441626a35")
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 type. 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 pandas as pd
import tempfile
import os

torch.manual_seed(0)

# Create a mock tokenizer for SSTDataset
class MockTokenizer:
    def tokenize(self, sentence):
        return sentence.split()
    
    def convert_tokens_to_ids(self, tokens):
        # Simple mapping: each token gets a unique id based on hash
        return [hash(token) % 1000 for token in tokens]

# Create a mock tokenizer for JigsawDataset (HuggingFace style)
class MockHFTokenizer:
    def __call__(self, sentence, padding='max_length', truncation=True):
        tokens = sentence.split()[:10]
        input_ids = [101] + [hash(t) % 1000 for t in tokens] + [102]
        input_ids = input_ids[:512]
        input_ids = input_ids + [0] * (512 - len(input_ids))
        attention_mask = [1 if x != 0 else 0 for x in input_ids]
        return {
            'input_ids': input_ids,
            'attention_mask': attention_mask
        }

# Create a mock JigsawDataOriginal class
class JigsawDataOriginal:
    def __init__(self, train_csv_file=None, test_csv_file=None, train=False, 
                 create_val_set=False, add_test_labels=False, classes=None):
        self.data = [
            ("This is toxic comment", {'multi_target': torch.tensor([1.0])}),
            ("This is nice comment", {'multi_target': torch.tensor([0.0])}),
        ]
    
    def __len__(self):
        return len(self.data)
    
    def __getitem__(self, index):
        return self.data[index % len(self.data)]

# Create temporary CSV files for SST dataset
with tempfile.TemporaryDirectory() as tmpdir:
    sst_file = os.path.join(tmpdir, 'sst_train.csv')
    df_sst = pd.DataFrame({
        'sentence': ['This movie is great', 'This movie is bad'],
        'label': [1, 0]
    })
    df_sst.to_csv(sst_file, sep='\t', index=False)
    
    jigsaw_file = os.path.join(tmpdir, 'jigsaw_train.csv')
    df_jigsaw = pd.DataFrame({
        'comment_text': ['toxic comment', 'nice comment'],
        'toxic': [1, 0]
    })
    df_jigsaw.to_csv(jigsaw_file, sep=',', index=False)
    
    # Store file paths for use in ARGS
    sst_filename = sst_file
    jigsaw_filename = jigsaw_file
    
    ARGS = {
        'dataset_name': 'sst'
    }
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
pandas, torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type type — a type output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a type 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
add_index_to_dataloader Ran
ran; our contract draft was wrong, not the code
MadryLab/glm_saga/glm_saga/elasticnet.py
pointer only (licence: MIT); the stored copy get_code serves, from importAmir/CI-CBM, is pointer only (licence: NONE) · get_code("7798dffe63b4a970")
How it ran

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

add_index_to_dataloader Ran
ran; our contract draft was wrong, not the code
MadryLab/DebuggableDeepNetworks/helpers/data_helpers.py
code served (permissive licence) · get_code("3de8819381c314c3")
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 DataLoader. 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 as ch
import torch.utils.data

ch.manual_seed(0)

# Create a small base dataset with (x, y) tuples
base_data = [(ch.randn(4), ch.randint(0, 2, (1,))) for _ in range(2)]
base_dataset = ch.utils.data.TensorDataset(
    ch.randn(2, 4),
    ch.randint(0, 2, (2,))
)

# Create a DataLoader from the base dataset
loader = ch.utils.data.DataLoader(
    base_dataset,
    batch_size=2,
    sampler=None,
    num_workers=0,
    collate_fn=None,
    pin_memory=False,
    drop_last=False,
    timeout=0,
    worker_init_fn=None,
    multiprocessing_context=None
)

# Create sample weights (optional)
sample_weight = ch.tensor([0.5, 1.0])

ARGS = {
    "loader": loader,
    "sample_weight": sample_weight
}
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 DataLoader — a DataLoader output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a DataLoader 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_device Ran
ran; our contract draft was wrong, not the code
MadryLab/glm_saga/glm_saga/elasticnet.py
pointer only (licence: MIT); the stored copy get_code serves, from Trustworthy-ML-Lab/Linear-Explanations, is pointer only (licence: NONE) · get_code("406014b884a2aaa7")
How it ran

The body of this sample is withheld: this paper's link allows the body inline (MIT), but get_code serves the stored copy, first harvested from Trustworthy-ML-Lab/Linear-Explanations, 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.

get_features_batch Ran
ran; our contract draft was wrong, not the code
MadryLab/DebuggableDeepNetworks/helpers/feature_helpers.py
code served (permissive licence) · get_code("7ebbfb81e3fe0d67")
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. 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 as ch
import torch.nn as nn

ch.manual_seed(0)

# Test with vision dataset_type
class SimpleVisionModel(nn.Module):
    def __init__(self):
        super().__init__()
        self.encoder = nn.Linear(4, 8)
    
    def forward(self, x, with_latent=False):
        latent = self.encoder(x)
        if with_latent:
            return (None, latent), None
        return latent

# Test with NLP dataset_type - RoBERTa-like model
class SimpleRobertaModel(nn.Module):
    def __init__(self):
        super().__init__()
        self.roberta = nn.Module()
        self.roberta.forward = lambda input_ids, attention_mask: (ch.randn(2, 5, 8),)
        
        self.classifier = nn.Module()
        self.classifier.dropout = nn.Dropout(0.1)
        self.classifier.dense = nn.Linear(8, 16)

# Vision batch: (images, targets)
vision_batch = (
    ch.randn(2, 4),  # batch of 2 images with 4 features
    ch.tensor([0, 1])  # targets
)

# NLP batch: (input_ids, attention_mask, targets)
# targets with -1 means masked out
nlp_batch = (
    ch.randint(0, 100, (2, 5)),  # input_ids: batch_size=2, seq_len=5
    ch.ones(2, 5, dtype=ch.long),  # attention_mask
    ch.tensor([1, 2])  # targets (no -1, so all kept)
)

vision_model = SimpleVisionModel()
nlp_model = SimpleRobertaModel()

ARGS = {
    'batch': vision_batch,
    'model': vision_model,
    'dataset_type': 'vision',
    'pooled_output': None,
    'device': 'cpu'
}
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 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
latent_predict Ran
ran; our contract draft was wrong, not the code
MadryLab/DebuggableDeepNetworks/helpers/vis_helpers.py
code served (permissive licence) · get_code("ca5fb68e5cab83b9")
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 2, dtype family float, shape (2, 4) 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 as ch
import torch.nn as nn
import torchvision
from PIL import Image
import numpy as np

ch.manual_seed(0)

# Create a minimal model that satisfies the function's usage
class DummyModel(nn.Module):
    def __init__(self):
        super().__init__()
        self.linear = nn.Linear(12, 4)  # Input: 3*2*2 flattened, Output: latent dim 4
    
    def forward(self, x, with_latent=False):
        # x shape: (batch, 3, 2, 2)
        batch_size = x.shape[0]
        x_flat = x.view(batch_size, -1)  # Flatten to (batch, 12)
        latents = self.linear(x_flat)  # (batch, 4)
        
        if with_latent:
            # Return ((something, latents), something)
            return (("dummy_output", latents), None)
        return latents

model = DummyModel()
model.eval()

# Create dummy PIL images (batch of 2 images, small size)
images = [
    Image.new('RGB', (2, 2), color=(100, 150, 200)),
    Image.new('RGB', (2, 2), color=(50, 75, 100))
]

# Create mean and std tensors for normalization
# They should have shape matching latent dimension (4)
mean = ch.randn(4)
std = ch.abs(ch.randn(4)) + 0.1  # Ensure non-zero

ARGS = {
    'images': images,
    'model': model,
    'mean': mean,
    'std': std
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
PIL, numpy, torch, torchvision — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type ndarray, ndim 2, dtype family float, shape (2, 4) — shape (2, 4) 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
make_lime_fn Ran
ran; our contract draft was wrong, not the code
MadryLab/DebuggableDeepNetworks/helpers/nlp_helpers.py
code served (permissive licence) · get_code("006b1ff00a0f50e9")
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. 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 as ch
import torch.nn as nn

ch.manual_seed(0)

# Build a minimal model with roberta attribute
class MinimalClassifier(nn.Module):
    def __init__(self):
        super().__init__()
        self.roberta = nn.Module()
        self.roberta.forward = self._roberta_forward
        
    def _roberta_forward(self, input_ids, attention_mask):
        batch_size = input_ids.size(0)
        # Return tuple with (sequence_output, pooled_output)
        sequence_output = ch.randn(batch_size, 8, 4)
        pooled_output = ch.randn(batch_size, 4)
        return (sequence_output, pooled_output)

class MinimalClassifierBert(nn.Module):
    def __init__(self):
        super().__init__()
        self.bert = nn.Module()
        self.bert.forward = self._bert_forward
        
    def _bert_forward(self, input_ids, attention_mask):
        batch_size = input_ids.size(0)
        sequence_output = ch.randn(batch_size, 8, 4)
        pooled_output = ch.randn(batch_size, 4)
        return (sequence_output, pooled_output)

# Build minimal val_set with process_sentence method
class MinimalValSet:
    def __init__(self):
        self.dataset = None
    
    def process_sentence(self, s):
        # Return (input_ids tensor, attention_mask tensor)
        input_ids = ch.randint(0, 1000, (8,))
        attention_mask = ch.ones(8)
        return (input_ids, attention_mask)

model = MinimalClassifier()
val_set = MinimalValSet()
pooled_output = False
mu = ch.zeros(4)
std = ch.ones(4)

ARGS = {
    'model': model,
    'val_set': val_set,
    'pooled_output': pooled_output,
    'mu': mu,
    'std': std,
    'bs': 2
}
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 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
normalize_weight Ran
ran; our contract draft was wrong, not the code
MadryLab/DebuggableDeepNetworks/helpers/vis_helpers.py
code served (permissive licence) · get_code("6938b253da1fdca6")
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 float, shape (4,) 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)

# The function expects a tensor with a .numpy() method
# It will call np.linalg.norm on the numpy array
# Create a small weight vector tensor
w = torch.randn(4)

ARGS = {
    "w": w
}
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 ndarray, ndim 1, dtype family float, shape (4,) — shape (4,) 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
soft_threshold Ran
ran, honoured the contract we drafted
MadryLab/glm_saga/glm_saga/elasticnet.py
pointer only (licence: MIT); the stored copy get_code serves, from Trustworthy-ML-Lab/Linear-Explanations, is pointer only (licence: NONE) · get_code("bfe4b187a1c5aeaf")
How it ran

The body of this sample is withheld: this paper's link allows the body inline (MIT), but get_code serves the stored copy, first harvested from Trustworthy-ML-Lab/Linear-Explanations, 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.

compute_features Not yet run
unverified (harvested, no recorded run)
MadryLab/DebuggableDeepNetworks/helpers/feature_helpers.py
code served (permissive licence) · get_code("e63aedfcdb649b2c")
How it ran

no invocation recorded.

load_glm Not yet run
unverified (harvested, no recorded run)
MadryLab/DebuggableDeepNetworks/helpers/decisionlayer_helpers.py
code served (permissive licence) · get_code("be6df81616b96380")
How it ran

no invocation recorded.

select_sparse_model Not yet run
unverified (harvested, no recorded run)
MadryLab/DebuggableDeepNetworks/helpers/decisionlayer_helpers.py
code served (permissive licence) · get_code("73162833f0dfa306")
How it ran

no invocation recorded.

top_and_bottom_words Not yet run
unverified (harvested, no recorded run)
MadryLab/DebuggableDeepNetworks/helpers/nlp_helpers.py
code served (permissive licence) · get_code("78f109bba22b01db")
How it ran

no invocation recorded.

Also present in other papers' code

Of 13 samples lifted from this paper's linked repositories, 13 carry a function identity and 0 do not. Of the 13 distinct functions with an identity, 3 are also present in other papers whose code we hold (0 with at least one paper dated earlier, 0 the same month, 3 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.

FunctionAlso present inEarliest-datedOthers named
get_device 5 other papers
5 later · 2 only as an assembly brick
2308.03685 (2023-08)
Learning Concise and Descriptive Attributes for Visual Recognition
2405.06855 (2024-05)
Linear Explanations for Individual Neurons
2408.01432 (2024-08)
VLG-CBM: Training Concept Bottleneck Models with Vision-Language Guidance
and 2 more not named here
soft_threshold 5 other papers
5 later · 2 only as an assembly brick
2308.03685 (2023-08)
Learning Concise and Descriptive Attributes for Visual Recognition
2405.06855 (2024-05)
Linear Explanations for Individual Neurons
2408.01432 (2024-08)
VLG-CBM: Training Concept Bottleneck Models with Vision-Language Guidance
and 2 more not named here
add_index_to_dataloader 2 other papers
2 later
2408.01432 (2024-08)
VLG-CBM: Training Concept Bottleneck Models with Vision-Language Guidance
2604.14519 (2026-04)
CI-CBM: Class-Incremental Concept Bottleneck Model for Interpretable Continual Learning

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 show how fitting sparse linear models over learned deep feature representations can lead to more debuggable neural networks. These networks remain highly accurate while also being more amenable to human interpretation, as we demonstrate quantiatively via numerical and human experiments. We further illustrate how the resulting sparse explanations can help to identify spurious correlations, explain misclassifications, and diagnose model biases in vision and language tasks. The code for our toolkit can be found at https://github.com/madrylab/debuggabledeepnetworks.

For agents

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

get_harvested_code_for_paper("2105.04857")
get_code_for_paper("2105.04857")
have("2105.04857")

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

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

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

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

Connect an agent — have() is free.