1 Star 0 Fork 0

kjm/pytorch_federated_learning

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
贡献代码
同步代码
取消
提示: 由于 Git 不支持空文件夾,创建文件夹后会生成空的 .keep 文件
Loading...
README
MIT

PyTorch实现的联邦学习基线方法

PyTorch-Federated-Learning 提供了使用PyTorch框架实现的各种联邦学习基线方法。代码库遵循客户端-服务器架构,非常直观和易于上手。

如果你觉得这个仓库有用,请用你的小星星支持一下。非常感谢!

英文|简体中文

  • 当前的基线实现: Pytorch 实现的联邦学习基线。目前支持的基线有 FedAvg、FedNova、FedProx 和 SCAFFOLD:

    • FedAvg (Hugh Brendan McMahan et al., AISTATS 2017)
    • FedNova (Jianyu Wang et al., NeurIPS 2020)
    • FedProx (Tian Li et al., MLSys 2020)
    • SCAFFOLD (Sai Praneeth Karimireddy et al.,ICML 2020)
  • 数据集预处理: 自动下载常用的公开数据集,并将其根据联邦学习特点分割给多个客户端,比如按照不同的非独立同分布要求进行分割。目前支持的数据集有 MNIST,Fashion-MNIST,SVHN,CIFAR-10,CIFAR-100。其他数据集需要手动下载。

  • 后处理: 为评估而进行的训练结果可视化。

安装

依赖项

  • Python (3.8)
  • PyTorch (1.8.1)
  • OpenCV (4.5)
  • numpy (1.21.5)

安装要求

运行: pip install -r requirements.txt to install the required packages.

联邦数据集预处理

此预处理旨在将整个数据集根据联邦设置分配给指定数量的客户端。根据每个本地数据集中的类别数量,整个数据集被划分为非独立同分布(Non-IID)数据集,这是根据标签分布偏斜来决定的。

执行联邦学习基线

测试运行

在一个 yaml 文件中定义超参数,例如 "./config/test_config.yaml", 然后只需用这个配置运行:

python fl_main.py --config "./config/test_config.yaml"

性能评估

运行 python postprocessing/eval_main.py -rr 'results' 以绘制测试精度和训练损失随着轮数或通信轮数的增加。注意,图中的标签是结果文件的名称。

MIT License Copyright (c) 2023 Rui Song Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

简介

暂无描述 展开 收起
README
MIT
取消

发行版

暂无发行版

贡献者

全部

语言

近期动态

不能加载更多了
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/jimmyke868/pytorch_federated_learning.git
git@gitee.com:jimmyke868/pytorch_federated_learning.git
jimmyke868
pytorch_federated_learning
pytorch_federated_learning
main

搜索帮助