SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 2411.00715 · NeurIPS · 2024

B-cosification: Transforming Deep Neural Networks to be Inherently Interpretable

Bernt Schiele, Moritz Böhle, Shreyash Arya, Sukrut Rao, German Shepherd

arXiv · PDF · Open in the Atlas

Code that ran

12 of 13 samples (functions and classes) lifted from this paper's linked repositories executed on a synthesized input in Syntology's jail (2 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; 9 failures of our instrument; 1 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/2411.00715.json · badge: /api/ran/2411.00715.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
shrebox/b-cosification canonical (classifier label)
classifier basis: census
6 ran · 1 no recorded run
shrebox/B-cosification canonical (classifier label)
classifier basis: classifier_2025
2 ran · 0 no recorded run
b-cos/b-cos-v2 canonical (classifier label)
classifier basis: classifier_2025
1 ran · 0 no recorded run
B-cos/B-cos-v2 community
Papers with Code archive
3 ran · 0 no recorded run
FunctionStatusWhere it lives
BcosConv2d Ran
ran on a synthesized input · constructed an object; no result was computed
B-cos/B-cos-v2/bcos/modules/bcosconv2d.py
code served (permissive licence) · get_code("5f602bc6a50e55cf")
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 an instance of its own class, BcosConv2d: the run constructed the object and did not call it, so no result was computed. 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
import numpy as np

torch.manual_seed(0)

ARGS = {
    'in_channels': 3,
    'out_channels': 16,
    'kernel_size': 3,
    'stride': 1,
    'padding': 1,
    'dilation': 1,
    'groups': 1,
    'padding_mode': 'zeros',
    'device': None,
    'dtype': None,
    'b': 2,
    'max_out': 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 BcosConv2d — the run constructed an instance of its own class and did not call it; no shape 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
DetachableModule Ran
ran on a synthesized input · constructed an object; no result was computed
B-cos/B-cos-v2/bcos/modules/bcosconv2d.py
code served (permissive licence) · get_code("b0ada584def6e695")
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 an instance of its own class, DetachableModule: the run constructed the object and did not call it, so no result was computed. 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)

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 DetachableModule — the run constructed an instance of its own class and did not call it; no shape 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
NormedConv2d Ran
ran on a synthesized input
B-cos/B-cos-v2/bcos/modules/bcosconv2d.py
code served (permissive licence) · get_code("028ee4573c8560e9")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, class construct-then-call prompt, model not recorded) and returned Tensor, ndim 4, 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 import Tensor

INIT_ARGS = {
    'in_channels': 3,
    'out_channels': 4,
    'kernel_size': 3,
    'stride': 1,
    'padding': 1,
}

ARGS = {
    'in_tensor': torch.randn(2, 3, 8, 8),
}
Setup block drafted by
a language model, class construct-then-call prompt, model not recorded
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 4, dtype family float — no output shape is stated: observe_signature.py observed this class with its constructor sizes canonicalised where it could, which the node does not record, so its shape is not stated as this setup block's
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: torch and numpy seeded to 0 by the harness immediately before the class was constructed from INIT_ARGS (fixture_check.py)
check_correct Ran
ran; the contract check could not run (RAISES, DEP_MISSING or TIMEOUT)
shrebox/B-cosification/evaluate.py
code served (permissive licence) · get_code("d853932b4bc4ddc6")
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) and returned list, ndim 1, dtype family int; 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

torch.manual_seed(0)

# Create output tensor: logits from a model
# Shape: (batch_size=2, num_classes=4)
output = torch.randn(2, 4)

# Create target tensor: class indices
# Shape: (batch_size=2,)
target = torch.tensor([1, 3])

# Define topk parameter
topk = (1, 2)

