TsingZ0 / PFLlib

37 traditional FL (tFL) or personalized FL (pFL) algorithms, 3 scenarios, and 20 datasets.
GNU General Public License v2.0
1.44k stars 298 forks source link

Share some fine-tuned hyperparameter settings #136

Open FryLcm opened 1 year ago

FryLcm commented 1 year ago

以下是我使用该仓库进行的一些方法复现所使用的超参数,走过路过的朋友们,如果发现哪里超参数的选择不合理或该使用的超参数未使用到,麻烦提醒下我,不胜感激。

FryLcm commented 1 year ago

fedavg: python main.py -nb 10 -data Cifar10 -m cnn -algo FedAvg -gr 1000 -did 0 -lr 0.005 -go cnn > cifar10_fedavg_1.out 2>&1 python main.py -nb 100 -data Cifar100 -m cnn -algo FedAvg -gr 1000 -did 0 -lr 0.005 -go cnn > cifar100_fedavg_1.out 2>&1 python main.py -nb 200 -data Tiny-imagenet -m cnn -algo FedAvg -gr 1000 -did 0 -lr 0.005 -go cnn >tiny_fedavg_1.out 2>&1

FryLcm commented 1 year ago

per-fedavg python main.py -nb 10 -data Cifar10 -m cnn -algo PerAvg -gr 1000 -did 0 -lr 0.005 -bt 0.001 -go cnn > cifar10_per-fedavg_1.out 2>&1

python main.py -nb 100 -data Cifar100 -m cnn -algo PerAvg -gr 1000 -did 0 -lr 0.005 -bt 0.001 -go cnn > cifar100_per-fedavg_1.out 2>&1

python main.py -nb 200 -data Tiny-imagenet -m cnn -algo PerAvg -gr 1000 -did 0 -lr 0.005 -bt 0.001 -go cnn > tiny_per-fedavg_1.out 2>&1

FryLcm commented 1 year ago

APFL: python main.py -nb 10 -data Cifar10 -m cnn -algo APFL -gr 1000 -did 0 -lr 0.005 -al 1.0 -go cnn > cifar10_APFL_1.out 2>&1

python main.py -nb 100 -data Cifar100 -m cnn -algo APFL -gr 1000 -did 0 -lr 0.005 -al 1.0 -go cnn > cifar100_APFL_1.out 2>&1

python main.py -nb 200 -data Tiny-imagenet -m cnn -algo APFL -gr 1000 -did 0 -lr 0.005 -al 1.0 -go cnn > tiny_APFL_1.out 2>&1

FryLcm commented 1 year ago

pFedMe python main.py -nb 10 -data Cifar10 -m cnn -algo pFedMe -gr 1000 -did 0 -lr 0.005 -lrp 0.01 -bt 1 -lam 15 -K 5 -go cnn > cifar10_pFedMe_1.out 2>&1

python main.py -nb 100 -data Cifar100 -m cnn -algo pFedMe -gr 1000 -did 0 -lr 0.005 -lrp 0.01 -bt 1 -lam 15 -K 5 -go cnn > cifar100_pFedMe_1.out 2>&1

python main.py -nb 200 -data Tiny-imagenet -m cnn -algo pFedMe -gr 1000 -did 0 -lr 0.005 -lrp 0.01 -bt 1 -lam 15 -K 5 -go cnn > tiny_pFedMe_1.out 2>&1

xxdznl commented 7 months ago

-gr不是2000吗?

FryLcm commented 6 months ago

-gr不是2000吗?

1000轮内就完全可以收敛了

TsingZ0 commented 6 months ago

是的,-gr的设置没有严格要求,如果算法能在1000轮内收敛,那么-gr 1000-gr 2000最终结果是一样的

JACKSON1077 commented 2 months ago

fedavg: python main.py -nb 10 -data Cifar10 -m cnn -algo FedAvg -gr 1000 -did 0 -lr 0.005 -go cnn > cifar10_fedavg_1.out 2>&1 python main.py -nb 100 -data Cifar100 -m cnn -algo FedAvg -gr 1000 -did 0 -lr 0.005 -go cnn > cifar100_fedavg_1.out 2>&1 python main.py -nb 200 -data Tiny-imagenet -m cnn -algo FedAvg -gr 1000 -did 0 -lr 0.005 -go cnn >tiny_fedavg_1.out 2>&1

FedAvg真的可以在1000个round下收敛吗?我在“serveravg.py”中加了这两句: print("\nBest Round.") print(self.rs_test_acc.index(max(self.rs_test_acc))) 来检查收敛情况,在2000个epoch下,cifar10在第1996个round时acc达到63.52%(1996/2000),cifar100是34.20%(1984/2000),这里acc比作者ALA里面高可能是随机种子的关系,我想说的是似乎超过2000个round他还能继续收敛?其他的超参数都一样没动过

顺便一提,按照上面提到的pFedMe的超参数设定(和ALA文中提到的一致),似乎完全没有办法收敛,即便跑完2000rounds,下面是我pFedMe的log cifar10:

结果 Best Accuracy. 0.4925049966688874 Best Round. 1904 Average time cost per round. 189.54730161607264 Average time cost: 379293.88s. Length: 2001 std for best accurancy: 0.0 mean for best accurancy: 0.4925049966688874 All done!

超参数及模型 Algorithm: pFedMe Local batch size: 10 Local steps: 1 Local learing rate: 0.005 Local learing rate decay: False Total number of clients: 20 Clients join in each round: 1.0 Clients randomly join: False Client drop rate: 0.0 Client select regarding time: False Running times: 1 Dataset: Cifar10-dir0.1-numclient20-npz Number of classes: 10 Backbone: cnn Using device: cuda Using DP: False Auto break: False Global rounds: 2000 Cuda device id: 0 DLG attack: False Total number of new clients: 0 Fine tuning epoches on new clients: 0

============= Running time: 0th ============= Creating server and clients ... FedAvgCNN( (conv1): Sequential( (0): Conv2d(3, 32, kernel_size=(5, 5), stride=(1, 1)) (1): ReLU(inplace=True) (2): MaxPool2d(kernel_size=(2, 2), stride=(2, 2), padding=0, dilation=1, ceil_mode=False) ) (conv2): Sequential( (0): Conv2d(32, 64, kernel_size=(5, 5), stride=(1, 1)) (1): ReLU(inplace=True) (2): MaxPool2d(kernel_size=(2, 2), stride=(2, 2), padding=0, dilation=1, ceil_mode=False) ) (fc1): Sequential( (0): Linear(in_features=1600, out_features=512, bias=True) (1): ReLU(inplace=True) ) (fc): Linear(in_features=512, out_features=10, bias=True) )

Join ratio / total clients: 1.0 / 20 Finished creating server and clients. pFedMe达不到ALA中提到的88.09±0.32,是哪里的设定我没有注意到吗?

KalosAner commented 1 week ago

为什么你们的cnn是小写的?main.py代码上是model_str == "CNN",我的也是只有大写的CNN才能运行