← 开源
KarhouTam

FL-bench

Benchmark of federated learning. Dedicated to the community. 🤗

Model DevelopmentTraining toolkitsPython
在 GitHub 打开
增长势头
+024 小时新增 Star0.0%
693
Star
116
Fork
+1
本周
8
贡献者
创建于 2023-01-25 · 更新于 2026-10-14 · 今日第 14908 名
主要开发者
KarhouTamKevinHaooneko941

KarhouTam/FL-bench 排名第 14,908,有 693 个星标。

同类别比较

KarhouTam/FL-bench 排名第 14,908,此处有 8 个同类条目;ankane/eps 排名第 14,913。

同类别比较
名称排名指标
mv-lab/swin2sr14,889
语言:
Python
星标数:
695
分叉数:
83
简介:
[ECCV] Swin2SR: SwinV2 Transformer for Compressed Image Super-Resolution and Restoration. Advances in Image Manipulation (AIM) workshop ECCV 2022. Try it out! over 3.3M runs https://replicate.com/mv-lab/swin2sr
soobinseo/Transformer-TTS14,890
语言:
Python
星标数:
695
分叉数:
139
简介:
A Pytorch Implementation of "Neural Speech Synthesis with Transformer Network"
flink-extended/dl-on-flink14,901
语言:
Java
星标数:
694
分叉数:
196
简介:
Deep Learning on Flink aims to integrate Flink and deep learning frameworks (e.g. TensorFlow, PyTorch, etc) to enable distributed deep learning training and inference on a Flink cluster.
khalil-research/PyEPO14,902
语言:
Jupyter Notebook
星标数:
694
分叉数:
90
简介:
A PyTorch-based End-to-End Predict-then-Optimize Library for Linear and Integer Programming
ankane/eps14,913
语言:
Ruby
星标数:
693
分叉数:
15
简介:
Machine learning for Ruby
elastic/eland14,915
语言:
Python
星标数:
693
分叉数:
112
简介:
Python Client and Toolkit for DataFrames, Big Data, Machine Learning and ETL in Elasticsearch
microsoft/LLM2CLIP14,920
语言:
Python
星标数:
693
分叉数:
34
简介:
LLM2CLIP significantly improves already state-of-the-art CLIP models.
SciML/OrdinaryDiffEq.jl14,927
语言:
Julia
星标数:
692
分叉数:
284
简介:
High performance ordinary differential equation (ODE) and differential-algebraic equation (DAE) solvers, including neural ordinary differential equations (neural ODEs) and scientific machine learning (SciML)
关键参数与规格
关键参数与规格
参数值
语言Python
类别Model Development
子类别Training toolkits
关键词Benchmarks, Federated learning
星标数693
分叉数116
贡献者8
创建日期2023-01-25
更新日期2026-10-14
1 天星标数0
7 天星标数1
排名14,908
上次排名14,743
排名变化-165
7 天星标排名10,913
上次 7 天星标排名10,970
7 天星标排名变化57
总星标排名14,985
上次总星标排名14,968
总星标排名变化-17
README 摘录

FL-bench welcomes PR on everything that can make this project better. If you wanna figure out the entire workflow and detail of variable settings, go check and . Generate FL Dataset Partition the MNIST according to Dir(0. 1) for 100 clients About methods of generating federated dastaset, go check for full details. Run Experiment : The algorithm's name, e. NOTE\] should be identical to the file name in . : Relative path to the directory of the config file. : Name of config

file (w/o the extension). Such as running FedAvg with all defaults. How To Customize FL method Arguments 🤖 By modifying config file. By modifying the default value in or in \[! NOTE\] For the same FL method argument, the priority of argument setting is **CLI > Config file > Default value**. For example, the default value of is , and your config file has Monitor 📈 FL-bench supports and . NOTE\] You needs to launch / server by yourself. Parallel Training via 🚀 This feature can **vastly

improve your training efficiency**. At the same time, this feature is user-friendly and easy to use! Activate (What You ONLY Need To Do) Manually Create Cluster (Optional) A cluster would be created implicitly everytime you run experiment in parallel mode. TIP\] You can create it manually by the command shown below to avoid creating and destroying cluster every time you run experiment. NOTE\] You need to keep and in your config file for connecting to a existing cluster. Arguments

🔧 FL-bench highly recommend through config file to customize your FL method and experiment settings. FL-bench offers a default config file that contains all required arguments and corresponding comments. All common arguments have their default value. Go check or in for all argument defaults. NOTE\] If your custom config file does not contain all required arguments, FL-bench will fill those missing arguments with their defaults that loaded from . About the default values of specific FL method arguments, go