ARGS = {
    "output": output,
    "target": target,
    "topk": topk,
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1
Imports
torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type list, ndim 1, dtype family int — a list 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
get_inx2label_imagenet Ran
ran; our contract draft was wrong, not the code
shrebox/b-cosification/bcos/common.py
code served (permissive licence) · get_code("0d82d406f3c731b2")
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 str. 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 json
import tempfile
import os

# Create a temporary directory and a mock imagenet_class_index.json file
temp_dir = tempfile.mkdtemp()
data_dir = os.path.join(temp_dir, 'bcos', 'data')
os.makedirs(data_dir, exist_ok=True)

# Create a mock ImageNet class index JSON file
mock_class_index = {
    "0": ["n02119245", "jack_russell"],
    "1": ["n02100735", "english_springer"],
    "2": ["n02110063", "malamute"],
    "3": ["n02096294", "toy_poodle"],
    "4": ["n02099601", "golden_retriever"],
}

class_index_path = os.path.join(data_dir, 'imagenet_class_index.json')
with open(class_index_path, 'w') as f:
    json.dump(mock_class_index, f)

# Change working directory so the relative path works
original_cwd = os.getcwd()
os.chdir(temp_dir)

# Define ARGS with a valid index
ARGS = {
    'index': 0
}
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 str — a str output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a str 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_job_dir Ran
ran; our contract draft was wrong, not the code
shrebox/b-cosification/run_with_submitit.py
code served (permissive licence) · get_code("89fa1815e1d4ec19")
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 str. 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.

class Args:
    def __init__(self):
        self.base_directory = '/tmp/jobs'
        self.dataset = 'mnist'
        self.base_network = 'resnet18'
        self.experiment_name = 'exp001'

ARGS = {'args': 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 str — a str output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a str 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_model_collection_from_file Ran
ran; our contract draft was wrong, not the code
shrebox/b-cosification/CLIP_benchmark/clip_benchmark/model_collection.py
code served (permissive licence) · get_code("e02503f545c31203")
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 list, ndim 2, 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 tempfile
import os

# Create a temporary file with CSV-like content
temp_file = tempfile.NamedTemporaryFile(mode='w', delete=False, suffix='.txt')
temp_file.write("model1,config1,weights1\n")
temp_file.write("model2,config2,weights2\n")
temp_file.write("model3,config3,weights3\n")
temp_file.close()

ARGS = {
    'path': temp_file.name
}
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 list, ndim 2, dtype family float — a list 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
get_parser Ran
ran; our contract draft was wrong, not the code
b-cos/b-cos-v2/evaluate.py
code served (permissive licence) · get_code("d86a09dbbd222a92")
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) and returned ArgumentParser. 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 argparse
from pathlib import Path

torch.manual_seed(0)

# The function get_parser only takes one argument: add_help
# It doesn't actually use any complex objects - it just builds an ArgumentParser
# So we only need to provide the add_help parameter

ARGS = {
    'add_help': True
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1
Imports
torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type ArgumentParser — a ArgumentParser output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a ArgumentParser 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_parser Ran
ran; our contract draft was wrong, not the code
shrebox/B-cosification/evaluate.py
code served (permissive licence) · get_code("c31ee5b22281c359")
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) and returned ArgumentParser. 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 argparse
from pathlib import Path
import torch
import torch.nn as nn

torch.manual_seed(0)

ARGS = {
    'add_help': True,
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1
Imports
torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type ArgumentParser — a ArgumentParser output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a ArgumentParser 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
gradient_to_image Ran
ran; our contract draft was wrong, not the code
shrebox/b-cosification/bcos/common.py
code served (permissive licence) · get_code("e2769f8e1dd0c387")
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 3, dtype family float, shape (4, 5, 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 torch.nn.functional as F

torch.manual_seed(0)

# Create small tensors with distinct dimensions
# image: [C, H, W] with C=6
C, H, W = 6, 4, 5
image = torch.randn(C, H, W)

# linear_mapping: [C, H, W] same shape as image
linear_mapping = torch.randn(C, H, W)

# smooth: kernel size for smoothing
smooth = 3

# alpha_percentile: cut-off percentile in range [0, 100]
alpha_percentile = 99.5

# return_contribs: boolean flag
return_contribs = False

ARGS = {
    "image": image,
    "linear_mapping": linear_mapping,
    "smooth": smooth,
    "alpha_percentile": alpha_percentile,
    "return_contribs": return_contribs,
}
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 ndarray, ndim 3, dtype family float, shape (4, 5, 4) — shape (4, 5, 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
plot_contribution_map Ran
ran; the contract check could not run (RAISES, DEP_MISSING or TIMEOUT)
shrebox/b-cosification/bcos/common.py
code served (permissive licence) · get_code("5c8bce000c76fd22")
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 numpy as np
import matplotlib.pyplot as plt

torch.manual_seed(0)

# Create a small 2D contribution map (4x3 for distinct dimensions)
contribution_map = torch.randn(4, 3)

# Create a matplotlib axis
fig, ax = plt.subplots(1)

ARGS = {
    "contribution_map": contribution_map,
    "ax": ax,
    "vrange": None,
    "vmin": None,
    "vmax": None,
    "hide_ticks": True,
    "cmap": "bwr",
    "percentile": 99.5,
    "class_index": None,
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
matplotlib, 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
register Ran
ran; our contract draft was wrong, not the code
shrebox/b-cosification/bcos/models/pretrained.py
code served (permissive licence) · get_code("bd478142f31f9d59")
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. 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
from typing import Callable

torch.manual_seed(0)

# Create a simple entrypoint function to pass as argument
def simple_model_entrypoint() -> nn.Module:
    """A simple entrypoint function that returns a small nn.Module."""
    return nn.Linear(4, 3)

# The register function expects a Callable that returns torch.nn.Module
# Based on the function body, it:
# 1. Accesses entrypoint_fn.__name__ to get the function name
# 2. Stores it in the registry dict
# 3. Appends to __all__
# 4. Returns the function unchanged

ARGS = {
    'entrypoint_fn': simple_model_entrypoint
}
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
build_model Not yet run
unverified (harvested, no recorded run)
shrebox/b-cosification/CLIP/clip/model.py
code served (permissive licence) · get_code("aedee70f1d728a60")
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 (3 with at least one paper dated earlier, 0 the same month, 1 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_model_collection_from_file 2 other papers
1 dated earlier, 1 later
2309.01859 (2023-09)
NLLB-CLIP -- train performant multilingual image retrieval model on a budget
2507.22264 (2025-07)
SmartCLIP: Modular Vision-language Alignment with Identification Guarantees
check_correct 1 other paper
1 dated earlier
2306.10898 (2023-06)
B-cos Alignment for Inherently Interpretable CNNs and Vision Transformers
get_parser 1 other paper
1 dated earlier
2306.10898 (2023-06)
B-cos Alignment for Inherently Interpretable CNNs and Vision Transformers

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

B-cos Networks have been shown to be effective for obtaining highly human interpretable explanations of model decisions by architecturally enforcing stronger alignment between inputs and weight. B-cos variants of convolutional networks (CNNs) and vision transformers (ViTs), which primarily replace linear layers with B-cos transformations, perform competitively to their respective standard variants while also yielding explanations that are faithful by design. However, it has so far been necessary to train these models from scratch, which is increasingly infeasible in the era of large, pre-trained foundation models. In this work, inspired by the architectural similarities in standard DNNs and B-cos networks, we propose 'Bcosification', a novel approach to transform existing pre-trained models to become inherently interpretable. We perform a thorough study of design choices to perform this conversion, both for convolutional neural networks and vision transformers. We find that B-cosification can yield models that are on par with B-cos models trained from scratch in terms of interpretability, while often outperforming them in terms of classification performance at a fraction of the training cost. Subsequently, we apply B-cosification to a pretrained CLIP model, and show that, even with limited data and compute cost, we obtain a B-cosified version that is highly interpretable and competitive on zero shot performance across a variety of datasets. We release our code and pre-trained model weights at https://github.com/shrebox/B-cosification.

For agents

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

get_harvested_code_for_paper("2411.00715")
get_code_for_paper("2411.00715")
have("2411.00715")

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

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

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

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

Connect an agent — have() is free.