SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 2102.07623 · ICLR · 2021

FedBN: Federated Learning on Non-IID Features via Local Batch Normalization

Michael Kamp, Xiaoxiao Li, Meirui Jiang, Xiaofei Zhang, Qi Dou

arXiv · PDF · Open in the Atlas

Code that ran

7 of 13 samples (functions and classes) lifted from this paper's linked repositories executed on a synthesized input in Syntology's jail (3 of them constructed an object rather than computing a result; 2 honoured the contract we drafted, 0 violated it and 3 have no contract verdict; 2 failures of our instrument; 6 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/2102.07623.json · badge: /api/ran/2102.07623.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
med-air/FedBN canonical (classifier label)
classifier basis: classifier_2025
1 ran · 4 no recorded run
TsingZ0/PFL-Non-IID community
Papers with Code archive
5 ran · 2 no recorded run
adap/flower alias (classifier label)
classifier basis: classifier_2025
1 ran · 0 no recorded run
FunctionStatusWhere it lives
CNNModel Ran
ran on a synthesized input · constructed an object; no result was computed
adap/flower/baselines/fedbn/fedbn/model.py
code served (permissive licence) · get_code("e0e85ded6bac75d2")
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, CNNModel: 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
from torch import nn

torch.manual_seed(0)

ARGS = {
    "num_classes": 10
}
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 CNNModel — 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 CNNModel 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
Client Ran
ran on a synthesized input · constructed an object; no result was computed
TsingZ0/PFL-Non-IID/system/flcore/servers/serverbn.py
code served (permissive licence) · get_code("2bdfc3745f9a344e")
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, Client: 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
import copy

torch.manual_seed(0)

# Create a minimal model
class TinyModel(nn.Module):
    def __init__(self, num_classes=10):
        super(TinyModel, self).__init__()
        self.fc = nn.Linear(4, num_classes)
    
    def forward(self, x):
        if isinstance(x, list):
            x = x[0]
        return self.fc(x)

# Create args object
class Args:
    def __init__(self):
        self.model = TinyModel(num_classes=10)
        self.algorithm = "fedavg"
        self.dataset = "CIFAR10"
        self.device = "cpu"
        self.save_folder_name = "test_save"
        self.num_classes = 10
        self.batch_size = 2
        self.local_learning_rate = 0.01
        self.local_epochs = 1
        self.few_shot = 0
        self.learning_rate_decay_gamma = 0.99
        self.learning_rate_decay = False

args = Args()

ARGS = {
    'args': args,
    'id': 0,
    'train_samples': 10,
    'test_samples': 5,
    'train_slow': False,
    'send_slow': False
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
numpy, sklearn, torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type Client — 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 Client 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
DLG Ran
ran, honoured the contract we drafted
TsingZ0/PFL-Non-IID/system/flcore/servers/serverbn.py
code served (permissive licence) · get_code("29ee58bca6b7aa74")
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 float32, ndim 0, dtype family float, shape () 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)

# Define a small neural network that takes input and produces output
class SimpleNet(nn.Module):
    def __init__(self, input_dim, output_dim):
        super(SimpleNet, self).__init__()
        self.fc1 = nn.Linear(input_dim, 8)
        self.fc2 = nn.Linear(8, output_dim)
    
    def forward(self, x):
        x = torch.relu(self.fc1(x))
        x = self.fc2(x)
        return x

# Create the network
net = SimpleNet(input_dim=4, output_dim=3)

# Create origin_grad: gradients with respect to network parameters
# We need to create a dummy forward pass to generate gradients
dummy_input = torch.randn(2, 4)
dummy_target = torch.randn(2, 3)
criterion = nn.MSELoss()
output = net(dummy_input)
loss = criterion(output, dummy_target)
loss.backward()

# Extract the gradients as origin_grad
origin_grad = [param.grad.clone() for param in net.parameters() if param.grad is not None]

# Zero out gradients for clean state
net.zero_grad()

# Create target_inputs: a list of (gt_data, gt_out) tuples
# gt_data should have shape compatible with net input (batch_size, 4)
# gt_out should have shape compatible with net output (batch_size, 3)
target_inputs = [
    (torch.randn(2, 4), torch.randn(2, 3)),
    (torch.randn(2, 4), torch.randn(2, 3)),
]

ARGS = {
    'net': net,
    'origin_grad': origin_grad,
    'target_inputs': target_inputs,
}
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 float32, ndim 0, dtype family float, shape () — shape () 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
clientBN Ran
ran on a synthesized input · constructed an object; no result was computed
TsingZ0/PFL-Non-IID/system/flcore/servers/serverbn.py
code served (permissive licence) · get_code("f39b0c07b54826f4")
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, clientBN: 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
import numpy as np
from torch.utils.data import TensorDataset
import copy

torch.manual_seed(0)

# Create a simple model
class SimpleModel(nn.Module):
    def __init__(self, num_classes=2):
        super(SimpleModel, self).__init__()
        self.fc1 = nn.Linear(4, 8)
        self.fc2 = nn.Linear(8, num_classes)
        self.bn = nn.BatchNorm2d(1)
    
    def forward(self, x):
        if isinstance(x, list):
            x = x[0]
        x = x.view(x.size(0), -1)
        x = torch.relu(self.fc1(x))
        x = self.fc2(x)
        return x

# Create dummy train and test data
def create_dummy_dataloader(num_samples=10, num_features=4, num_classes=2, batch_size=2):
    X = torch.randn(num_samples, num_features)
    y = torch.randint(0, num_classes, (num_samples,))
    dataset = TensorDataset(X, y)
    return dataset

# Mock the read_client_data function
def read_client_data(dataset, client_id, is_train=True, few_shot=False):
    return create_dummy_dataloader(num_samples=10, num_features=4, num_classes=2, batch_size=2)

# Inject the mock function into the module scope
import sys
current_module = sys.modules[__name__]
current_module.read_client_data = read_client_data

# Create args object
class ArgsConfig:
    def __init__(self):
        self.model = SimpleModel(num_classes=2)
        self.algorithm = "FedAvg"
        self.dataset = "mnist"
        self.device = torch.device("cpu")
        self.save_folder_name = "/tmp/federated_learning"
        self.num_classes = 2
        self.batch_size = 2
        self.local_learning_rate = 0.01
        self.local_epochs = 5
        self.few_shot = False
        self.learning_rate_decay_gamma = 0.99
        self.learning_rate_decay = True

ARGS = {
    'args': ArgsConfig(),
    'id': 0,
    'train_samples': 10,
    'test_samples': 5,
    'train_slow': 0.0,
    'send_slow': 0.0
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
numpy, sklearn, torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type clientBN — 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 clientBN 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
psnr Ran
ran, honoured the contract we drafted
TsingZ0/PFL-Non-IID/system/flcore/servers/serverbn.py
code served (permissive licence) · get_code("417018913135e19a")
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 float32, ndim 0, dtype family float, shape () 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

# Create two small numpy arrays representing images
# The function expects arrays that can be subtracted and have mean computed
original = np.random.rand(4, 3).astype(np.float32)
contrast = np.random.rand(4, 3).astype(np.float32)

ARGS = {
    "original": original,
    "contrast": contrast,
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
numpy — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type float32, ndim 0, dtype family float, shape () — shape () 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
read_client_data Ran
ran; our contract draft was wrong, not the code
TsingZ0/PFL-Non-IID/system/flcore/servers/serverbn.py
code served (permissive licence) · get_code("baa08f0b4e0d3a57")
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. 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 numpy as np
import os
import tempfile
from collections import defaultdict

torch.manual_seed(0)

# Create a temporary directory structure to mock the dataset
temp_dir = tempfile.mkdtemp()
dataset_dir = os.path.join(temp_dir, 'dataset', 'MNIST', 'train')
os.makedirs(dataset_dir, exist_ok=True)

# Create a mock .npz file for client 0
mock_data = {
    'x': np.random.rand(2, 4).astype(np.float32),
    'y': np.array([0, 1], dtype=np.int64)
}
npz_path = os.path.join(dataset_dir, '0.npz')
np.savez(npz_path, data=mock_data)

# Patch os.path.join to use our temp directory
original_join = os.path.join
def patched_join(*args):
    if len(args) > 0 and args[0] == '../dataset':
        return original_join(temp_dir, 'dataset', *args[1:])
    return original_join(*args)

os.path.join = patched_join

ARGS = {
    'dataset': 'MNIST',
    'idx': 0,
    'is_train': True,
    'few_shot': 0
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1
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 — a list 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
stratified_split Ran
ran; the contract check could not run (RAISES, DEP_MISSING or TIMEOUT)
med-air/FedBN/utils/data_preprocess.py
pointer only (licence: NONE) · get_code("c4c79d49a4db6ea4")
How it ran

The body of this sample is withheld: GitHub detected no licence in this paper's repository, med-air/FedBN 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.

FedBN Not yet run
unverified (harvested, no recorded run)
TsingZ0/PFL-Non-IID/system/flcore/servers/serverbn.py
code served (permissive licence) · get_code("405bc33570a8c6b3")
How it ran

no invocation recorded.

Server Not yet run
unverified (harvested, no recorded run)
TsingZ0/PFL-Non-IID/system/flcore/servers/serverbn.py
code served (permissive licence) · get_code("ab6103d2a317e40a")
How it ran

no invocation recorded.

communication Not yet run
unverified (harvested, no recorded run)
med-air/FedBN/federated/fed_domainnet.py
pointer only (licence: NONE) · get_code("2fd0c777cb416959")
How it ran

The body of this sample is withheld: GitHub detected no licence in this paper's repository, med-air/FedBN 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. No invocation recorded.

get_confirm_token Not yet run
unverified (harvested, no recorded run)
med-air/FedBN/utils/data_preprocess.py
pointer only (licence: NONE) · get_code("135b3dc835ffe6ad")
How it ran

The body of this sample is withheld: GitHub detected no licence in this paper's repository, med-air/FedBN 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. No invocation recorded.

train Not yet run
unverified (harvested, no recorded run)
med-air/FedBN/federated/fed_digits.py
pointer only (licence: NONE) · get_code("ecb6e27008c12b2b")
How it ran

The body of this sample is withheld: GitHub detected no licence in this paper's repository, med-air/FedBN 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. No invocation recorded.

train_fedprox Not yet run
unverified (harvested, no recorded run)
med-air/FedBN/federated/fed_digits.py
pointer only (licence: NONE) · get_code("3c6e4c6321f0a002")
How it ran

The body of this sample is withheld: GitHub detected no licence in this paper's repository, med-air/FedBN 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. No invocation recorded.

Also present in other papers' code

Of 13 samples lifted from this paper's linked repositories, 13 carry a function identity and 0 do not. Of the 13 distinct functions with an identity, 7 are also present in other papers whose code we hold (6 with at least one paper dated earlier, 0 the same month, 7 later) and 6 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
get_confirm_token 38 other papers
26 dated earlier, 12 later
1409.8230 (2014-09)
RENOIR - A Dataset for Real Low-Light Image Noise Reduction
1503.03832 (2015-03)
FaceNet: A Unified Embedding for Face Recognition and Clustering
1506.03134 (2015-06)
Pointer Networks
and 35 more not named here
read_client_data
brick of this paper's assembly: helper
10 other papers
3 dated earlier, 7 later · 8 only as an assembly brick
1602.05629 (2016-02)
Communication-Efficient Learning of Deep Networks from Decentralized Data
2001.01523 (2020-01)
Think Locally, Act Globally: Federated Learning with Local and Global Representations
2012.04221 (2020-12)
Ditto: Fair and Robust Federated Learning Through Personalization
and 7 more not named here
Client
brick of this paper's assembly: helper
9 other papers
3 dated earlier, 6 later · 2 only as an assembly brick
1602.05629 (2016-02)
Communication-Efficient Learning of Deep Networks from Decentralized Data
2001.01523 (2020-01)
Think Locally, Act Globally: Federated Learning with Local and Global Representations
2012.04221 (2020-12)
Ditto: Fair and Robust Federated Learning Through Personalization
and 6 more not named here
DLG
brick of this paper's assembly: helper
8 other papers
1 dated earlier, 7 later · 4 only as an assembly brick
1602.05629 (2016-02)
Communication-Efficient Learning of Deep Networks from Decentralized Data
2106.06042 (2021-06)
FEDBABU: TOWARD ENHANCED REPRESENTATION FOR FEDERATED IMAGE CLASSIFICATION
2111.04263 (2021-11)
Federated Learning Based on Dynamic Regularization
and 5 more not named here
psnr
brick of this paper's assembly: helper
7 other papers
1 dated earlier, 6 later · 6 only as an assembly brick
1602.05629 (2016-02)
Communication-Efficient Learning of Deep Networks from Decentralized Data
2106.06042 (2021-06)
FEDBABU: TOWARD ENHANCED REPRESENTATION FOR FEDERATED IMAGE CLASSIFICATION
2111.04263 (2021-11)
Federated Learning Based on Dynamic Regularization
and 4 more not named here
Server
brick of this paper's assembly: helper
4 other papers
1 dated earlier, 3 later
1602.05629 (2016-02)
Communication-Efficient Learning of Deep Networks from Decentralized Data
2106.06042 (2021-06)
FEDBABU: TOWARD ENHANCED REPRESENTATION FOR FEDERATED IMAGE CLASSIFICATION
2111.04263 (2021-11)
Federated Learning Based on Dynamic Regularization
and 1 more not named here
train_fedprox 1 other paper
1 later
2210.00912 (2022-10)
Federated Domain Generalization for Image Recognition via Cross-Client Style Transfer

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

The emerging paradigm of federated learning (FL) strives to enable collaborative training of deep models on the network edge without centrally aggregating raw data and hence improving data privacy. In most cases, the assumption of independent and identically distributed samples across local clients does not hold for federated learning setups. Under this setting, neural network training performance may vary significantly according to the data distribution and even hurt training convergence. Most of the previous work has focused on a difference in the distribution of labels or client shifts. Unlike those settings, we address an important problem of FL, e.g., different scanners/sensors in medical imaging, different scenery distribution in autonomous driving (highway vs. city), where local clients store examples with different distributions compared to other clients, which we denote as feature shift non-iid. In this work, we propose an effective method that uses local batch normalization to alleviate the feature shift before averaging models. The resulting scheme, called FedBN, outperforms both classical FedAvg, as well as the state-of-the-art for non-iid data (FedProx) on our extensive experiments. These empirical results are supported by a convergence analysis that shows in a simplified setting that FedBN has a faster convergence rate than FedAvg. Code is available at https://github.com/med-air/FedBN. Recent studies have attempted to address the problem of FL on non-iid data. Most variants of FedAvg primarily tackle the issues of stability, client drift and heterogeneous label distribution over * Work was done during the transition from Yale University to Princeton University.

For agents

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

get_harvested_code_for_paper("2102.07623")
get_code_for_paper("2102.07623")
have("2102.07623")

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

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

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

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

Connect an agent — have() is free.