check corresponding for the full details. TIP\] FL-bench also supports CLI arguments for quick changings. Here are some examples: Models 🤖 This benchmark supports bunch of models that common and integrated in Torchvision (check here for all): ResNet family EfficientNet family DenseNet family MobileNet family LeNet5 . TIP\] You can define your own custom model by filling the class in and use it by defining in your config file. Datasets and Partition Strategies 🎨 Regular Image Datasets *MNIST* (1 x 28 x

28, 10 classes) *CIFAR-10/100* (3 x 32 x 32, 10/100 classes) *EMNIST* (1 x 28 x 28, 62 classes) *FashionMNIST* (1 x 28 x 28, 10 classes) *Syhthetic Dataset* *FEMNIST* (1 x 28 x 28, 62 classes) *CelebA* (3 x 218 x 178, 2 classes) *SVHN* (3 x 32 x 32, 10 classes) *USPS* (1 x 16 x 16, 10 classes) *Tiny-ImageNet-200* (3 x 64 x 64, 200 classes) *CINIC-10* (3 x 32 x

32, 10 classes) Domain Generalization Image Datasets *DomainNet* (3 x ? , 345 classes) Go check for the full process guideline 🧾. Medical

常见问题

记录了多少星标和分叉?

KarhouTam/FL-bench 有 693 个星标和 116 个分叉。

仓库排名是多少?

KarhouTam/FL-bench 排名第 14,908。

记录的语言和类别是什么?

KarhouTam/FL-bench 有 693 个星标,语言为 Python,类别为 Model Development。

哪个仓库排名最接近?

KarhouTam/FL-bench 与 ankane/eps 比较,后者排名第 14,913,有 693 个星标。

README

Benchmarking Federated Learning Methods.

Realizing Your Brilliant Ideas.

Having Fun with Federated Learning.

FL-bench welcomes PR on everything that can make this project better.

FL-bench 的简单介绍

Methods 🧬

Traditional FL Methods

Personalized FL Methods

FL Domain Generalization Methods

Differential Privacy FL Methods

Environment Preparation 🧩

PyPI 🐍

pip install -r .env/requirements.txt

Easy Run 🏃‍♂️

ALL classes of methods are inherited from FedAvgServer and FedAvgClient. If you wanna figure out the entire workflow and detail of variable settings, go check src/server/fedavg.py and src/client/fedavg.py.

Step 1. Generate FL Dataset

Partition the MNIST according to Dir(0.1) for 100 clients

python generate_data.py -d mnist -a 0.1 -cn 100

About methods of generating federated dastaset, go check data/README.md for full details.

Step 2. Run Experiment

python main.py [--config-path, --config-name] [method= args...]
  • method: The algorithm's name, e.g., method=fedavg.

[!NOTE] method should be identical to the .py file name in src/server.

  • --config-path: Relative path to the directory of the config file. Defaults to config.
  • --config-name: Name of .yaml config file (w/o the .yaml extension). Defaults to defaults, which points to config/defaults.yaml.

Such as running FedAvg with all defaults.

python main.py method=fedavg

Defaults are set in both config/defaults.yaml and src/utils/constants.py.

How To Customize FL method Arguments 🤖

  • By modifying config file.
  • By explicitly setting in CLI, e.g., python main.py --config-name my_cfg.yaml method=fedprox fedprox.mu=0.01.
  • By modifying the default value in config/defaults.yaml or get_hyperparams() in src/server/.py

[!NOTE] For the same FL method argument, the priority of argument setting is CLI > Config file > Default value.

For example, the default value of fedprox.mu is 1,

# src/server/fedprox.py
class FedProxServer(FedAvgServer):

    @staticmethod
    def get_hyperparams(args_list=None) -> Namespace:
        parser = ArgumentParser()
        parser.add_argument("--mu", type=float, default=1.0)
        return parser.parse_args(args_list)

and your .yaml config file has

# config/your_config.yaml
...
fedprox:
  mu: 0.01
python main.py method=fedprox                                            # fedprox.mu = 1
python main.py --config-name your_config method=fedprox                  # fedprox.mu = 0.01
python main.py --config-name your_config method=fedprox fedprox.mu=0.001 # fedprox.mu = 0.001

Monitor 📈

FL-bench supports visdom and tensorboard.

Activate

# your_config.yaml
common:
  ...
  monitor: tensorboard # options: [null, visdom, tensorboard]

[!NOTE] You needs to launch visdom / tensorboard server by yourself.

Launch visdom / tensorboard Server

visdom
  1. Run python -m visdom.server on terminal.
  2. Go check localhost:8097 on your browser.

tensorboard

  1. Run tensorboard --logdir= on terminal.
  2. Go check localhost:6006 on your browser.

Parallel Training via Ray 🚀

This feature can vastly improve your training efficiency. At the same time, this feature is user-friendly and easy to use!!!

Activate (What You ONLY Need To Do)

