Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Share some fine-tuned hyperparameter settings #136

Open
FryLcm opened this issue Oct 26, 2023 · 8 comments
Open

Share some fine-tuned hyperparameter settings #136

FryLcm opened this issue Oct 26, 2023 · 8 comments
Labels
share knowledge Share some insights on usage

Comments

@FryLcm
Copy link

FryLcm commented Oct 26, 2023

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

@FryLcm
Copy link
Author

FryLcm commented Oct 26, 2023

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
Copy link
Author

FryLcm commented Oct 26, 2023

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
Copy link
Author

FryLcm commented Oct 26, 2023

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
Copy link
Author

FryLcm commented Oct 26, 2023

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
Copy link

xxdznl commented Apr 1, 2024

-gr不是2000吗?

@FryLcm
Copy link
Author

FryLcm commented Apr 8, 2024

-gr不是2000吗?

1000轮内就完全可以收敛了

@TsingZ0
Copy link
Owner

TsingZ0 commented Apr 17, 2024

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

@TsingZ0 TsingZ0 changed the title 超参数选择 Share some fine-tuned hyperparameter settings Apr 18, 2024
@TsingZ0 TsingZ0 added enhancement New feature or request share knowledge Share some insights on usage and removed enhancement New feature or request labels Apr 18, 2024
@JACKSON1077
Copy link

JACKSON1077 commented Aug 25, 2024

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,是哪里的设定我没有注意到吗?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
share knowledge Share some insights on usage
Projects
None yet
Development

No branches or pull requests

4 participants