-
Notifications
You must be signed in to change notification settings - Fork 11
/
main.py
43 lines (38 loc) · 1.18 KB
/
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
import os
os.environ["CUDA_VISIBLE_DEVICES"]="0"
from utils.trainer_utils import TrainConfig
from flearn.trainer.fedavg import FedAvg
from flearn.trainer.ifca import IFCA
from flearn.trainer.fesem import FeSEM
from flearn.trainer.fedgroup import FedGroup
# Modify these settings as you need
def main_fedavg():
config = TrainConfig('mnist', 'mlp', 'fedavg')
trainer = FedAvg(config)
trainer.train()
#trainer.train_locally()
def main_ifca():
config = TrainConfig('mnist', 'mlp', 'ifca')
config.trainer_config['dynamic'] = False # whether migrate clients
trainer = IFCA(config)
trainer.train()
#trainer.train_locally()
def main_fesem():
config = TrainConfig('mnist', 'mlp', 'fesem')
config.trainer_config['dynamic'] = False
trainer = FeSEM(config)
trainer.train()
#trainer.train_locally()
def main_flexcfl():
config = TrainConfig('femnist', 'mlp', 'fedgroup')
config.trainer_config['dynamic'] = True
config.trainer_config['shift_type'] = "all"
config.trainer_config['swap_p'] = 0.05
trainer = FedGroup(config)
trainer.train()
main_flexcfl()
''' # Uncomment these codes as you need
main_fedavg()
main_fesem()
main_ifca()
'''