SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 2401.03230 · AAAI · 2024

FedTGP: Trainable Global Prototypes with Adaptive-Margin-Enhanced Contrastive Learning for Data and Model Heterogeneity in Federated Learning

Yang Liu, Jian Cao, Yang Hua, Jianqing Zhang

arXiv · PDF · Open in the Atlas

Code that ran

3 of 8 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; 0 honoured the contract we drafted, 0 violated it and 1 has no contract verdict; 2 failures of our instrument; 5 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/2401.03230.json · badge: /api/ran/2401.03230.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
tsingz0/fedtgp community
Papers with Code archive
3 ran · 5 no recorded run
FunctionStatusWhere it lives
Trainable_Global_Prototypes Ran
ran on a synthesized input · constructed an object; no result was computed
tsingz0/fedtgp/system/flcore/servers/servertgp.py
code served (permissive licence) · get_code("ac1be2fc541bc784")
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, Trainable_Global_Prototypes: 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 = {
    "num_classes": 5,
    "server_hidden_dim": 8,
    "feature_dim": 4,
    "device": torch.device("cpu")
}
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 Trainable_Global_Prototypes — 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 Trainable_Global_Prototypes 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
agg_func Ran
ran; our contract draft was wrong, not the code
tsingz0/fedtgp/system/flcore/servers/servertgp.py
code served (permissive licence) · get_code("34ebb1820a560b2b")
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 torch
import torch.nn as nn

torch.manual_seed(0)

# Construct a protos dictionary with labels as keys and lists of tensors as values
# The function expects each value to be a list of objects with a .data attribute
# We'll use simple tensors which have a .data attribute

proto_tensor_1 = torch.tensor([[1.0, 2.0, 3.0, 4.0], [5.0, 6.0, 7.0, 8.0]])
proto_tensor_2 = torch.tensor([[2.0, 3.0, 4.0, 5.0], [6.0, 7.0, 8.0, 9.0]])
proto_tensor_3 = torch.tensor([[3.0, 4.0, 5.0, 6.0], [7.0, 8.0, 9.0, 10.0]])
proto_tensor_4 = torch.tensor([[1.5, 2.5, 3.5, 4.5], [5.5, 6.5, 7.5, 8.5]])

protos = {
    0: [proto_tensor_1, proto_tensor_2, proto_tensor_3],  # Multiple protos for label 0
    1: [proto_tensor_4]  # Single proto for label 1
}

ARGS = {
    "protos": protos
}
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 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
proto_cluster Ran
ran; our contract draft was wrong, not the code
tsingz0/fedtgp/system/flcore/servers/servertgp.py
code served (permissive licence) · get_code("130f1778fd817237")
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 defaultdict. 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
from collections import defaultdict

torch.manual_seed(0)

# Create sample prototypes
# Each proto is a dict with string keys and tensor values
proto1 = {
    'class_0': torch.randn(4),
    'class_1': torch.randn(4),
}

proto2 = {
    'class_0': torch.randn(4),
    'class_1': torch.randn(4),
}

proto3 = {
    'class_0': torch.randn(4),
    'class_1': torch.randn(4),
}

# protos_list is a list of such dicts
protos_list = [proto1, proto2, proto3]

ARGS = {
    'protos_list': protos_list
}
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 defaultdict — a defaultdict output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a defaultdict 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
BaseHeadSplit Not yet run
unverified (harvested, no recorded run)
tsingz0/fedtgp/system/flcore/servers/servertgp.py
code served (permissive licence) · get_code("9cffef012e449576")
How it ran

no invocation recorded.

Client Not yet run
unverified (harvested, no recorded run)
tsingz0/fedtgp/system/flcore/servers/servertgp.py
code served (permissive licence) · get_code("42de4e65658e7ceb")
How it ran

no invocation recorded.

FedTGP Not yet run
unverified (harvested, no recorded run)
tsingz0/fedtgp/system/flcore/servers/servertgp.py
code served (permissive licence) · get_code("e3b929e7aa0f98ff")
How it ran

no invocation recorded.

Server Not yet run
unverified (harvested, no recorded run)
tsingz0/fedtgp/system/flcore/servers/servertgp.py
code served (permissive licence) · get_code("03bdd9abb57b35ce")
How it ran

no invocation recorded.

clientTGP Not yet run
unverified (harvested, no recorded run)
tsingz0/fedtgp/system/flcore/servers/servertgp.py
code served (permissive licence) · get_code("a36d77b5524b396c")
How it ran

no invocation recorded.

Also present in other papers' code

Of 8 samples lifted from this paper's linked repositories, 8 carry a function identity and 0 do not. Of the 8 distinct functions with an identity, 3 are also present in other papers whose code we hold (1 with at least one paper dated earlier, 0 the same month, 2 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
agg_func
brick of this paper's assembly: helper
3 other papers
3 dated earlier
2209.10083 (2022-09)
Federated Learning from Pre-Trained Models: A Contrastive Learning Approach
2211.01572 (2022-11)
FedTP: Federated Learning by Transformer Personalization
2312.04992 (2023-12)
PFLlib: A Beginner-Friendly and Comprehensive Personalized Federated Learning Library and Benchmark
Client
brick of this paper's assembly: helper
1 other paper
1 later
2403.15760 (2024-03)
An Upload-Efficient Scheme for Transferring Knowledge From a Server-Side Pre-trained Generator to Clients in Heterogeneous Federated Learning
Server
brick of this paper's assembly: helper
1 other paper
1 later
2403.15760 (2024-03)
An Upload-Efficient Scheme for Transferring Knowledge From a Server-Side Pre-trained Generator to Clients in Heterogeneous Federated 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

Recently, Heterogeneous Federated Learning (HtFL) has attracted attention due to its ability to support heterogeneous models and data. To reduce the high communication cost of transmitting model parameters, a major challenge in HtFL, prototype-based HtFL methods are proposed to solely share class representatives, a.k.a, prototypes, among heterogeneous clients while maintaining the privacy of clients' models. However, these prototypes are naively aggregated into global prototypes on the server using weighted averaging, resulting in suboptimal global knowledge which negatively impacts the performance of clients. To overcome this challenge, we introduce a novel HtFL approach called FedTGP, which leverages our Adaptive-margin-enhanced Contrastive Learning (ACL) to learn Trainable Global Prototypes (TGP) on the server. By incorporating ACL, our approach enhances prototype separability while preserving semantic meaning. Extensive experiments with twelve heterogeneous models demonstrate that our FedTGP surpasses state-of-the-art methods by up to 9.08% in accuracy while maintaining the communication and privacy advantages of prototype-based HtFL. Our code is available at https://github.com/TsingZ0/FedTGP.

For agents

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

get_harvested_code_for_paper("2401.03230")
get_code_for_paper("2401.03230")
have("2401.03230")

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

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

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

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

Connect an agent — have() is free.