SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 2104.02297 · ICLR · 2021

Shapley Explanation Networks

Rui Wang, Xiaoqian Wang, David Inouye

arXiv · PDF · Open in the Atlas

Code that ran

10 of 14 samples (functions and classes) lifted from this paper's linked repositories executed on a synthesized input in Syntology's jail (1 of them constructed an object rather than computing a result; 6 honoured the contract we drafted, 0 violated it and 1 has no contract verdict; 3 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/2104.02297.json · badge: /api/ran/2104.02297.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
inouye-lab/ShapleyExplanationNetworks canonical (classifier label)
classifier basis: census
8 ran · 0 no recorded run
inouye-lab/shapleyexplanationnetworks canonical (classifier label)
classifier basis: classifier_2025
1 ran · 2 no recorded run
RuiWang1998/ShapleyExplanationNetworks marked official in Papers with Code
Papers with Code archive
1 ran · 2 no recorded run
FunctionStatusWhere it lives
ModuleDimensions Ran
ran on a synthesized input · constructed an object; no result was computed
RuiWang1998/ShapleyExplanationNetworks/ShapNet/basic.py
code served (permissive licence) · get_code("52922940053de0b8")
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, ModuleDimensions: 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 = {
    "features": 5,
    "in_channel": 3,
    "out_channel": 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 ModuleDimensions — the run constructed an instance of its own class and did not call it; no shape is stated — the instrument coerces any output to an array; for a ModuleDimensions 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_dim Ran
ran; our contract draft was wrong, not the code
inouye-lab/ShapleyExplanationNetworks/ShapNet/utils/named_tensor_utils/private_methods.py
code served (permissive licence) · get_code("2ef7e6b2837fc1b1")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned Tensor, ndim 4, dtype family float, shape (2, 1, 4, 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 torch

torch.manual_seed(0)

# Create a small tensor with distinct dimensions
tensor = torch.randn(2, 4, 3)

# Define the index at which to unsqueeze
index = 1

# Construct the ARGS dictionary with all parameters
ARGS = {
    "tensor": tensor,
    "index": index,
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type Tensor, ndim 4, dtype family float, shape (2, 1, 4, 3) — shape (2, 1, 4, 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
dummy Ran
ran, honoured the contract we drafted
inouye-lab/ShapleyExplanationNetworks/ShapNet/utils/named_tensor_utils/private_methods.py
code served (permissive licence) · get_code("8fba73b4ca872986")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned Tensor, ndim 2, dtype family float, shape (2, 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 as nn
import numpy as np

torch.manual_seed(0)

# The dummy function simply returns the first argument 'any'
# So we need to provide valid arguments for: any, *args, **kwargs

# Create some example objects for the 'any' parameter
sample_tensor = torch.randn(2, 4)
sample_list = [1, 2, 3]
sample_dict = {"key": "value"}
sample_string = "test"

# Define ARGS - mapping all parameters
ARGS = {
    "any": sample_tensor,
    "args": (sample_list, sample_dict, sample_string),
    "kwargs": {"param1": 42, "param2": "extra"}
}
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 Tensor, 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
flatten Ran
ran, honoured the contract we drafted
inouye-lab/shapleyexplanationnetworks/ShapNet/utils/utils.py
code served (permissive licence) · get_code("232d06cae3a687fa")
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
from typing import Any, List

torch.manual_seed(0)

def _place_holder(x: Any):
    """
    Whatever in, whatever out

    Args:
        x ():

    Returns:

    """
    return x

def custom_function(item):
    """A simple callable that processes items"""
    return item * 2 if isinstance(item, int) else item

# Construct arguments for flatten function
x = [
    [1, 2, 3],
    [4, 5],
    [6, 7, 8, 9]
]

function = custom_function

ARGS = {
    "x": x,
    "function": function
}
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
flatten Ran
ran, honoured the contract we drafted
inouye-lab/ShapleyExplanationNetworks/ShapNet/utils/utils.py
code served (permissive licence) · get_code("560e72cd468e68b6")
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 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
import torch.nn as nn
from typing import Any, List

torch.manual_seed(0)

def _place_holder(x: Any):
    """
    Whatever in, whatever out

    Args:
        x ():

    Returns:

    """
    return x

def flatten(x: List[List[Any]], function: callable=_place_holder) -> List[Any]:
    """

    Args:
        x ():
        function ():

    Returns:

    """
    return [function(item) for sublist in x for item in sublist]


# Define test arguments
test_nested_list = [
    [1, 2, 3],
    [4, 5],
    [6, 7, 8, 9]
]

def custom_function(x: Any) -> Any:
    """A simple custom function that processes items"""
    if isinstance(x, int):
        return x * 2
    return x

ARGS = {
    "x": test_nested_list,
    "function": custom_function
}
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 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
generate_binary_sequence Ran
ran, honoured the contract we drafted
inouye-lab/ShapleyExplanationNetworks/ShapNet/utils/utils.py
code served (permissive licence) · get_code("47dfd51a1374d4a7")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned Tensor, ndim 3, dtype family float, shape (8, 3, 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 torch

torch.manual_seed(0)

# The function takes a single parameter 'size' which specifies the target size
# of binary sequences to generate. It should be a small integer.
# Looking at the function body, it expects an integer that determines the
# dimensionality of the output sequences.

size = 3

ARGS = {
    "size": size
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type Tensor, ndim 3, dtype family float, shape (8, 3, 1) — shape (8, 3, 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
get_indices Ran
ran, honoured the contract we drafted
inouye-lab/ShapleyExplanationNetworks/ShapNet/utils/utils.py
code served (permissive licence) · get_code("01d54ad12f5dbdf6")
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 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
import numpy as np

# Set random seed for reproducibility
torch.manual_seed(0)

# Construct valid arguments for get_indices function
# The function takes three integer parameters:
# - total_num: the index of stages as of now
# - index_of_interest: the index of the test_module
# - index_in_index: the index inside the index of interest

# Based on the function logic, we need:
# - total_num > index_of_interest (so that remainder is positive)
# - index_of_interest >= 0
# - index_in_index >= 0

ARGS = {
    "total_num": 5,
    "index_of_interest": 2,
    "index_in_index": 3
}
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 int — 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
name_insert Ran
ran; our contract draft was wrong, not the code
inouye-lab/ShapleyExplanationNetworks/ShapNet/utils/named_tensor_utils/private_methods.py
code served (permissive licence) · get_code("9b548cdd3c3d9cc7")
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 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
from typing import Tuple, List

TensorName = str

# Define ARGS with all parameters for name_insert
ARGS = {
    "names": ("tensor_a", "tensor_b", "tensor_c"),
    "index": 1,
    "name": "tensor_d",
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type list, ndim 1, 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
named_tensor_repeat Ran
ran; our contract draft was wrong, not the code
inouye-lab/ShapleyExplanationNetworks/ShapNet/utils/named_tensor_utils/public_methods.py
code served (permissive licence) · get_code("2345dd4967497bd9")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned Tensor, ndim 2, dtype family float, shape (4, 12) as a later run recorded it. The image it ran in was not recorded. If your copy returns the same type, ndim and shape on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import torch

torch.manual_seed(0)

# Create a named tensor with dimension names
# The function will rename it, repeat it, and refine the names back
tensor = torch.randn(2, 4, names=('batch', 'features'))

# repeat_dims specifies how many times to repeat each dimension
# For a 2D tensor, we need 2 repeat factors
repeat_dims = [2, 3]

ARGS = {
    'tensor': tensor,
    'repeat_dims': repeat_dims
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type Tensor, ndim 2, dtype family float, shape (4, 12) — shape (4, 12) 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
process_list_sizes Ran
ran, honoured the contract we drafted
inouye-lab/ShapleyExplanationNetworks/ShapNet/utils/dims.py
code served (permissive licence) · get_code("d6d3b9c0e1800573")
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 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
import numpy as np
from typing import List, Tuple

torch.manual_seed(0)

# Construct test arguments for process_list_sizes
list_sizes = [
    5,                          # single int element
    (3, 7),                     # tuple element
    2,                          # another single int
    (4, 6),                     # another tuple
    8                           # final single int
]

ARGS = {
    "list_sizes": list_sizes
}
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 list, ndim 2, 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
ListModuleDimensions Not yet run
unverified (harvested, no recorded run)
RuiWang1998/ShapleyExplanationNetworks/ShapNet/basic.py
code served (permissive licence) · get_code("228afffadc4be04b")
How it ran

no invocation recorded.

ShapleyNetwork Not yet run
unverified (harvested, no recorded run)
RuiWang1998/ShapleyExplanationNetworks/ShapNet/basic.py
code served (permissive licence) · get_code("0f6e67b66b326c49")
How it ran

no invocation recorded.

generate_binary_sequence Not yet run
unverified (harvested, no recorded run)
inouye-lab/shapleyexplanationnetworks/ShapNet/utils/utils.py
code served (permissive licence) · get_code("be730864b4b20fd3")
How it ran

no invocation recorded. this sample carries JSON test cases instead of a setup block; get_reference_implementation serves them with the level they back.

get_indices Not yet run
unverified (harvested, no recorded run)
inouye-lab/shapleyexplanationnetworks/ShapNet/utils/utils.py
code served (permissive licence) · get_code("9061c823a930b004")
How it ran

no invocation recorded. this sample carries JSON test cases instead of a setup block; get_reference_implementation serves them with the level they back.

Also present in other papers' code

Of 14 samples lifted from this paper's linked repositories, 14 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-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

Shapley values have become one of the most popular feature attribution explanation methods. However, most prior work has focused on post-hoc Shapley explanations, which can be computationally demanding due to its exponential time complexity and preclude model regularization based on Shapley explanations during training. Thus, we propose to incorporate Shapley values themselves as latent representations in deep models-thereby making Shapley explanations first-class citizens in the modeling paradigm. This intrinsic explanation approach enables layer-wise explanations, explanation regularization of the model during training, and fast explanation computation at test time. We define the Shapley transform that transforms the input into a Shapley representation given a specific function. We operationalize the Shapley transform as a neural network module and construct both shallow and deep networks, called SHAPNETs, by composing Shapley modules. We prove that our Shallow SHAPNETs compute the exact Shapley values and our Deep SHAPNETs maintain the missingness and accuracy properties of Shapley values. We demonstrate on synthetic and real-world datasets that our SHAPNETs enable layer-wise Shapley explanations, novel Shapley regularizations during training, and fast computation while maintaining reasonable performance. Code is available at https: //github.com/inouye-lab/ShapleyExplanationNetworks.

For agents

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

get_harvested_code_for_paper("2104.02297")
get_code_for_paper("2104.02297")
have("2104.02297")

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

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

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

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

Connect an agent — have() is free.