SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 2201.12987 · ICML · 2022

Interpretable and Generalizable Graph Learning via Stochastic Attention Mechanism

Pan Li, Siqi Miao, Miaoyuan Liu

arXiv · PDF · Open in the Atlas

Code that ran

9 of 10 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 4 have no contract verdict; 4 failures of our instrument; 1 no recorded run), measured 2026-11-21; 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/2201.12987.json · badge: /api/ran/2201.12987.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
Graph-COM/GSAT canonical (classifier label)
classifier basis not recorded on the link
9 ran · 1 no recorded run
FunctionStatusWhere it lives
compute_adjacency_matrix_images Ran
ran; the contract check could not run (RAISES, DEP_MISSING or TIMEOUT)
Graph-COM/GSAT/src/datasets/mnist.py
pointer only (licence: MIT); the stored copy get_code serves, from yuelinan/codes-of-c2r, is pointer only (licence: NONE) · get_code("f61cb17009c83363")
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 yuelinan/codes-of-c2r, 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.

eval_one_batch Ran
ran on a synthesized input
Graph-COM/GSAT/src/pretrain_clf.py
code served (permissive licence) · get_code("58d024fc97883157")
How it ran

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

import torch
import torch.nn as nn

torch.manual_seed(0)

class SimpleGNNModel(nn.Module):
    def __init__(self):
        super().__init__()
        self.lin = nn.Linear(4, 2)
    
    def forward(self, x, edge_index=None, edge_attr=None, batch=None):
        return self.lin(x)

class Data:
    def __init__(self):
        self.x = torch.randn(2, 4)
        self.edge_index = torch.tensor([[0, 1], [1, 0]], dtype=torch.long)
        self.edge_attr = torch.randn(2, 3)
        self.batch = torch.tensor([0, 1], dtype=torch.long)
        self.y = torch.tensor([0, 1], dtype=torch.long)

model = SimpleGNNModel()
data = Data()
criterion = nn.CrossEntropyLoss()

ARGS = {
    'data': data,
    'model': model,
    'criterion': criterion,
    'optimizer': None
}
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
get_loaders_and_test_set Ran
ran on a synthesized input
Graph-COM/GSAT/src/utils/get_data_loaders.py
code served (permissive licence) · get_code("1b2c93892e91d26d")
How it ran

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

import torch
import torch_geometric
from torch_geometric.data import Data

torch.manual_seed(0)

# Create small mock graph data objects
def create_mock_graph_data():
    x = torch.randn(5, 4)  # 5 nodes, 4 features
    edge_index = torch.tensor([[0, 1, 2], [1, 2, 3]], dtype=torch.long)
    y = torch.randint(0, 2, (5,))
    return Data(x=x, edge_index=edge_index, y=y)

# Create a mock dataset with indexing and copy capabilities
class MockDataset:
    def __init__(self, data_list):
        self.data_list = data_list
    
    def __getitem__(self, idx):
        if isinstance(idx, list):
            return [self.data_list[i] for i in idx]
        return self.data_list[idx]
    
    def __len__(self):
        return len(self.data_list)
    
    def copy(self, indices):
        if isinstance(indices, list):
            return [self.data_list[i] for i in indices]
        return [self.data_list[indices]]

# Create dataset with 10 graph samples
dataset_list = [create_mock_graph_data() for _ in range(10)]
dataset = MockDataset(dataset_list)

# Create split indices
split_idx = {
    'train': [0, 1, 2, 3, 4],
    'valid': [5, 6, 7],
    'test': [8, 9]
}

# Create dataset splits as lists
dataset_splits = {
    'train': [dataset_list[i] for i in split_idx['train']],
    'valid': [dataset_list[i] for i in split_idx['valid']],
    'test': [dataset_list[i] for i in split_idx['test']]
}

