README.md

June 11, 2026 · View on GitHub

Banner

FNR-FL

The official implementation of Feature Norm Regularized Federated Learning (FNR-FL) algorithm, which uniquely incorporates class average feature norms to enhance model accuracy and convergence in non-i.i.d. scenarios.

Paper: Feature Norm Regularized Federated Learning: Utilizing Data Disparities for Model Performance Gains (Under reviewing)

Table of Contents

Introduction to codes

  config.py	
  criteo-dis.npy
  datasets.py             # Dataset-related
  draw_noisy_image.py     # (Additional) Observe samples with added Gaussian noise, use `alg=fedavg` when calling
  femnist-dis.npy
  LICENSE_FNR-FL          # MIT LICENSE for this project (FNR-FL)
  LICENSE_NIID-Bench      # MIT LICENSE for the base code of this project (NIID-Bench)
  model.py                # Define some models
  partition.py            # Define partitioning functions to achieve different non-i.i.d distributions
  README.md
  requirements.txt        # Project dependencies
  resnetcifar.py          # Define ResNet
  train.py                # (Main) Training entry point (for ResNet)
  utils.py
  vggmodel.py             # Define VGG
        
├─models                    # Folder to store model files
     celeba_model.py
     mnist_model.py
     svhn_model.py

Experimental settings

Non-i.i.d settingsPartitionBetaNoise
Label Distribution SkewDistribution-based label imbalancenoniid-labeldir0.50
Feature Distribution SkewNoise-based feature imbalancehomo00.5
Quantity Skew/iid-diff-quantity0.50
Mixed skewdistribution-based label imbalance + quantity skewmixed//
Mixed skewdistribution-based label imbalance + noise-based feature imbalancenoniid-labeldir0.50.5

Installation

(Back to top)

Install dependencies by running:

pip install -r requirements.txt

Usage

(Back to top)

For example, to run the tests on ResNet18:

python train.py 
--model=resnet
--dataset=cifar10
--alg=fnr
--lr=0.01
--cc_optimizer=sgd
--batch-size=64
--test_batch_size=32
--epochs=10
--calibration_epochs=5
--n_parties=10
--mu=0.01
--rho=0.9
--comm_round=10
--partition=mixed
--noise=0.0
--beta=0.5
--device=cuda:0
--datadir=../data/
--logdir=./logs/
--sample=1
--init_seed=0
--ccreg_w=0.5

The parameters and their descriptions are listed as follows:

ParameterDescription
modelThe model architecture. Default = resnet.
datasetDataset to use. Options: mnist, cifar10, fmnist, svhn. Default = mnist.
algThe training algorithm. Options: fedavg, fedprox, scaffold, fednova, moon,fnr. Default = fnr.
lrLearning rate for the local models, default = 0.01.
batch-sizeBatch size, default = 64.
epochsNumber of local training epochs, default = 10.
calibration_epochsNumber of calibration epochs, default = 5.
ccreg_wWeight of calibration regularization term. Default=1.0
n_partiesNumber of parties, default = 2.
muThe proximal term parameter for FedProx, default = 0.001.
rhoThe parameter controlling the momentum SGD, default = 0.
comm_roundNumber of communication rounds to use, default = 10.
partitionThe partition way. Options: homo, noniid-labeldir, iid-diff-quantity. Default = homo
betaThe concentration parameter of the Dirichlet distribution for heterogeneous partition, default = 0.5.
deviceSpecify the device to run the program, default = cuda:0.
datadirThe path of the dataset, default = ./data/.
logdirThe path to store the logs, default = ./logs/.
noiseMaximum variance of Gaussian noise we add to local party, default = 0.
sampleRatio of parties that participate in each communication round, default = 1.
init_seedThe initial seed, default = 0.

Contribute

(Back to top)

Thanks goes to these wonderful people:

LonelyMoonDesert
LonelyMoonDesert

💻 🎨 🤔

This project follows the all-contributors specification. Contributions of any kind welcome!

Citation

(Back to top) If you find our work useful in your research, please consider citing our paper:

hided

Acknowledgments

(Back to top) We would like to express our sincere gratitude to the Xtra-Computing Group for their NIID-Bench repository, which has been instrumental in the development of our project. Our codebase is built upon the foundational work provided by their extensive research and resources in non-independent and identically distributed (non-i.i.d.) data for federated learning. We appreciate the opportunity to contribute to the ongoing dialogue in this field and thank the Xtra-Computing Group for their valuable contributions to the community.

License

(Back to top)

MIT license

Back to top