# your_config.yaml
mode: parallel
parallel:
  num_workers: 2 # any positive integer that larger than 1
  ...
...

Manually Create Ray Cluster (Optional)

A Ray cluster would be created implicitly everytime you run experiment in parallel mode.

[!TIP] You can create it manually by the command shown below to avoid creating and destroying cluster every time you run experiment.

ray start --head [OPTIONS]

[!NOTE] You need to keep num_cpus: null and num_gpus: null in your config file for connecting to a existing Ray cluster.

# your_config_file.yaml
# Connect to an existing Ray cluster in localhost.
mode: parallel
parallel:
  ...
  num_gpus: null
  num_cpus: null
...

Arguments 🔧

FL-bench highly recommend through config file to customize your FL method and experiment settings.

FL-bench offers a default config file config/defaults.yaml that contains all required arguments and corresponding comments.

All common arguments have their default value. Go check config/defaults.yaml or DEFAULTS in src/utils/constants.py for all argument defaults.

[!NOTE] If your custom config file does not contain all required arguments, FL-bench will fill those missing arguments with their defaults that loaded from DEFAULTS.

About the default values of specific FL method arguments, go check corresponding src/server/.py for the full details.

[!TIP] FL-bench also supports CLI arguments for quick changings. Here are some examples:

# Using config/defaults.yaml but change the method to FedProx and set its mu to 0.1.
python main.py method=fedprox fedprox.mu=0.1

# Change learning rate to 0.1.
python main.py optimizer.lr=0.1

# Change batch size to 128.
python main.py common.batch_size=128

Models 🤖

This benchmark supports bunch of models that common and integrated in Torchvision (check here for all):

  • ResNet family
  • EfficientNet family
  • DenseNet family
  • MobileNet family
  • LeNet5
  • ...

[!TIP] You can define your own custom model by filling the CustomModel class in src/utils/models.py and use it by defining model: custom in your .yaml config file.

Datasets and Partition Strategies 🎨

Regular Image Datasets

  • MNIST (1 x 28 x 28, 10 classes)

  • CIFAR-10/100 (3 x 32 x 32, 10/100 classes)

  • EMNIST (1 x 28 x 28, 62 classes)

  • FashionMNIST (1 x 28 x 28, 10 classes)

  • Syhthetic Dataset

  • FEMNIST (1 x 28 x 28, 62 classes)

  • CelebA (3 x 218 x 178, 2 classes)

  • SVHN (3 x 32 x 32, 10 classes)

  • USPS (1 x 16 x 16, 10 classes)

  • Tiny-ImageNet-200 (3 x 64 x 64, 200 classes)

  • CINIC-10 (3 x 32 x 32, 10 classes)

Domain Generalization Image Datasets

Medical Image Datasets

Customization Tips 💡

Implementing FL Method

The package() at server-side class is used for assembling all parameters server need to send to clients. Similarly, package() at client-side class is for parameters clients need to send back to server. You should always has super().package() in your override implementation.

  • Consider to inherit your method classes from FedAvgServer and FedAvgClient for maximum utilizing FL-bench's workflow.

  • You can also inherit your method classes from advanced methods, e.g., FedBN, FedProx, etc. Which will inherit all functions, variables and hyperparamter settings. If you do that, you need to careful design your method in order to avoid potential hyperparamters and workflow conflicts.

class YourServer(FedBNServer):
  ...

class YourClient(FedBNClient):
  ...
  • For customizing your server-side process, consider to override the package() and aggregate_client_updates().

  • For customizing your client-side training, consider to override the fit(), set_parameters() and package().

You can find all details in FedAvgClient and FedAvgServer, which are the bases of all implementations in FL-bench.

Integrating Dataset

  • Inherit your own dataset class from BaseDataset in data/utils/datasets.py and add your class in dict DATASETS. Highly recommend to refer to the existing dataset classes for guidance.

Customizing Model

  • I offer the CustomModel class in src/utils/models.py and you just need to define your model arch.
  • If you want to use your customized model within FL-bench's workflow, the base and classifier must be defined. (Tips: You can define one of them as torch.nn.Identity() for bypassing it.)

Citation 🧐

@software{Tan_FL-bench,
  author = {Tan, Jiahao and Wang, Xinpeng},
  license = {GPL-3.0},
  title = {{FL-bench: A federated learning benchmark for solving image classification tasks}},
  url = {https://github.com/KarhouTam/FL-bench}
}
@misc{tan2023pfedsim,
  title={pFedSim: Similarity-Aware Model Aggregation Towards Personalized Federated Learning}, 
  author={Jiahao Tan and Yipeng Zhou and Gang Liu and Jessie Hui Wang and Shui Yu},
  year={2023},
  eprint={2305.15706},
  archivePrefix={arXiv},
  primaryClass={cs.LG}
}

排名相邻
同类项目