SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 2206.12917 · ICML · 2022

TAM: Topology-Aware Margin Loss for Class-Imbalanced Node Classification

Eunho Yang, Jaeyun Song, Joonhyung Park

arXiv · PDF · Open in the Atlas

Code that ran

3 of 3 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, 0 violated it and 0 have no contract verdict; 3 failures of our instrument; 0 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/2206.12917.json · badge: /api/ran/2206.12917.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
Jaeyun-Song/TAM canonical (classifier label)
classifier basis: classifier_2025
3 ran · 0 no recorded run
FunctionStatusWhere it lives
adjust_output Ran
ran; our contract draft was wrong, not the code
Jaeyun-Song/TAM/models/tam.py
code served (permissive licence) · get_code("5d9da09044265254")
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 Tensor, ndim 2, dtype family float, shape (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
import torch.nn as nn
import torch.nn.functional as F

torch.manual_seed(0)

# Create a minimal aggregator that takes (agg_out, edge_index) and returns aggregated output
class MinimalAggregator(nn.Module):
    def forward(self, agg_out, edge_index):
        # agg_out: [num_nodes, num_classes]
        # edge_index: [2, num_edges]
        # Return aggregated distribution for each node
        num_nodes = agg_out.shape[0]
        num_classes = agg_out.shape[1]
        
        # Simple aggregation: average neighbor features
        aggregated = agg_out.clone()
        
        # For each edge, accumulate neighbor info
        for i in range(edge_index.shape[1]):
            src, dst = edge_index[0, i].item(), edge_index[1, i].item()
            aggregated[dst] = aggregated[dst] + agg_out[src]
        
        # Normalize
        aggregated = aggregated / (aggregated.sum(dim=1, keepdim=True) + 1e-8)
        return aggregated

# Create minimal args config
class Args:
    def __init__(self):
        self.tam = True
        self.warmup = 0
        self.temp_phi = 0.5
        self.tam_alpha = 0.1
        self.tam_beta = 0.1

# Setup tensors and data
num_nodes = 8
num_classes = 3
num_edges = 10

# output: model predictions [num_nodes, num_classes]
output = torch.randn(num_nodes, num_classes)

# edge_index: [2, num_edges]
edge_index = torch.randint(0, num_nodes, (2, num_edges))

# label: [num_nodes]
label = torch.randint(0, num_classes, (num_nodes,))

# train_mask: [num_nodes]
train_mask = torch.tensor([True, True, True, True, False, False, False, False])

# aggregator: callable that takes (agg_out, edge_index)
aggregator = MinimalAggregator()

# class_num_list: number of samples per class
class_num_list = [3, 3, 2]

# epoch: integer
epoch = 5

# args: configuration object
args = Args()

ARGS = {
    "args": args,
    "output": output,
    "edge_index": edge_index,
    "label": label,
    "train_mask": train_mask,
    "aggregator": aggregator,
    "class_num_list": class_num_list,
    "epoch": epoch,
}
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 Tensor, ndim 2, dtype family float, shape (4, 3) — shape (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
compute_jsd Ran
ran; our contract draft was wrong, not the code
Jaeyun-Song/TAM/models/tam.py
code served (permissive licence) · get_code("654ddc7776540043")
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 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.functional as F

torch.manual_seed(0)

# Create two probability distributions as tensors
# Shape: (batch_size=2, num_classes=4)
# These should be valid probability distributions (sum to 1 along last dim)
dist1 = torch.tensor([
    [0.1, 0.2, 0.3, 0.4],
    [0.25, 0.25, 0.25, 0.25]
], dtype=torch.float32)

dist2 = torch.tensor([
    [0.2, 0.3, 0.2, 0.3],
    [0.1, 0.4, 0.3, 0.2]
], dtype=torch.float32)

ARGS = {
    "dist1": dist1,
    "dist2": dist2
}
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 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
compute_tam Ran
ran; our contract draft was wrong, not the code
Jaeyun-Song/TAM/models/tam.py
code served (permissive licence) · get_code("bb2828903fad2499")
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 tuple, ndim 3, 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
import torch.nn.functional as F

torch.manual_seed(0)

# Create a simple aggregator that takes (features, edge_index) and returns aggregated features
class SimpleAggregator(nn.Module):
    def forward(self, x, edge_index):
        # x: [num_nodes, num_classes]
        # edge_index: [2, num_edges]
        # Return aggregated output of same shape as x
        num_nodes = x.shape[0]
        num_classes = x.shape[1]
        # Simple mean aggregation - just return x repeated for all nodes
        return x.unsqueeze(0).expand(num_nodes, -1, -1).mean(dim=1)

# Set up small tensors
num_nodes = 6
num_classes = 3
num_features = 4

# output: logits for each node across classes
output = torch.randn(num_nodes, num_classes)

# edge_index: sparse representation of edges
edge_index = torch.tensor([
    [0, 1, 2, 3, 4, 5],
    [1, 2, 3, 4, 5, 0]
], dtype=torch.long)

# label: class label for each node
label = torch.tensor([0, 1, 2, 0, 1, 2], dtype=torch.long)

# train_mask: boolean mask for training nodes
train_mask = torch.tensor([True, True, True, False, False, False], dtype=torch.bool)

# aggregator: neural network module
aggregator = SimpleAggregator()

# class_num_list: number of samples per class
class_num_list = [2, 2, 2]

# temp_phi: temperature parameter phi
temp_phi = 1.0

# temp_gamma: temperature parameter gamma
temp_gamma = 0.5

ARGS = {
    "output": output,
    "edge_index": edge_index,
    "label": label,
    "train_mask": train_mask,
    "aggregator": aggregator,
    "class_num_list": class_num_list,
    "temp_phi": temp_phi,
    "temp_gamma": temp_gamma,
}
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 tuple, ndim 3, 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

Also present in other papers' code

Of 3 samples lifted from this paper's linked repositories, 3 carry a function identity and 0 do not. Of the 3 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 3 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

Learning unbiased node representations under class-imbalanced graph data is challenging due to interactions between adjacent nodes. Existing studies have in common that they compensate the minor class nodes 'as a group' according to their overall quantity (ignoring node connections in graph), which inevitably increase the false positive cases for major nodes. We hypothesize that the increase in these false positive cases is highly affected by the label distribution around each node and confirm it experimentally. In addition, in order to handle this issue, we propose Topology-Aware Margin (TAM) to reflect local topology on the learning objective. Our method compares the connectivity pattern of each node with the classaveraged counter-part and adaptively adjusts the margin accordingly based on that. Our method consistently exhibits superiority over the baselines on various node classification benchmark datasets with representative GNN architectures.

For agents

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

get_harvested_code_for_paper("2206.12917")
get_code_for_paper("2206.12917")
have("2206.12917")

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

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

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

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

Connect an agent — have() is free.