ARGS = {
    'batch_size': 2,
    'dataset': dataset,
    'split_idx': split_idx,
    'dataset_splits': dataset_splits
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
torch, torch_geometric — 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
get_random_split_idx Ran
ran on a synthesized input
Graph-COM/GSAT/src/utils/get_data_loaders.py
code served (permissive licence) · get_code("748ff6aa4827bf6f")
How it ran

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

import numpy as np
import torch
from torch_geometric.data import Data

# Create a minimal dataset-like object
class MinimalDataset:
    def __init__(self, size=10, include_mutag_attrs=False):
        self.size = size
        self.include_mutag_attrs = include_mutag_attrs
    
    def __len__(self):
        return self.size
    
    def __getitem__(self, idx):
        if self.include_mutag_attrs:
            # For mutag_x case: need y and edge_label attributes
            data = Data(x=torch.randn(3, 4))
            data.y = torch.tensor([0])  # Label 0 for some items
            data.edge_label = torch.tensor([1.0, 1.0])  # Non-zero sum
            return data
        else:
            # For normal case: just need basic structure
            return Data(x=torch.randn(3, 4))

# Test case 1: Normal split (not mutag_x)
dataset_normal = MinimalDataset(size=10, include_mutag_attrs=False)
splits_normal = {'train': 0.6, 'valid': 0.2}

# Test case 2: mutag_x split
dataset_mutag = MinimalDataset(size=10, include_mutag_attrs=True)
splits_mutag = {'train': 0.7}

ARGS = {
    'dataset': dataset_normal,
    'splits': splits_normal,
    'random_state': 42,
    'mutag_x': False
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
numpy, torch, torch_geometric — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type dict — a dict output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a dict output the recorded ndim 0 and dtype family float describe that coercion, not the output, and are not stated
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
list_to_torch Ran
ran; our contract draft was wrong, not the code
Graph-COM/GSAT/src/datasets/mnist.py
pointer only (licence: MIT); the stored copy get_code serves, from yuelinan/codes-of-c2r, is pointer only (licence: NONE) · get_code("88a529db78fde884")
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 yuelinan/codes-of-c2r, 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.

read_file Ran
ran, honoured the contract we drafted
Graph-COM/GSAT/src/datasets/graph_sst2.py
pointer only (licence: MIT); the stored copy get_code serves, from sang-woo-seo/pgib, is pointer only (licence: NONE) · get_code("60ccd1c98038811b")
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 sang-woo-seo/pgib, 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.

split Ran
ran; the contract check could not run (RAISES, DEP_MISSING or TIMEOUT)
Graph-COM/GSAT/src/datasets/graph_sst2.py
pointer only (licence: MIT); the stored copy get_code serves, from graphminddartmouth/disgen, is pointer only (licence: NONE) · get_code("fe7d97d9abf11937")
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 graphminddartmouth/disgen, 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.

train_one_batch Ran
ran on a synthesized input
Graph-COM/GSAT/src/pretrain_clf.py
code served (permissive licence) · get_code("7e9b6145faddfc72")
How it ran

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

import torch
import torch.nn as nn
import torch.optim as optim

torch.manual_seed(0)

# Create a simple GNN model that accepts x, edge_index, edge_attr, and batch
class SimpleGNN(nn.Module):
    def __init__(self):
        super().__init__()
        self.linear1 = nn.Linear(4, 8)
        self.linear2 = nn.Linear(8, 3)
    
    def forward(self, x, edge_index, edge_attr, batch):
        # x: [num_nodes, 4]
        # edge_index: [2, num_edges]
        # edge_attr: [num_edges, 5]
        # batch: [num_nodes]
        out = self.linear1(x)
        out = torch.relu(out)
        out = self.linear2(out)
        return out

# Create a simple data object with required attributes
class Data:
    def __init__(self):
        self.x = torch.randn(6, 4)  # 6 nodes, 4 features
        self.edge_index = torch.tensor([[0, 1, 2, 3], [1, 2, 3, 4]], dtype=torch.long)  # 4 edges
        self.edge_attr = torch.randn(4, 5)  # 4 edges, 5 attributes
        self.batch = torch.tensor([0, 0, 0, 1, 1, 1], dtype=torch.long)  # 6 nodes in 2 batches
        self.y = torch.tensor([0, 1, 2, 0, 1, 2], dtype=torch.long)  # 6 labels (for 6 nodes)

# Create instances
model = SimpleGNN()
data = Data()
criterion = nn.CrossEntropyLoss()
optimizer = optim.Adam(model.parameters(), lr=0.001)

ARGS = {
    "data": data,
    "model": model,
    "criterion": criterion,
    "optimizer": optimizer,
}
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
undirected_graph Ran
ran; our contract draft was wrong, not the code
Graph-COM/GSAT/src/datasets/graph_sst2.py
pointer only (licence: MIT); the stored copy get_code serves, from sang-woo-seo/pgib, is pointer only (licence: NONE) · get_code("dde52a0f318548b4")
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 sang-woo-seo/pgib, 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.

read_ba2motif_data Not yet run
unverified (harvested, no recorded run)
Graph-COM/GSAT/src/datasets/ba_2motifs.py
code served (permissive licence) · get_code("04d8e2c1ac682160")
How it ran

no invocation recorded.

Also present in other papers' code

Of 10 samples lifted from this paper's linked repositories, 10 carry a function identity and 0 do not. Of the 10 distinct functions with an identity, 5 are also present in other papers whose code we hold (0 with at least one paper dated earlier, 0 the same month, 5 later) and 5 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
compute_adjacency_matrix_images 3 other papers
3 later
2310.16520 (2023-10)
Towards Self-Interpretable Graph-Level Anomaly Detection
aaai_29103 (2024 (year only))
Rethinking Causal Relationships Learning in Graph Neural Networks
2403.06239 (2024-03)
Cooperative Classification and Rationalization for Graph Generalization
list_to_torch 3 other papers
3 later
2310.16520 (2023-10)
Towards Self-Interpretable Graph-Level Anomaly Detection
aaai_29103 (2024 (year only))
Rethinking Causal Relationships Learning in Graph Neural Networks
2403.06239 (2024-03)
Cooperative Classification and Rationalization for Graph Generalization
read_file 3 other papers
3 later
2310.19906 (2023-10)
Interpretable Prototype-based Graph Information Bottleneck
aaai_29103 (2024 (year only))
Rethinking Causal Relationships Learning in Graph Neural Networks
2406.04601 (2024-06)
Enhancing Size Generalization in Graph Neural Networks through Disentangled Representation Learning
undirected_graph 3 other papers
3 later
2310.19906 (2023-10)
Interpretable Prototype-based Graph Information Bottleneck
aaai_29103 (2024 (year only))
Rethinking Causal Relationships Learning in Graph Neural Networks
2406.04601 (2024-06)
Enhancing Size Generalization in Graph Neural Networks through Disentangled Representation Learning
split 2 other papers
2 later
aaai_29103 (2024 (year only))
Rethinking Causal Relationships Learning in Graph Neural Networks
2406.04601 (2024-06)
Enhancing Size Generalization in Graph Neural Networks through Disentangled Representation 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-21.

Repositories linked to this paper

Some links come from the archived Papers with Code dataset (CC BY-SA 4.0): attribution and licence.

Abstract

Interpretable graph learning is in need as many scientific applications depend on learning models to collect insights from graph-structured data. Previous works mostly focused on using posthoc approaches to interpret pre-trained models (graph neural networks in particular). They argue against inherently interpretable models because the good interpretability of these models is often at the cost of their prediction accuracy. However, those post-hoc methods often fail to provide stable interpretation and may extract features that are spuriously correlated with the task. In this work, we address these issues by proposing Graph Stochastic Attention (GSAT). Derived from the information bottleneck principle, GSAT injects stochasticity to the attention weights to block the information from task-irrelevant graph components while learning stochasticity-reduced attention to select task-relevant subgraphs for interpretation. The selected subgraphs provably do not contain patterns that are spuriously correlated with the task under some assumptions. Extensive experiments on eight datasets show that GSAT outperforms the state-of-the-art methods by up to 20%↑ in interpretation AUC and 5%↑ in prediction accuracy. Our code is available at https: //github.com/Graph-COM/GSAT.

For agents

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

get_harvested_code_for_paper("2201.12987")
get_code_for_paper("2201.12987")
have("2201.12987")

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

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

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

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

Connect an agent — have() is free.