-
Notifications
You must be signed in to change notification settings - Fork 5
/
write_config.py
executable file
·61 lines (48 loc) · 1.07 KB
/
write_config.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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
import json
import os
seed = 0
dataset = 'CIFAR10' # ['MNIST', 'CIFAR10', 'CIFAR100']
alpha = 0.01
scheme = 'FedAvg'
path = 'config/data-heterog/' + dataset + '/' + scheme
try:
os.mkdir('config/data-heterog/' + dataset)
except FileExistsError:
pass
try:
os.mkdir(path)
except FileExistsError:
pass
model = 'VGG-9' # ['Net', 'VGG-9', 'ResNet-18', 'ResNet-34', 'ShuffleNet-V2']
lr = 0.001
weight_decay = 0
epochs = 40
loss = 'CE'
# scheme = ['AvgKD', 'FedAvg', 'FedProx', 'FedMA']
clients = 20
data = {
'Dataset' : dataset,
'Alpha': alpha,
'Batch_size': 256,
'Eval_batch_size': 2048
}
optimizer = {
'Name' : 'Adam',
'lr': lr,
'weight_decay' : weight_decay,
'Loss' : loss,
'Epochs' : epochs
}
json_data = {
'Seed' : seed,
'Data' : data,
'Model' : model,
'Optmizer' : optimizer,
'Scheme' : scheme,
'Clients': clients,
'Communications' : 10
}
with open(path + '_' + str(alpha) + '.json', 'w') as jsonFile:
json.dump(json_data, jsonFile)
jsonFile.close()
print('Config has been written to ' + path)