Skip to content

wangf622/AdaDQ-KD

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

基于差分隐私的联邦学习

代码

提示:原仓库的FL代码是基于 这个仓库 实现的,目前已按论文工作作过大量改动,但框架仍适用。

参数列表

数据集: Cifar-10, FEMNIST

模型: Resnet-18

DP机制: Gaussian(Simple Composition)

DP参数: $\epsilon$ and $\delta$

DP裁剪: 在机器学习任务中,为了计算敏感度,通常情况下需要对梯度进行裁剪,限制梯度的一范数或者二范数的值。

实验环境

python == 3.12

另外原仓库引用 opacus == 1.1.1 进行逐样本梯度裁剪,改动后已删除。 opacus 占用内存过高,现用简易的模块实现汇总梯度的裁剪。

环境搭配完成后运行主程序 main_resnet.py 即可。

高斯机制

Simple合成定理

基于DP中的Simple Composition。

也就是说,如果某个客户端的隐私预算是 $\epsilon$ ,这个客户端被选中 $T$ 次的话,那么该客户端每次加噪使用的预算为 $\epsilon / T$

论文(原仓库)

附注(原仓库)

新版本用了Opacus进行 Per Sample Gradient Clip,限制了每一条Sample计算出的梯度的范数。

本代码设置了本地训练轮数为1,并且batch size为客户端本地的数据集大小,由于Opacus库的训练会保存所有样本的梯度,因此训练时gpu显存占用非常大。 解决此问题可以通过指定 --serial--serial_bs 参数。

这两个参数会从物理上指定一个虚拟的batch size,相应的训练时间会变长,但是逻辑上不会影响训练和DP噪声的添加,这么做的主要原因是为了不违背DP噪声添加的理论。

Dev分支目前还在完善中,里面实现了包括MA、F-DP、以及Shuffle等新的DPFL算法,欢迎感兴趣的朋友提出宝贵意见!

引用(原仓库)

考虑引用以下文 章:

[1] W. Yang et al., "Gain Without Pain: Offsetting DP-Injected Noises Stealthily in Cross-Device Federated Learning," in IEEE Internet of Things Journal, vol. 9, no. 22, pp. 22147-22157, 15 Nov.15, 2022, doi: 10.1109/JIOT.2021.3102030.

[2] M. Hu et al., "AutoFL: A Bayesian Game Approach for Autonomous Client Participation in Federated Edge Learning," in IEEE Transactions on Mobile Computing, doi: 10.1109/TMC.2022.3227014.

[3] Y. Zhou et al., "Optimizing the Numbers of Queries and Replies in Convex Federated Learning with Differential Privacy," in IEEE Transactions on Dependable and Secure Computing, doi: 10.1109/TDSC.2023.3234599.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages