SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 2211.03064 · 2022

ViT-CX: Causal Explanation of Vision Transformers

arXiv · PDF · Open in the Atlas

Code that ran

9 of 9 samples (functions and classes) lifted from this paper's linked repositories executed on a synthesized input in Syntology's jail (0 of them constructed an object rather than computing a result; 0 honoured the contract we drafted, 2 violated it and 7 have no contract verdict; 0 failures of our instrument; 0 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/2211.03064.json · badge: /api/ran/2211.03064.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
vaynexie/CausalX-ViT canonical (classifier label)
classifier basis not recorded on the link
9 ran · 0 no recorded run
FunctionStatusWhere it lives
deprocess_image Ran
ran, violated the contract we drafted
vaynexie/CausalX-ViT/ViT_CX/cam/utils/image.py
pointer only (licence: CC0-1.0); the stored copy get_code serves, from yaleCat/Grad-CAM-pytorch, is pointer only (licence: NONE) · get_code("672d3d84a89bbafa")
How it ran

The body of this sample is withheld: this paper's link allows the body inline (CC0-1.0), but get_code serves the stored copy, first harvested from yaleCat/Grad-CAM-pytorch, 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.

find_layer_predicate_recursive Ran
ran on a synthesized input
vaynexie/CausalX-ViT/ViT_CX/cam/utils/find_layers.py
code served (permissive licence) · get_code("383600edf86e6da6")
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
import torch.nn as nn

torch.manual_seed(0)

# Build a simple nested model structure
class SimpleBlock(nn.Module):
    def __init__(self):
        super().__init__()
        self.linear = nn.Linear(4, 3)
        self.relu = nn.ReLU()
    
    def forward(self, x):
        return self.relu(self.linear(x))

class NestedModel(nn.Module):
    def __init__(self):
        super().__init__()
        self.block1 = SimpleBlock()
        self.block2 = SimpleBlock()
        self.conv = nn.Conv1d(4, 3, kernel_size=1)
    
    def forward(self, x):
        return self.block2(self.block1(x))

model = NestedModel()

# Define a predicate function that checks if a layer is a Linear layer
predicate = lambda layer: isinstance(layer, nn.Linear)

ARGS = {
    "model": model,
    "predicate": predicate
}
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
find_layer_types_recursive Ran
ran on a synthesized input
vaynexie/CausalX-ViT/ViT_CX/cam/utils/find_layers.py
code served (permissive licence) · get_code("401af4c8ee982ca6")
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
import torch.nn as nn

torch.manual_seed(0)

# Build a model with nested structure containing various layer types
class SimpleModel(nn.Module):
    def __init__(self):
        super().__init__()
        self.linear1 = nn.Linear(4, 3)
        self.relu = nn.ReLU()
        self.linear2 = nn.Linear(3, 2)
        self.conv = nn.Conv1d(3, 2, 1)
        self.nested = nn.Sequential(
            nn.Linear(2, 4),
            nn.ReLU(),
            nn.Linear(4, 2)
        )

model = SimpleModel()

# Define layer types to search for
layer_types = [nn.Linear, nn.ReLU]

ARGS = {
    "model": model,
    "layer_types": layer_types
}
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
get_cos_similar_matrix Ran
ran on a synthesized input
vaynexie/CausalX-ViT/ViT_CX/ViT_CX.py
code served (permissive licence) · get_code("9da12373ae640999")
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, 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 two tensors for computing cosine similarity
# v1: shape (2, 4) - 2 vectors of dimension 4
# v2: shape (3, 4) - 3 vectors of dimension 4
v1 = torch.randn(2, 4)
v2 = torch.randn(3, 4)

ARGS = {
    "v1": v1,
    "v2": v2,
}
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 (2, 3) — shape (2, 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
norm_matrix Ran
ran on a synthesized input
vaynexie/CausalX-ViT/ViT_CX/ViT_CX.py
code served (permissive licence) · get_code("1bf4c39bc534e65c")
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

torch.manual_seed(0)

# Create a small activation tensor: shape (batch=2, features=4)
# The function uses torch.min and torch.max on dimension 1,
# so we need at least 2 rows and some columns
act = torch.randn(2, 4)

ARGS = {
    "act": act
}
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 (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
preprocess_image Ran
ran on a synthesized input
vaynexie/CausalX-ViT/ViT_CX/cam/utils/image.py
code served (permissive licence) · get_code("d5db1adaf17e9890")
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 (1, 3, 4, 6) 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 numpy as np
import torch
from torchvision.transforms import Compose, Normalize, ToTensor

torch.manual_seed(0)

# Create a small test image as numpy array (H, W, C format)
# Using shape (4, 6, 3) for height=4, width=6, channels=3
test_image = np.random.randint(0, 256, size=(4, 6, 3), dtype=np.uint8)

ARGS = {
    "img": test_image,
    "mean": [0.5, 0.5, 0.5],
    "std": [0.5, 0.5, 0.5],
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
numpy, torch, torchvision — 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 (1, 3, 4, 6) — shape (1, 3, 4, 6) 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
replace_layer_recursive Ran
ran, violated the contract we drafted
vaynexie/CausalX-ViT/ViT_CX/cam/utils/find_layers.py
pointer only (licence: CC0-1.0); the stored copy get_code serves, from ryanlyang/LearningToLook, is pointer only (licence: NONE) · get_code("a112dc051428bbc2")
How it ran

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

reshape_function_vit Ran
ran on a synthesized input
vaynexie/CausalX-ViT/ViT_CX/ViT_CX.py
code served (permissive licence) · get_code("c2cd700d59efd9ed")
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, 4, 14, 14) 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

torch.manual_seed(0)

# The function expects:
# - tensor: a 3D tensor with shape (batch_size, num_tokens, channels)
#   where num_tokens should be height*width + 1 (the +1 is for the class token)
# - height: spatial height (default 14)
# - width: spatial width (default 14)

batch_size = 2
height = 14
width = 14
channels = 4

# Create a tensor with shape (batch_size, height*width + 1, channels)
# The +1 accounts for the class token that gets sliced off with [:, 1:, :]
num_tokens = height * width + 1
tensor = torch.randn(batch_size, num_tokens, channels)

ARGS = {
    "tensor": tensor,
    "height": height,
    "width": width,
}
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, 4, 14, 14) — shape (2, 4, 14, 14) 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
show_cam_on_image Ran
ran on a synthesized input
vaynexie/CausalX-ViT/ViT_CX/cam/utils/image.py
code served (permissive licence) · get_code("4dab890a3ffb1e99")
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 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 cv2
import numpy as np

# Create a small base image in RGB format with values in [0, 1]
# Shape: (4, 3, 3) for height=4, width=3, channels=3
img = np.random.rand(4, 3, 3).astype(np.float32)

# Create a small mask with values in [0, 1]
# Shape: (4, 3) matching the spatial dimensions of the image
mask = np.random.rand(4, 3).astype(np.float32)

# Define arguments dictionary
ARGS = {
    'img': img,
    'mask': mask,
    'use_rgb': True,
    'colormap': cv2.COLORMAP_JET
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
cv2, numpy — 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 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

Also present in other papers' code

Of 9 samples lifted from this paper's linked repositories, 9 carry a function identity and 0 do not. Of the 9 distinct functions with an identity, 2 are also present in other papers whose code we hold (2 with at least one paper dated earlier, 0 the same month, 1 later) and 7 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
replace_layer_recursive 5 other papers
1 dated earlier, 4 later
2204.02426 (2022-04)
OccamNets: Mitigating Dataset Bias by Favoring Simpler Hypotheses Robik Shrestha 1[0000-0002-0945-3458] , Kushal Kafle 2[0000-0002-0847-7861] , and
Lin_CLIP_Is_Also_an_Efficient_Segmenter_A_Text-Driven_Approach_for_CVPR_2023_paper (2023 (year only))
CLIP is Also an Efficient Segmenter: A Text-Driven Approach for Weakly Supervised Semantic Segmentation
2406.11189 (2024-06)
Frozen CLIP: A Strong Backbone for Weakly Supervised Semantic Segmentation
and 2 more not named here
deprocess_image 1 other paper
1 dated earlier
1610.02391 (2016-10)
Grad-CAM: Visual Explanations from Deep Networks via Gradient-based Localization

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

Despite the popularity of Vision Transformers (ViTs) and eXplainable AI (XAI), only a few explanation methods have been designed specially for ViTs thus far. They mostly use attention weights of the [CLS] token on patch embeddings and often produce unsatisfactory saliency maps. This paper proposes a novel method for explaining ViTs called ViT-CX. It is based on patch embeddings, rather than attentions paid to them, and their causal impacts on the model output. Other characteristics of ViTs such as causal overdetermination are also considered in the design of ViT-CX. The empirical results show that ViT-CX produces more meaningful saliency maps and does a better job revealing all important evidence for the predictions than previous methods. The explanation generated by ViT-CX also shows significantly better faithfulness to the model. The codes and appendix are available at https://github.com/vaynexie/CausalX-ViT.

For agents

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

get_harvested_code_for_paper("2211.03064")
get_code_for_paper("2211.03064")
have("2211.03064")

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

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

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

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

Connect an agent — have() is free.